viper-headers-csp-cors
Skill22 starsChanged 15 days agoMITView on GitHub
HTTP Security Headers, Content-Security-Policy (CSP) & CORS Configuration Auditor (modeled on Mozilla Observatory & OWASP Secure Headers). Reviews origin reflection and framing defenses.
In this repository72 other files it gives its agents.
- llms.txtllms.txt
- viper-agent-skill-supplychainSkill
- viper-ai-llm-guardrailsSkill
- viper-api-gateway-apigee-kongSkill
- viper-auth-oauth-jwtSkill
- viper-aws-iam-cloud-auditSkill
- viper-bola-idorSkill
- viper-browser-extension-mv3Skill
- viper-browseros-agentSkill
- viper-cicd-hardeningSkill
- viperclawSkill
- viper-container-k8s-auditSkill
- viper-crypto-tls-auditSkill
- viper-csrf-samesite-auditSkill
- viper-dependency-sbomSkill
- viper-deserialization-parserSkill
- viper-diff-pr-reviewSkill
- viper-dns-email-domainSkill
- viper-electron-tauri-desktopSkill
- viper-fastapi-django-flaskSkill
- viper-file-upload-storageSkill
- viper-gcp-azure-cloud-auditSkill
- viper-github-repo-governanceSkill
- viper-go-service-auditSkill
- viper-graphql-wsSkill
- viper-grpc-protobuf-auditSkill
- viper-iac-terraform-auditSkill
- viper-incident-forensics-triageSkill
- viper-injection-oracleSkill
- viper-java-spring-auditSkill
- viper-js-harvesterSkill
- viper-kafka-rabbitmq-queueSkill
- viper-linux-systemd-hostSkill
- viper-logging-pii-complianceSkill
- viper-mcp-server-auditSkill
- viper-mobile-api-configSkill
- viper-multitenant-isolationSkill
- viper-nextjs-react-rscSkill
- viper-nginx-envoy-gatewaySkill
- viper-nodejs-express-nestjsSkill
- viper-oauth-oidc-complianceSkill
- viper-openapi-rest-schemaSkill
- viper-orchestratorSkill
- viper-payment-stripe-pciSkill
- viper-php-laravel-wordpressSkill
- viper-postgres-redis-mongoSkill
- viper-privacy-gdpr-hipaaSkill
- viper-proof-judgeSkill
- viper-proxy-fingerprintSkill
- viper-proxy-parser-alignmentSkill
- viper-race-logicSkill
- viper-rag-vector-auditSkill
- viper-rate-limit-dos-resilienceSkill
- viper-remediation-patch-verifierSkill
- viper-ruby-rails-auditSkill
- viper-rust-memory-unsafeSkill
- viper-saml-sso-enterpriseSkill
- viper-sbom-slsa-provenanceSkill
- viper-secrets-auditSkill
- viper-semgrep-rule-authorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Run the following discovery commands across the target repository before manual code review:
- Distinctive: line 62
Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.
- Distinctive: line 98
Write a Positive Unit Test confirming authorized, schema-valid requests succeed.
- Distinctive: line 99
Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
HTTP Security Headers, CSP & CORS Configuration Auditor (viper-headers-csp-cors)
1. Executive Scope, Standards & CWE/OWASP Mapping
- Frameworks & Standards: OWASP Secure Headers Project, W3C Content Security Policy Level 3, Fetch Standard (CORS), CWE-942, CWE-1021
- Primary CWE Mapping: CWE-942 (Overly Permissive Cross-domain Whitelist / CORS), CWE-1021 (Improper Restriction of Rendered UI Layers / Clickjacking), CWE-693
- ViperClaw MCP Tools:
viper_fingerprint_traffic,viper_verify_and_report - ViperClaw CLI Command:
viperclaw fingerprint ./traffic.har --output headers_audit.json
2. Threat Model & Root-Cause Architecture
flowchart LR
Origin["Browser Cross-Origin Request"] --> CORS["Strict Origin Allowlist Match"] --> CSP["Nonce/Hash CSP + frame-ancestors"] --> Client["Protected Browser Context"]Root-Cause Analysis
Permissive configurations weaken browser Same-Origin Policy protections by reflecting the incoming Origin header into Access-Control-Allow-Origin alongside Access-Control-Allow-Credentials: true, or weaken CSP with 'unsafe-inline', 'unsafe-eval', and broad CDN wildcards.
3. Deterministic Discovery & Grep/AST Audit Commands
Run the following discovery commands across the target repository before manual code review:
# 1. Automated ViperClaw analysis
viperclaw fingerprint ./traffic.har --output headers_audit.json
# 2. Rapid static pattern discovery (ripgrep)
rg -n "(Access-Control-Allow-Origin|Access-Control-Allow-Credentials|CORSMiddleware|cors\()"
rg -n "(Content-Security-Policy|unsafe-inline|unsafe-eval|frame-ancestors)"
rg -n "(Strict-Transport-Security|X-Frame-Options|X-Content-Type-Options|Referrer-Policy)"4. Senior Security Engineer 8-Point Audit Checklist
| Control ID | Audit Verification Target | Pass Criteria | Fail / Vulnerability Indicator |
HDR-01 | Zero Arbitrary CORS Origin Reflection | When Access-Control-Allow-Credentials: true is present, Access-Control-Allow-Origin is validated against an exact-match set of trusted origins. | Server reflects req.headers.origin or uses regex .endswith('example.com') (matched improperly by evilexample.com). |
HDR-02 | Block Origin: null in Credentialed CORS | Origin: null is never allowed on credentialed endpoints. | Access-Control-Allow-Origin: null + Allow-Credentials: true (reachable via sandboxed <iframe sandbox>). |
HDR-03 | Vary: Origin Shared-Cache Isolation | Dynamic Access-Control-Allow-Origin responses always include Vary: Origin. | Missing Vary: Origin causes CDN to cache Origin A's CORS header and serve it to Origin B. |
HDR-04 | CSP script-src Hardening (No unsafe-inline/eval) | CSP uses cryptographic nonces ('nonce-...') + 'strict-dynamic' or hashes, with object-src 'none' and base-uri 'self'. | script-src * 'unsafe-inline' 'unsafe-eval' data: rendering CSP ineffective against XSS. |
HDR-05 | Clickjacking Defense (frame-ancestors & X-Frame-Options) | CSP includes frame-ancestors 'none' (or 'self') paired with X-Frame-Options: DENY on HTML routes. | Authenticated state-changing UI pages frameable by external origins. |
HDR-06 | HSTS Preload Readiness | Strict-Transport-Security: max-age=63072000; includeSubDomains; preload served over HTTPS. | max-age < 1 year (31536000) or missing includeSubDomains. |
HDR-07 | Referrer-Policy & Permissions-Policy | Referrer-Policy: strict-origin-when-cross-origin (or no-referrer) and Permissions-Policy: camera=(), microphone=(), geolocation=() set. | unsafe-url referrer policy leaking sensitive URL paths/tokens to third-party links. |
HDR-08 | Cross-Origin Isolation Headers (COOP / CORP) | Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Resource-Policy: same-origin configured. | Window references retained across cross-origin popups (window.opener tabnabbing). |
5. False-Positive Elimination & CVSS v3.1 Triage Rubric
False-Positive Gate
- Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.
- Confirm the code path is reachable from an external entrypoint (not dead code, CLI-only admin script, or unit-test fixture).
| Severity Tier | Baseline CVSS v3.1 Vector | Qualifying Security Impact |
| HIGH (8.1) | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N | Reflected Access-Control-Allow-Origin + Allow-Credentials: true on authenticated API leaking tokens/PII. |
| MEDIUM (6.1) | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N | Clickjacking on sensitive account-settings UI due to missing frame-ancestors / X-Frame-Options. |
| LOW (3.7) | CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N | Permissive Referrer-Policy or missing Vary: Origin header. |
6. Production Remediation Patterns (Vulnerable vs. Hardened Code)
# ❌ VULNERABLE: FastAPI CORSMiddleware with wildcard origin reflection + allow_credentials=True
app.add_middleware(
CORSMiddleware,
allow_origin_regex=r"https://.*example\.com", # Matches https://evilexample.com!
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# ✅ HARDENED: Exact-match origin allowlist + restricted methods and headers
app.add_middleware(
CORSMiddleware,
allow_origins=["https://app.example.com", "https://admin.example.com"],
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE"],
allow_headers=["Authorization", "Content-Type", "X-CSRF-Token"],
)7. Regression Testing & Continuous Verification
- Write a Positive Unit Test confirming authorized, schema-valid requests succeed.
- Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.
- Re-run
viperclaw taintandviperclaw verifyto confirm zero remaining unmitigated flows in.viperclaw/graph.db.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

