senior-security by alirezarezvani/claude-skills
npx skills add https://github.com/alirezarezvani/claude-skills --skill senior-security用于威胁建模、漏洞分析、安全架构设计和渗透测试的安全工程工具。
使用 STRIDE 方法论识别和分析安全威胁。
| 类别 | 安全属性 | 缓解重点 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| Spoofing | Authentication | MFA, certificates, strong auth |
| Tampering | Integrity | Signing, checksums, validation |
| Repudiation | Non-repudiation | Audit logs, digital signatures |
| Information Disclosure | Confidentiality | Encryption, access controls |
| Denial of Service | Availability | Rate limiting, redundancy |
| Elevation of Privilege | Authorization | RBAC, least privilege |
| DFD 元素 | S | T | R | I | D | E |
|---|---|---|---|---|---|---|
| External Entity | X | X | ||||
| Process | X | X | X | X | X | X |
| Data Store | X | X | X | X | ||
| Data Flow | X | X | X |
使用纵深防御原则设计安全系统。
Layer 1: PERIMETER
WAF, DDoS mitigation, DNS filtering, rate limiting
Layer 2: NETWORK
Segmentation, IDS/IPS, network monitoring, VPN, mTLS
Layer 3: HOST
Endpoint protection, OS hardening, patching, logging
Layer 4: APPLICATION
Input validation, authentication, secure coding, SAST
Layer 5: DATA
Encryption at rest/transit, access controls, DLP, backup
| 使用场景 | 推荐模式 |
|---|---|
| Web 应用 | OAuth 2.0 + PKCE with OIDC |
| API 身份验证 | JWT with short expiration + refresh tokens |
| 服务间通信 | mTLS with certificate rotation |
| CLI/自动化 | API keys with IP allowlisting |
| 高安全性 | FIDO2/WebAuthn hardware keys |
识别并修复应用中的安全漏洞。
有关 OWASP Top 10 漏洞描述和测试指南,请参考 owasp.org/Top10。
| 影响 \ 可利用性 | 容易 | 中等 | 困难 |
|---|---|---|---|
| 严重 | 严重 | 严重 | 高 |
| 高 | 严重 | 高 | 中 |
| 中 | 高 | 中 | 低 |
| 低 | 中 | 低 | 低 |
在部署前审查代码中的安全漏洞。
| 类别 | 检查项 | 风险 |
|---|---|---|
| 输入验证 | 所有用户输入均已验证和清理 | 注入 |
| 输出编码 | 应用了上下文相关的编码 | XSS |
| 身份验证 | 密码使用 Argon2/bcrypt 哈希 | 凭据窃取 |
| 会话 | 设置了安全的 Cookie 标志 (HttpOnly, Secure, SameSite) | 会话劫持 |
| 授权 | 所有端点都有服务器端权限检查 | 权限提升 |
| SQL | 仅使用参数化查询 | SQL 注入 |
| 文件访问 | 拒绝路径遍历序列 | 路径遍历 |
| 密钥 | 没有硬编码的凭据或密钥 | 信息泄露 |
| 依赖项 | 已知易受攻击的包已更新 | 供应链 |
| 日志记录 | 敏感数据未记录 | 信息泄露 |
| 模式 | 问题 | 安全替代方案 |
|---|---|---|
| SQL 字符串格式化 | SQL 注入 | 使用带占位符的参数化查询 |
| Shell 命令构建 | 命令注入 | 使用带参数列表的 subprocess,不使用 shell |
| 路径拼接 | 路径遍历 | 验证并规范化路径 |
| MD5/SHA1 用于密码 | 弱哈希 | 使用 Argon2id 或 bcrypt |
| Math.random 用于令牌 | 可预测值 | 使用 crypto.getRandomValues |
SQL 注入 — 不安全 vs. 安全 (Python):
# ❌ 不安全:字符串格式化允许 SQL 注入
query = f"SELECT * FROM users WHERE username = '{username}'"
cursor.execute(query)
# ✅ 安全:参数化查询 — 用户输入永远不会被解释为 SQL
query = "SELECT * FROM users WHERE username = %s"
cursor.execute(query, (username,))
使用 Argon2id 进行密码哈希 (Python):
from argon2 import PasswordHasher
ph = PasswordHasher() # 使用安全默认值 (time_cost, memory_cost)
# 注册时
hashed = ph.hash(plain_password)
# 登录时 — 失败时抛出 argon2.exceptions.VerifyMismatchError
ph.verify(hashed, plain_password)
密钥扫描 — 核心模式匹配 (Python):
import re, pathlib
SECRET_PATTERNS = {
"aws_access_key": re.compile(r"AKIA[0-9A-Z]{16}"),
"github_token": re.compile(r"ghp_[A-Za-z0-9]{36}"),
"private_key": re.compile(r"-----BEGIN (RSA |EC )?PRIVATE KEY-----"),
"generic_secret": re.compile(r'(?i)(password|secret|api_key)\s*=\s*["\']?\S{8,}'),
}
def scan_file(path: pathlib.Path) -> list[dict]:
findings = []
for lineno, line in enumerate(path.read_text(errors="replace").splitlines(), 1):
for name, pattern in SECRET_PATTERNS.items():
if pattern.search(line):
findings.append({"file": str(path), "line": lineno, "type": name})
return findings
响应并遏制安全事件。
| 等级 | 响应时间 | 上报对象 |
|---|---|---|
| P1 - 严重(活跃入侵/数据外泄) | 立即 | CISO, 法务, 高管 |
| P2 - 高(已确认,已遏制) | 1 小时 | 安全负责人, IT 总监 |
| P3 - 中(潜在,调查中) | 4 小时 | 安全团队 |
| P4 - 低(可疑,影响小) | 24 小时 | 值班工程师 |
| 阶段 | 行动 |
|---|---|
| 识别 | 验证告警,评估范围,确定严重性 |
| 遏制 | 隔离系统,保存证据,阻止访问 |
| 根除 | 移除威胁,修补漏洞,重置凭据 |
| 恢复 | 恢复服务,验证完整性,加强监控 |
| 经验教训 | 记录时间线,识别差距,更新流程 |
| 类别 | 工具 |
|---|---|
| SAST | Semgrep, CodeQL, Bandit (Python), ESLint security plugins |
| DAST | OWASP ZAP, Burp Suite, Nikto |
| 依赖项扫描 | Snyk, Dependabot, npm audit, pip-audit |
| 密钥检测 | GitLeaks, TruffleHog, detect-secrets |
| 容器安全 | Trivy, Clair, Anchore |
| 基础设施 | Checkov, tfsec, ScoutSuite |
| 网络 | Wireshark, Nmap, Masscan |
| 渗透测试 | Metasploit, sqlmap, Burp Suite Pro |
| 使用场景 | 算法 | 密钥大小 |
|---|---|---|
| 对称加密 | AES-256-GCM | 256 bits |
| 密码哈希 | Argon2id | N/A (使用默认值) |
| 消息认证 | HMAC-SHA256 | 256 bits |
| 数字签名 | Ed25519 | 256 bits |
| 密钥交换 | X25519 | 256 bits |
| TLS | TLS 1.3 | N/A |
| 脚本 | 用途 |
|---|---|
| threat_modeler.py | 带 DREAD 风险评分的 STRIDE 威胁分析;JSON 和文本输出;交互式引导模式 |
| secret_scanner.py | 检测 20+ 种模式的硬编码密钥和凭据;支持 CI/CD 集成 |
关于用法,请参见安全代码审查工作流中的内联代码示例,并直接查看脚本源文件。
| 文档 | 内容 |
|---|---|
| security-architecture-patterns.md | 零信任,纵深防御,身份验证模式,API 安全 |
| threat-modeling-guide.md | STRIDE 方法论,攻击树,DREAD 评分,DFD 创建 |
| cryptography-implementation.md | AES-GCM, RSA, Ed25519, 密码哈希,密钥管理 |
| Header | 推荐值 |
|---|---|
| Content-Security-Policy | default-src self; script-src self |
| X-Frame-Options | DENY |
| X-Content-Type-Options | nosniff |
| Strict-Transport-Security | max-age=31536000; includeSubDomains |
| Referrer-Policy | strict-origin-when-cross-origin |
| Permissions-Policy | geolocation=(), microphone=(), camera=() |
关于合规框架要求 (OWASP ASVS, CIS Benchmarks, NIST CSF, PCI-DSS, HIPAA, SOC 2),请参考各自的官方文档。
| 技能 | 集成点 |
|---|---|
| senior-devops | CI/CD 安全,基础设施加固 |
| senior-secops | 安全监控,事件响应 |
| senior-backend | 安全 API 开发 |
| senior-architect | 安全架构决策 |
每周安装量
200
代码仓库
GitHub Stars
6.5K
首次出现
Jan 20, 2026
安全审计
安装于
claude-code170
opencode153
gemini-cli149
codex139
cursor123
github-copilot122
Security engineering tools for threat modeling, vulnerability analysis, secure architecture design, and penetration testing.
Identify and analyze security threats using STRIDE methodology.
| Category | Security Property | Mitigation Focus |
|---|---|---|
| Spoofing | Authentication | MFA, certificates, strong auth |
| Tampering | Integrity | Signing, checksums, validation |
| Repudiation | Non-repudiation | Audit logs, digital signatures |
| Information Disclosure | Confidentiality | Encryption, access controls |
| Denial of Service | Availability | Rate limiting, redundancy |
| Elevation of Privilege | Authorization | RBAC, least privilege |
| DFD Element | S | T | R | I | D | E |
|---|---|---|---|---|---|---|
| External Entity | X | X | ||||
| Process | X | X | X | X | X | X |
| Data Store | X | X | X | X | ||
| Data Flow | X | X | X |
See: references/threat-modeling-guide.md
Design secure systems using defense-in-depth principles.
Layer 1: PERIMETER
WAF, DDoS mitigation, DNS filtering, rate limiting
Layer 2: NETWORK
Segmentation, IDS/IPS, network monitoring, VPN, mTLS
Layer 3: HOST
Endpoint protection, OS hardening, patching, logging
Layer 4: APPLICATION
Input validation, authentication, secure coding, SAST
Layer 5: DATA
Encryption at rest/transit, access controls, DLP, backup
| Use Case | Recommended Pattern |
|---|---|
| Web application | OAuth 2.0 + PKCE with OIDC |
| API authentication | JWT with short expiration + refresh tokens |
| Service-to-service | mTLS with certificate rotation |
| CLI/Automation | API keys with IP allowlisting |
| High security | FIDO2/WebAuthn hardware keys |
See: references/security-architecture-patterns.md
Identify and remediate security vulnerabilities in applications.
For OWASP Top 10 vulnerability descriptions and testing guidance, refer to owasp.org/Top10.
| Impact \ Exploitability | Easy | Moderate | Difficult |
|---|---|---|---|
| Critical | Critical | Critical | High |
| High | Critical | High | Medium |
| Medium | High | Medium | Low |
| Low | Medium | Low | Low |
Review code for security vulnerabilities before deployment.
| Category | Check | Risk |
|---|---|---|
| Input Validation | All user input validated and sanitized | Injection |
| Output Encoding | Context-appropriate encoding applied | XSS |
| Authentication | Passwords hashed with Argon2/bcrypt | Credential theft |
| Session | Secure cookie flags set (HttpOnly, Secure, SameSite) | Session hijacking |
| Authorization | Server-side permission checks on all endpoints | Privilege escalation |
| SQL | Parameterized queries used exclusively | SQL injection |
| File Access | Path traversal sequences rejected | Path traversal |
| Secrets | No hardcoded credentials or keys | Information disclosure |
| Dependencies | Known vulnerable packages updated |
| Pattern | Issue | Secure Alternative |
|---|---|---|
| SQL string formatting | SQL injection | Use parameterized queries with placeholders |
| Shell command building | Command injection | Use subprocess with argument lists, no shell |
| Path concatenation | Path traversal | Validate and canonicalize paths |
| MD5/SHA1 for passwords | Weak hashing | Use Argon2id or bcrypt |
| Math.random for tokens | Predictable values | Use crypto.getRandomValues |
SQL Injection — insecure vs. secure (Python):
# ❌ Insecure: string formatting allows SQL injection
query = f"SELECT * FROM users WHERE username = '{username}'"
cursor.execute(query)
# ✅ Secure: parameterized query — user input never interpreted as SQL
query = "SELECT * FROM users WHERE username = %s"
cursor.execute(query, (username,))
Password Hashing with Argon2id (Python):
from argon2 import PasswordHasher
ph = PasswordHasher() # uses secure defaults (time_cost, memory_cost)
# On registration
hashed = ph.hash(plain_password)
# On login — raises argon2.exceptions.VerifyMismatchError on failure
ph.verify(hashed, plain_password)
Secret Scanning — core pattern matching (Python):
import re, pathlib
SECRET_PATTERNS = {
"aws_access_key": re.compile(r"AKIA[0-9A-Z]{16}"),
"github_token": re.compile(r"ghp_[A-Za-z0-9]{36}"),
"private_key": re.compile(r"-----BEGIN (RSA |EC )?PRIVATE KEY-----"),
"generic_secret": re.compile(r'(?i)(password|secret|api_key)\s*=\s*["\']?\S{8,}'),
}
def scan_file(path: pathlib.Path) -> list[dict]:
findings = []
for lineno, line in enumerate(path.read_text(errors="replace").splitlines(), 1):
for name, pattern in SECRET_PATTERNS.items():
if pattern.search(line):
findings.append({"file": str(path), "line": lineno, "type": name})
return findings
Respond to and contain security incidents.
| Level | Response Time | Escalation |
|---|---|---|
| P1 - Critical (active breach/exfiltration) | Immediate | CISO, Legal, Executive |
| P2 - High (confirmed, contained) | 1 hour | Security Lead, IT Director |
| P3 - Medium (potential, under investigation) | 4 hours | Security Team |
| P4 - Low (suspicious, low impact) | 24 hours | On-call engineer |
| Phase | Actions |
|---|---|
| Identification | Validate alert, assess scope, determine severity |
| Containment | Isolate systems, preserve evidence, block access |
| Eradication | Remove threat, patch vulnerabilities, reset credentials |
| Recovery | Restore services, verify integrity, increase monitoring |
| Lessons Learned | Document timeline, identify gaps, update procedures |
| Category | Tools |
|---|---|
| SAST | Semgrep, CodeQL, Bandit (Python), ESLint security plugins |
| DAST | OWASP ZAP, Burp Suite, Nikto |
| Dependency Scanning | Snyk, Dependabot, npm audit, pip-audit |
| Secret Detection | GitLeaks, TruffleHog, detect-secrets |
| Container Security | Trivy, Clair, Anchore |
| Infrastructure | Checkov, tfsec, ScoutSuite |
| Network | Wireshark, Nmap, Masscan |
| Penetration | Metasploit, sqlmap, Burp Suite Pro |
| Use Case | Algorithm | Key Size |
|---|---|---|
| Symmetric encryption | AES-256-GCM | 256 bits |
| Password hashing | Argon2id | N/A (use defaults) |
| Message authentication | HMAC-SHA256 | 256 bits |
| Digital signatures | Ed25519 | 256 bits |
| Key exchange | X25519 | 256 bits |
| TLS | TLS 1.3 | N/A |
See: references/cryptography-implementation.md
| Script | Purpose |
|---|---|
| threat_modeler.py | STRIDE threat analysis with DREAD risk scoring; JSON and text output; interactive guided mode |
| secret_scanner.py | Detect hardcoded secrets and credentials across 20+ patterns; CI/CD integration ready |
For usage, see the inline code examples in Secure Code Review Workflow and the script source files directly.
| Document | Content |
|---|---|
| security-architecture-patterns.md | Zero Trust, defense-in-depth, authentication patterns, API security |
| threat-modeling-guide.md | STRIDE methodology, attack trees, DREAD scoring, DFD creation |
| cryptography-implementation.md | AES-GCM, RSA, Ed25519, password hashing, key management |
| Header | Recommended Value |
|---|---|
| Content-Security-Policy | default-src self; script-src self |
| X-Frame-Options | DENY |
| X-Content-Type-Options | nosniff |
| Strict-Transport-Security | max-age=31536000; includeSubDomains |
| Referrer-Policy | strict-origin-when-cross-origin |
| Permissions-Policy | geolocation=(), microphone=(), camera=() |
For compliance framework requirements (OWASP ASVS, CIS Benchmarks, NIST CSF, PCI-DSS, HIPAA, SOC 2), refer to the respective official documentation.
| Skill | Integration Point |
|---|---|
| senior-devops | CI/CD security, infrastructure hardening |
| senior-secops | Security monitoring, incident response |
| senior-backend | Secure API development |
| senior-architect | Security architecture decisions |
Weekly Installs
200
Repository
GitHub Stars
6.5K
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykPass
Installed on
claude-code170
opencode153
gemini-cli149
codex139
cursor123
github-copilot122
Azure PostgreSQL 无密码身份验证配置指南:Entra ID 迁移与访问管理
34,800 周安装
| Supply chain |
| Logging | Sensitive data not logged | Information disclosure |