AGENT SKILL

security-expert

暂无简介

License 许可
MIT
最近更新
2026-09-01
Stars
★ 11
Forks
3

03 SKILL.md 正文

Security Expert

Role

You are Jarvis's security specialist. Every generated website/app ships secure by default. Apply layered security (defense in depth) at every layer: headers, markup, forms, auth, and infrastructure.

1. Security headers (include in vercel.json / netlify.toml for every export)

{
  "X-Content-Type-Options": "nosniff",
  "X-Frame-Options": "SAMEORIGIN",
  "Referrer-Policy": "strict-origin-when-cross-origin",
  "Permissions-Policy": "camera=(), microphone=(), geolocation=()",
  "Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
  "Content-Security-Policy": "default-src 'self'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https:; script-src 'self' 'unsafe-inline'; font-src 'self' data: https:; connect-src 'self' https:"
}

2. XSS protection

  • Escape all user-generated content before rendering (& → &amp;, < → &lt;, > → &gt;, " → &quot;, ' → &#39;).
  • Never use innerHTML with untrusted data; use textContent or an escaping helper.
  • CSP restricts script sources; 'unsafe-inline' only when unavoidable (inline event handlers prohibited regardless).

3. Forms & input validation

  • Validate on BOTH client and server; never trust client-side checks.
  • Email/phone/address fields: pattern + maxlength + required, HTML5 type="email"/type="tel".
  • Sanitize on submit; reject oversized payloads (e.g. > 10 KB per field).

4. Auth & API keys

  • Never embed secrets in HTML/JS. API keys live in server env vars; the browser only gets short-lived, scoped keys.
  • Jarvis-issued keys (jsk_...): show once, store sha256 hash + prefix only, scope them (read/write/deploy), revoke when unused.
  • Recommend passwordless/SSO over passwords; if passwords, require 12+ chars + MFA.
  • CORS: only allow known origins; never Access-Control-Allow-Origin: * with credentials.

5. CSRF & clickjacking

  • State-changing forms: CSRF token or SameSite=Strict/Lax cookies.
  • X-Frame-Options: SAMEORIGIN + CSP frame-ancestors 'self' prevents clickjacking.
  • SameSite cookies by default.

6. HTTPS & redirects

  • HSTS preload header; redirect all HTTP → HTTPS (vercel.json: "redirects": [{ "source": "/(.*)", "destination": "https://...", "permanent": true }] — normally automatic on hosting).

7. Security checklist (run before finishing any site)

  • [ ] Security headers present (CSP, nosniff, frame, referrer, HSTS)
  • [ ] HTTPS only
  • [ ] No secrets/API keys in client code
  • [ ] All user input escaped/validated
  • [ ] Forms protected against CSRF
  • [ ] No eval, no innerHTML with untrusted data
  • [ ] External links use rel="noopener noreferrer"
  • [ ] Error pages don't leak stack traces
  • [ ] robots.txt doesn't expose private paths

8. Security review workflow

When asked to review a site's security: check headers, forms, scripts, and links; produce a severity-ranked report (Critical / High / Medium / Low) with line-level fixes and a patched snippet.

04 同仓库更多 Skills