software-security-appsec by vasilyu1983/ai-agents-public
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill software-security-appsec构建安全应用程序的生产级安全模式(截至 2026 年 1 月)。涵盖 OWASP Top 10:2025(稳定版)https://owasp.org/Top10/2025/ 以及 OWASP API 安全 Top 10(2023)https://owasp.org/API-Security/ 和安全 SDLC 基线(NIST SSDF)https://csrc.nist.gov/publications/detail/sp/800-218/final。
在以下情况下激活此技能:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 安全任务 | 工具/模式 | 实现 | 何时使用 |
|---|---|---|---|
| 主要认证 | Passkeys/WebAuthn | navigator.credentials.create() | 新应用(2026+),防钓鱼,广泛的平台支持 |
| 密码存储 | bcrypt/Argon2 | bcrypt.hash(password, 12) | 传统认证备用方案(切勿存储明文) |
| 输入验证 | 允许列表正则表达式 | /^[a-zA-Z0-9_]{3,20}$/ | 所有用户输入(预防 SQL、XSS、命令注入) |
| SQL 查询 | 参数化查询 | db.execute(query, [userId]) | 所有数据库操作(预防 SQL 注入) |
| API 认证 | OAuth 2.1 + PKCE | oauth.authorize({ code_challenge }) | 第三方认证,API 访问(弃用隐式流) |
| 令牌认证 | JWT(短期有效) | jwt.sign(payload, secret, { expiresIn: '15m' }) | 无状态 API(始终验证,15-30 分钟有效期) |
| 数据加密 | AES-256-GCM | crypto.createCipheriv('aes-256-gcm') | 静态敏感数据(PII、金融、健康) |
| HTTPS/TLS | TLS 1.3 | 强制 HTTPS 重定向 | 所有生产流量(传输中数据) |
| 访问控制 | RBAC/ABAC | requireRole('admin', 'moderator') | 资源授权(API、管理面板) |
| 速率限制 | express-rate-limit | limiter({ windowMs: 15min, max: 100 }) | 公共 API、认证端点(DoS 预防) |
| 安全要求 | OWASP ASVS | 选择 L1/L2/L3 | 安全要求基线 + 测试范围 |
| 方法 | 使用场景 | 令牌有效期 | 安全级别 | 备注 |
|---|---|---|---|---|
| Passkeys/WebAuthn | 主要认证(2026+) | N/A(加密方式) | 最高 | 防钓鱼,广泛的平台支持 |
| OAuth 2.1 + PKCE | 第三方认证 | 5-15 分钟访问令牌 | 高 | 取代隐式流,强制 PKCE |
| 会话 Cookie | 传统 Web 应用 | 30 分钟 - 4 小时 | 中-高 | HttpOnly、Secure、SameSite=Strict |
| JWT 无状态 | API、微服务 | 15-30 分钟 | 中 | 始终验证签名,短期有效期 |
| API 密钥 | 机器对机器 | 长期有效 | 低-中 | 定期轮换,限定权限范围 |
司法管辖区注意事项(需核实): 认证保证要求因国家、行业和买方而异。优先选择 passkeys/FIDO2;将短信 OTP 仅视为恢复手段/低保证级别,除非能证明其合理性。
---|---|---|--- A01 | 失效的访问控制 | RBAC/ABAC、默认拒绝、CORS 允许列表 | BOLA、BFLA、权限提升 A02 | 安全配置错误 | 加固默认设置、禁用未使用功能、错误处理 | 默认凭据、堆栈跟踪、响应头 A03 | 供应链故障(新增) | SBOM、依赖项扫描、SLSA、代码签名 | 过时依赖项、域名仿冒、被劫持的软件包 A04 | 加密机制失效 | TLS 1.3、AES-256-GCM、密钥轮换、不使用 MD5/SHA1 | 弱密码套件、暴露的密钥、证书验证 A05 | 注入 | 参数化查询、输入验证、输出编码 | SQLi、XSS、命令注入、LDAP 注入 A06 | 不安全的设计 | 威胁建模、安全设计模式、滥用案例 | 设计缺陷、缺失的控制措施、信任边界 A07 | 认证失败 | MFA/passkeys、速率限制、安全的密码存储 | 凭据填充、暴力破解、会话固定 A08 | 完整性故障 | 代码签名、CI/CD 流水线安全、SRI | 未签名的更新、流水线投毒、CDN 篡改 A09 | 日志记录失败 | 结构化 JSON、SIEM 集成、关联 ID | 缺失日志、日志中的 PII、无告警 A10 | 异常条件处理不当(新增) | 故障安全默认值、完整的错误恢复、输入验证 | 错误处理漏洞、故障开放、资源耗尽
Security requirement: [Feature Type]
├─ User Authentication?
│ ├─ Session-based? → Cookie sessions + CSRF tokens
│ ├─ Token-based? → JWT with refresh tokens (references/authentication-authorization.md)
│ └─ Third-party? → OAuth2/OIDC integration
│
├─ User Input?
│ ├─ Database query? → Parameterized queries (NEVER string concatenation)
│ ├─ HTML output? → DOMPurify sanitization + CSP headers
│ ├─ File upload? → Content validation, size limits, virus scanning
│ └─ API parameters? → Allowlist validation (references/input-validation.md)
│
├─ Sensitive Data?
│ ├─ Passwords? → bcrypt/Argon2 (cost factor 12+)
│ ├─ PII/financial? → AES-256-GCM encryption + key rotation
│ ├─ API keys/tokens? → Environment variables + secrets manager
│ └─ In transit? → TLS 1.3 only
│
├─ Access Control?
│ ├─ Simple roles? → RBAC (assets/web-application/template-authorization.md)
│ ├─ Complex rules? → ABAC with policy engine
│ └─ Relationship-based? → ReBAC (owner, collaborator, viewer)
│
└─ API Security?
├─ Public API? → Rate limiting + API keys
├─ CORS needed? → Strict origin allowlist (never *)
└─ Headers? → Helmet.js (CSP, HSTS, X-Frame-Options)
安全投资论证和合规驱动的收入。完整框架:references/security-business-value.md
指示性数据(来源:IBM 2024 年数据泄露成本报告;请刷新获取当年最新数据):https://www.ibm.com/reports/data-breach
| 指标 | 全球平均 | 美国平均 | 影响 |
|---|---|---|---|
| 平均泄露成本 | $4.88M | $9.36M | 预算论证基线 |
| 每条记录成本 | $165 | $194 | 数据分类优先级 |
| 检测时间 | 204 天 | 191 天 | SIEM/监控投资回报率 |
| DevSecOps 采用 | -$1.68M | -34% | 左移论证 |
| 应急响应团队 | -$2.26M | -46% | 最高投资回报率的控制措施 |
| 认证 | 解锁的交易 | 销售影响 |
|---|---|---|
| SOC 2 Type II | $100K+ 企业级 | 通常减少安全问卷阻力 |
| ISO 27001 | $250K+ 欧盟企业 | 优选供应商地位 |
| HIPAA | 医疗保健垂直领域 | 市场准入 |
| FedRAMP | $1M+ 政府项目 | 美国政府采购市场准入 |
Security ROI = (Risk Reduction - Investment) / Investment × 100
Risk Reduction = Breach Probability × Avg Cost × Control Effectiveness
Example: 15% × $4.88M × 46% = $337K/year risk reduction
| 阶段 | 行动 |
|---|---|
| 检测 | 告警触发、用户报告、自动化扫描 |
| 遏制 | 隔离受影响系统、撤销泄露的凭据 |
| 调查 | 收集日志、确定影响范围、识别根本原因 |
| 修复 | 修补漏洞、轮换密钥、更新防御措施 |
| 恢复 | 恢复服务、验证修复、更新监控 |
| 总结 | 事后分析、更新响应手册、分享经验教训 |
| 记录内容 | 格式 | 保留期 |
|---|---|---|
| 认证事件 | 带有关联 ID 的 JSON | 至少 90 天 |
| 授权失败 | 带有用户上下文的 JSON | 至少 90 天 |
| 数据访问(敏感) | 带有资源 ID 的 JSON | 至少 1 年 |
| 安全扫描结果 | SARIF 格式 | 至少 1 年 |
应做:
避免:
| FAIL 不良实践 | PASS 正确方法 | 风险 |
|---|---|---|
query = "SELECT * FROM users WHERE id=" + userId | db.execute("SELECT * FROM users WHERE id=?", [userId]) | SQL 注入 |
| 以明文或 MD5 存储密码 | bcrypt.hash(password, 12) 或 Argon2 | 凭据盗窃 |
res.send(userInput) 无编码 | res.send(DOMPurify.sanitize(userInput)) | XSS |
| 源代码中硬编码 API 密钥 | 环境变量 + 密钥管理器 | 密钥暴露 |
Access-Control-Allow-Origin: * | 明确的源允许列表 | CORS 绕过 |
| JWT 无过期时间 | expiresIn: '15m' + 刷新令牌 | 令牌劫持 |
| 日志中的通用错误消息 | 带有关联 ID 的结构化 JSON | 调试盲区 |
| 短信 OTP 作为主要因素 | Passkeys/WebAuthn 或 TOTP(仅保留短信用于恢复) | 凭据钓鱼 |
注意:AI 系统的安全注意事项。如果不构建 AI 功能,请跳过此部分。
| 威胁 | 缓解措施 |
|---|---|
| 提示注入 | 输入验证、输出过滤、沙箱执行 |
| 数据泄露 | 输出扫描、PII 检测 |
| 模型窃取 | API 速率限制、水印 |
| 越狱 | 宪法 AI、护栏 |
| 工具 | 使用场景 |
|---|---|
| Semgrep | 带 AI 规则的静态分析 |
| Snyk Code | AI 驱动的漏洞检测 |
| GitHub CodeQL | 语义代码分析 |
对于使用 Entity Framework Core 的 C#/.NET 加密/金融科技服务,请参阅:
关键规则摘要:
decimal,切勿使用 double/float重要提示:当用户询问关于应用程序安全的推荐问题时,您必须在使用 WebSearch 检查当前趋势后再回答。如果 WebSearch 不可用,请使用 data/sources.json + 网页浏览,并说明您核实了哪些内容以及假设了哪些内容。
"application security best practices 2026""OWASP Top 10 2025 2026""[authentication/authorization] trends 2026""supply chain security 2026"搜索后,提供:
在构建任何涉及存储、上传或用户生成内容的功能之前:
在没有预先定义安全约束的情况下构建存储/上传功能,会导致事后加固成本更高且更容易出错。
每周安装次数
97
仓库
GitHub 星标数
49
首次出现
2026 年 1 月 23 日
安全审计
安装于
codex79
gemini-cli78
opencode78
cursor77
github-copilot73
amp65
Production-grade security patterns for building secure applications in Jan 2026. Covers OWASP Top 10:2025 (stable) https://owasp.org/Top10/2025/ plus OWASP API Security Top 10 (2023) https://owasp.org/API-Security/ and secure SDLC baselines (NIST SSDF) https://csrc.nist.gov/publications/detail/sp/800-218/final.
Activate this skill when:
| Security Task | Tool/Pattern | Implementation | When to Use |
|---|---|---|---|
| Primary Auth | Passkeys/WebAuthn | navigator.credentials.create() | New apps (2026+), phishing-resistant, broad platform support |
| Password Storage | bcrypt/Argon2 | bcrypt.hash(password, 12) | Legacy auth fallback (never store plaintext) |
| Input Validation | Allowlist regex | /^[a-zA-Z0-9_]{3,20}$/ | All user input (SQL, XSS, command injection prevention) |
| SQL Queries | Parameterized queries | db.execute(query, [userId]) |
| Method | Use Case | Token Lifetime | Security Level | Notes |
|---|---|---|---|---|
| Passkeys/WebAuthn | Primary auth (2026+) | N/A (cryptographic) | Highest | Phishing-resistant, broad platform support |
| OAuth 2.1 + PKCE | Third-party auth | 5-15 min access | High | Replaces implicit flow, mandatory PKCE |
| Session cookies | Traditional web apps | 30 min - 4 hrs | Medium-High | HttpOnly, Secure, SameSite=Strict |
| JWT stateless | APIs, microservices | 15-30 min | Medium | Always validate signature, short expiry |
| API keys | Machine-to-machine | Long-lived | Low-Medium | Rotate regularly, scope permissions |
Jurisdiction notes (verify): Authentication assurance requirements vary by country, industry, and buyer. Prefer passkeys/FIDO2; treat SMS OTP as recovery-only/low assurance unless you can justify it.
---|---|---|---
A01 | Broken Access Control | RBAC/ABAC, deny by default, CORS allowlist | BOLA, BFLA, privilege escalation
A02 | Security Misconfiguration | Harden defaults, disable unused features, error handling | Default creds, stack traces, headers
A03 | Supply Chain Failures (NEW) | SBOM, dependency scanning, SLSA, code signing | Outdated deps, typosquatting, compromised packages
A04 | Cryptographic Failures | TLS 1.3, AES-256-GCM, key rotation, no MD5/SHA1 | Weak ciphers, exposed secrets, cert validation
A05 | Injection | Parameterized queries, input validation, output encoding | SQLi, XSS, command injection, LDAP injection
A06 | Insecure Design | Threat modeling, secure design patterns, abuse cases | Design flaws, missing controls, trust boundaries
A07 | Authentication Failures | MFA/passkeys, rate limiting, secure password storage | Credential stuffing, brute force, session fixation
A08 | Integrity Failures | Code signing, CI/CD pipeline security, SRI | Unsigned updates, pipeline poisoning, CDN tampering
A09 | Logging Failures | Structured JSON, SIEM integration, correlation IDs | Missing logs, PII in logs, no alerting
A10 | Exceptional Conditions (NEW) | Fail-safe defaults, complete error recovery, input validation | Error handling gaps, fail-open, resource exhaustion
Security requirement: [Feature Type]
├─ User Authentication?
│ ├─ Session-based? → Cookie sessions + CSRF tokens
│ ├─ Token-based? → JWT with refresh tokens (references/authentication-authorization.md)
│ └─ Third-party? → OAuth2/OIDC integration
│
├─ User Input?
│ ├─ Database query? → Parameterized queries (NEVER string concatenation)
│ ├─ HTML output? → DOMPurify sanitization + CSP headers
│ ├─ File upload? → Content validation, size limits, virus scanning
│ └─ API parameters? → Allowlist validation (references/input-validation.md)
│
├─ Sensitive Data?
│ ├─ Passwords? → bcrypt/Argon2 (cost factor 12+)
│ ├─ PII/financial? → AES-256-GCM encryption + key rotation
│ ├─ API keys/tokens? → Environment variables + secrets manager
│ └─ In transit? → TLS 1.3 only
│
├─ Access Control?
│ ├─ Simple roles? → RBAC (assets/web-application/template-authorization.md)
│ ├─ Complex rules? → ABAC with policy engine
│ └─ Relationship-based? → ReBAC (owner, collaborator, viewer)
│
└─ API Security?
├─ Public API? → Rate limiting + API keys
├─ CORS needed? → Strict origin allowlist (never *)
└─ Headers? → Helmet.js (CSP, HSTS, X-Frame-Options)
Security investment justification and compliance-driven revenue. Full framework: references/security-business-value.md
Indicative figures (source: IBM Cost of a Data Breach 2024; refresh for current year): https://www.ibm.com/reports/data-breach
| Metric | Global Avg | US Avg | Impact |
|---|---|---|---|
| Avg breach cost | $4.88M | $9.36M | Budget justification baseline |
| Cost per record | $165 | $194 | Data classification priority |
| Detection time | 204 days | 191 days | SIEM/monitoring ROI |
| DevSecOps adoption | -$1.68M | -34% | Shift-left justification |
| IR team | -$2.26M | -46% | Highest ROI control |
| Certification | Deals Unlocked | Sales Impact |
|---|---|---|
| SOC 2 Type II | $100K+ enterprise | Typically reduces security questionnaire friction |
| ISO 27001 | $250K+ EU enterprise | Preferred vendor status |
| HIPAA | Healthcare vertical | Market access |
| FedRAMP | $1M+ government | US gov market entry |
Security ROI = (Risk Reduction - Investment) / Investment × 100
Risk Reduction = Breach Probability × Avg Cost × Control Effectiveness
Example: 15% × $4.88M × 46% = $337K/year risk reduction
| Phase | Actions |
|---|---|
| Detect | Alert fires, user report, automated scan |
| Contain | Isolate affected systems, revoke compromised credentials |
| Investigate | Collect logs, determine scope, identify root cause |
| Remediate | Patch vulnerability, rotate secrets, update defenses |
| Recover | Restore services, verify fixes, update monitoring |
| Learn | Post-mortem, update playbooks, share lessons |
| What to Log | Format | Retention |
|---|---|---|
| Authentication events | JSON with correlation ID | 90 days minimum |
| Authorization failures | JSON with user context | 90 days minimum |
| Data access (sensitive) | JSON with resource ID | 1 year minimum |
| Security scan results | SARIF format | 1 year minimum |
Do:
Avoid:
| FAIL Bad Practice | PASS Correct Approach | Risk |
|---|---|---|
query = "SELECT * FROM users WHERE id=" + userId | db.execute("SELECT * FROM users WHERE id=?", [userId]) | SQL injection |
| Storing passwords in plaintext or MD5 | bcrypt.hash(password, 12) or Argon2 | Credential theft |
res.send(userInput) without encoding | res.send(DOMPurify.sanitize(userInput)) | XSS |
| Hardcoded API keys in source code | Environment variables + secrets manager |
Note : Security considerations for AI systems. Skip if not building AI features.
| Threat | Mitigation |
|---|---|
| Prompt injection | Input validation, output filtering, sandboxed execution |
| Data exfiltration | Output scanning, PII detection |
| Model theft | API rate limiting, watermarking |
| Jailbreaking | Constitutional AI, guardrails |
| Tool | Use Case |
|---|---|
| Semgrep | Static analysis with AI rules |
| Snyk Code | AI-powered vulnerability detection |
| GitHub CodeQL | Semantic code analysis |
For C#/.NET crypto/fintech services using Entity Framework Core, see:
Key rules summary:
decimal for financial values, never double/floatIMPORTANT : When users ask recommendation questions about application security, you MUST use WebSearch to check current trends before answering. If WebSearch is unavailable, use data/sources.json + web browsing and state what you verified vs assumed.
"application security best practices 2026""OWASP Top 10 2025 2026""[authentication/authorization] trends 2026""supply chain security 2026"After searching, provide:
Before building any feature that involves storage, uploads, or user-generated content:
Building storage/upload features without upfront security constraints leads to retroactive hardening that is more expensive and error-prone.
Weekly Installs
97
Repository
GitHub Stars
49
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex79
gemini-cli78
opencode78
cursor77
github-copilot73
amp65
Azure PostgreSQL 无密码身份验证配置指南:Entra ID 迁移与访问管理
34,800 周安装
深度研究工具:使用Actionbook自动化分析主题/论文并生成HTML报告
144 周安装
GitHub Actions专家指南:CI/CD工作流优化、安全实践与自定义开发
145 周安装
Java Gradle 构建工具指南:Kotlin DSL 配置、依赖管理与性能优化
155 周安装
Z-Library 书籍自动下载并上传到 NotebookLM 工具 - 实现 AI 零幻觉对话式阅读
156 周安装
LinkedIn帖子生成器 - 基于个人风格和会议记录自动生成专业LinkedIn内容
158 周安装
NestJS BullMQ 队列架构师指南:构建弹性媒体处理系统 | 高级队列设计
158 周安装
| All database operations (prevent SQL injection) |
| API Authentication | OAuth 2.1 + PKCE | oauth.authorize({ code_challenge }) | Third-party auth, API access (deprecates implicit flow) |
| Token Auth | JWT (short-lived) | jwt.sign(payload, secret, { expiresIn: '15m' }) | Stateless APIs (always validate, 15-30 min expiry) |
| Data Encryption | AES-256-GCM | crypto.createCipheriv('aes-256-gcm') | Sensitive data at rest (PII, financial, health) |
| HTTPS/TLS | TLS 1.3 | Force HTTPS redirects | All production traffic (data in transit) |
| Access Control | RBAC/ABAC | requireRole('admin', 'moderator') | Resource authorization (APIs, admin panels) |
| Rate Limiting | express-rate-limit | limiter({ windowMs: 15min, max: 100 }) | Public APIs, auth endpoints (DoS prevention) |
| Security Requirements | OWASP ASVS | Choose L1/L2/L3 | Security requirements baseline + test scope |
| Secret exposure |
Access-Control-Allow-Origin: * | Explicit origin allowlist | CORS bypass |
| JWT with no expiration | expiresIn: '15m' + refresh tokens | Token hijacking |
| Generic error messages to logs | Structured JSON with correlation IDs | Debugging blind spots |
| SMS OTP as primary factor | Passkeys/WebAuthn or TOTP (keep SMS for recovery-only) | Credential phishing |