viper-openapi-rest-schema
Skill22 starsChanged 15 days agoMITView on GitHub
OpenAPI / Swagger Schema, Mass Assignment & REST API Security Auditor (OWASP API3 & API4). Reviews DTO allowlisting, pagination caps, and schema validation.
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-headers-csp-corsSkill
- 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-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 106
Write a Positive Unit Test confirming authorized, schema-valid requests succeed.
- Distinctive: line 107
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
OpenAPI Schema, Mass Assignment (BOPLA) & REST API Contract Auditor (viper-openapi-rest-schema)
1. Executive Scope, Standards & CWE/OWASP Mapping
- Frameworks & Standards: OWASP API3:2023 (Broken Object Property Level Authorization), OWASP API4:2023, OpenAPI v3.1 Specification, CWE-915
- Primary CWE Mapping: CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes / Mass Assignment), CWE-213 (Exposure of Sensitive Information Due to Incompatible Policies / Excessive Data Exposure)
- ViperClaw MCP Tools:
viper_taint_scan,viper_diff_oracle,viper_verify_and_report - ViperClaw CLI Command:
viperclaw taint ./src --db .viperclaw/graph.db
2. Threat Model & Root-Cause Architecture
flowchart LR
Client["Client JSON Request"] --> InDTO["Strict Input DTO (additionalProperties: false)"] --> ORM["Explicit Field Mapping"] --> OutDTO["Redacted Output DTO Serializer"]Root-Cause Analysis
REST controllers bind raw request JSON directly into database ORM objects (User(**req.json), Object.assign(entity, req.body)), allowing callers to overwrite protected columns (role, is_admin, tenant_id, email_verified, balance), or return raw ORM entities that serialize password_hash, mfa_secret, and PII.
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 taint ./src --db .viperclaw/graph.db
# 2. Rapid static pattern discovery (ripgrep)
rg -n "(\*\*request\.(json|get_json)|Object\.assign\(user,\s*req\.body|Model\.create\(req\.body)"
rg -n "(swagger-ui|openapi\.json|/docs|/redoc|api-docs)"
rg -n "(extra\s*=\s*.allow.|additionalProperties\s*:\s*true)"4. Senior Security Engineer 8-Point Audit Checklist
| Control ID | Audit Verification Target | Pass Criteria | Fail / Vulnerability Indicator |
API-01 | Input DTO Property Allowlisting (No Mass Assignment) | Every POST/PUT/PATCH route binds to a dedicated Input DTO that explicitly lists editable user fields and sets extra='forbid' / additionalProperties: false. | ORM model updated directly from req.body or request.json. |
API-02 | Output Serializer DTO (No Excessive Data Exposure) | Every read/list endpoint serializes through an explicit Output DTO that excludes password_hash, mfa_secret, reset_token, and internal metadata. | Controller returns raw database row (SELECT * / return db_user) to the JSON serializer. |
API-03 | Pagination & Batch Size Caps (OWASP API4) | List endpoints enforce 1 <= limit <= 100 and cap maximum offset or use cursor pagination. | GET /api/users?limit=10000000 allowed, exhausting database memory and worker threads. |
API-04 | Production Swagger / OpenAPI UI Access Control | Interactive /docs, /redoc, /swagger-ui.html, and /openapi.json are disabled in production or gated behind internal authentication. | Unauthenticated /swagger-ui in production exposing internal admin and debug endpoints. |
API-05 | Strict JSON Type & Bound Validation | Strings enforce minLength/maxLength and regex patterns; numbers enforce minimum/maximum and reject NaN/Infinity. | Unbounded 50MB string field or negative numeric value accepted by API schema. |
API-06 | API Version Lifecycle & Shadow API Retirement | Legacy API versions (/api/v1/*, /api/beta/*) are decommissioned or share the exact same auth/rate-limit middleware as /api/v2/*. | Deprecated /api/v1/login remains online without MFA or rate limiting. |
API-07 | JSON Patch (application/json-patch+json) Path Guard | If RFC 6902 JSON Patch is used, path pointers (/role, /tenantId) are validated against an editable field allowlist. | Unfiltered [{ "op": "replace", "path": "/isAdmin", "value": true }] applied to entity. |
API-08 | Uniform 401/403/422 Error Schema | Validation errors (422) do not echo back internal server configuration or full raw database constraints. | Pydantic/Hibernate error response leaks internal class paths or SQL constraint names. |
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 |
| CRITICAL (9.1) | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N | Mass assignment on user profile/registration overwriting role: "admin", is_superuser: true, or tenant_id. |
| HIGH (7.5) | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N | Excessive data exposure returning password_hash, api_key, or mfa_secret in /api/users response. |
| MEDIUM (5.3) | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L | Uncapped pagination (limit=999999) or exposed internal Swagger documentation. |
6. Production Remediation Patterns (Vulnerable vs. Hardened Code)
# ❌ VULNERABLE: Updates ORM user directly from raw dict & returns full ORM model (with password_hash!)
@router.patch("/users/me")
def update_me(req_body: dict, user: User = Depends(get_current_user), db: Session = Depends(get_db)):
for k, v in req_body.items():
setattr(user, k, v) # Untrusted caller sends {"is_admin": True, "balance": 999999}
db.commit()
return user
# ✅ HARDENED: Strict Input DTO (extra='forbid') + Explicit Output DTO
class UserUpdateInput(BaseModel):
model_config = ConfigDict(extra="forbid")
display_name: str = Field(min_length=1, max_length=80)
bio: str = Field(default="", max_length=500)
class UserPublicOutput(BaseModel):
id: UUID
display_name: str
bio: str
@router.patch("/users/me", response_model=UserPublicOutput)
def update_me(req_body: UserUpdateInput, user: User = Depends(get_current_user), db: Session = Depends(get_db)):
user.display_name = req_body.display_name
user.bio = req_body.bio
db.commit()
return user7. 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.

