跳到正文
FunCoding

security-hardening

Harden an application or service against common attack vectors. Use when asked to improve security posture, secure an API, harden a server, or prepare for a security review.

Star
836
分类
安全
最近提交
2026年7月17日

ch09_agent_skills/skills/security-hardening/SKILL.md

在 GitHub 上查看

Overview

Security hardening is not about chasing perfect — it's about raising the cost of attack above the attacker's budget. Work systematically through the layers.

Process

Layer 1: Authentication and Authorization

  1. Verify all endpoints require authentication. Check for unprotected routes using:
    grep -rn "route\|@app\.\|router\." src/ | grep -v "login\|health\|docs"
    
  2. Check that authorization is enforced at the data layer, not just the route layer. A user who can reach /orders should only see their orders.
  3. Confirm tokens expire. JWTs must have exp claims. Sessions must have server-side expiry.

Layer 2: Input Validation

  1. Every user-supplied value that touches a database must use parameterized queries. Grep for f-string SQL:
    grep -rn "f\"SELECT\|f'SELECT\|format.*SELECT" src/
    
  2. Every file path from user input must be validated against an allowlist or a sandboxed directory. Check for os.path.join(base, user_input) without os.path.abspath + startswith guard.

Layer 3: Secrets and Configuration

  1. Scan for hardcoded secrets:
    grep -rn "password\s*=\s*[\"'][^\"']\|api_key\s*=\s*[\"'][^\"']" src/
    
  2. Confirm all secrets come from environment variables or a secrets manager, not from config files committed to version control.
  3. Check .gitignore includes .env, *.key, *.pem.

Layer 4: Dependencies and Infrastructure

  1. Run the dependency-audit skill to check for vulnerable packages.
  2. Check HTTP security headers are set (for web services):
    • Content-Security-Policy
    • X-Frame-Options: DENY
    • Strict-Transport-Security
    • X-Content-Type-Options: nosniff

Layer 5: Output

  1. Write findings as a prioritized list: Critical → High → Medium → Low. For each finding: what it is, where it is (file:line), how to fix it.

Rationalizations

ExcuseRebuttal
"This is an internal service, it doesn't need hardening"Internal services are the primary target of lateral movement attacks after initial breach.
"We'll harden it before the public launch"Security debt compounds. Fix it before it goes anywhere.
"The framework handles security"Frameworks handle some things. You must handle the application-level concerns.

Verification

  • All four layers were checked (not just the ones that seemed relevant)
  • No hardcoded secrets found in source or git history
  • Every critical and high finding has a specific remediation
  • A finding was produced for each layer — even if it's "no issues found"

相似的 Skill

agent-security-hardening

AFaffaan-m/ECC315k近 7 天新增 4,381 个 star

精选

ponytail-audit

审计整个代码库,找出 bug、安全漏洞和性能瓶颈,获得按重要性排序的通俗报告。

DIDietrichGebert/ponytail203k近 7 天新增 4,904 个 star

gstack

GAgarrytan/gstack143k近 7 天新增 598 个 star

精选

security-and-hardening

按 OWASP Top 10 检查输入处理、登录和依赖,加固代码。

ADaddyosmani/agent-skills122k近 7 天新增 1,667 个 star

doubt-driven-development

ADaddyosmani/agent-skills122k近 7 天新增 1,667 个 star

ruview-rvagent

RUruvnet/RuView106k近 7 天新增 739 个 star