agentleFS
zahidoverflowzahidoverflow/viperclaw/skills/viper-bola-idor/SKILL.md

viper-bola-idor

Skill22 starsChanged 16 days agoMITView on GitHub

Object & Function-Level Authorization (BOLA / BFLA) Audit Skill. Reviews resource access controls, tenant scoping, and ownership checks across API endpoints and controllers.

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
  1. Distinctive:

    Run the following discovery commands across the target repository before manual code review:

    line 30
  2. Distinctive:

    Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.

    line 62
  3. Distinctive:

    Write a Positive Unit Test confirming authorized, schema-valid requests succeed.

    line 100
  4. Distinctive:

    Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.

    line 101

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Object, Property & Function-Level Authorization (BOLA / IDOR / BFLA) Auditor (viper-bola-idor)

1. Executive Scope, Standards & CWE/OWASP Mapping

  • Frameworks & Standards: OWASP API1:2023 (BOLA), OWASP API3:2023 (BOPLA), OWASP API5:2023 (BFLA), OWASP ASVS V4, CWE-639, CWE-285
  • Primary CWE Mapping: CWE-639 (Insecure Direct Object Reference via User-Controlled Key), CWE-285 (Improper Authorization), CWE-862 (Missing Authorization), CWE-863 (Incorrect Authorization)
  • ViperClaw MCP Tools: viper_diff_oracle, viper_taint_scan, viper_graph_upsert, viper_verify_and_report
  • ViperClaw CLI Command: viperclaw taint ./src --db .viperclaw/graph.db

2. Threat Model & Root-Cause Architecture

flowchart LR
  Caller["Authenticated Caller (User A, Tenant 1)"] --> Ctrl["API Controller (/orders/{id})"] --> AuthZ["Policy / Ownership Check"] --> DB[("Database (WHERE id = ? AND tenant_id = ?)")]

Root-Cause Analysis

Controllers validate authentication (verifying the caller has a valid JWT/session) but query the database using only the client-supplied resource ID (WHERE id = :id) without binding the caller's user_id or tenant_id.


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 "\.(findById|find_by_id|get_object_or_404|findUnique|findOne)\("
rg -n "WHERE\s+id\s*=\s*(\?|%s|\$1|:id)"
rg -n "/api/v[0-9]+/[a-zA-Z0-9_-]+/\{?(id|uuid|user_id|org_id|account_id)\}?"

4. Senior Security Engineer 8-Point Audit Checklist

Control IDAudit Verification TargetPass CriteriaFail / Vulnerability Indicator
BOLA-01Query-Level Ownership BindingEvery SELECT/UPDATE/DELETE query includes AND tenant_id = :ctx_tenant AND user_id = :ctx_user.Resource fetched solely by primary key findById(req.params.id) without ownership check.
BOLA-02Nested & Sub-Resource ScopingChild resources (/orgs/{org_id}/projects/{proj_id}/keys/{key_id}) verify parent-child hierarchy.Controller checks org_id membership but looks up key_id globally without verifying key.org_id == org_id.
BOLA-03Bulk & Array Endpoint AuthorizationBatch endpoints (POST /api/items/bulk-delete with ids: [1,2,3]) verify ownership of every ID in the array.Controller checks ownership of ids[0] only and deletes the entire WHERE id IN (...) list.
BOLA-04Function-Level RBAC (BFLA)Administrative routes (/admin/*, DELETE, role-assignment) enforce explicit server-side role guards.Admin endpoints rely on UI hiding or only check standard user authentication.
BOLA-05Foreign-Key Reference Validation on Create/UpdateCreating a resource with project_id or folder_id in the body verifies the caller owns that target container.A caller creates a webhook or export bound to another tenant's project_id.
BOLA-06UUIDv4 vs. Access ControlUnpredictable UUIDs are paired with server-side ownership checks (UUIDs alone are not authorization).Publicly readable/writable objects protected solely by unauthenticated UUIDs leaked in logs/referrers.
BOLA-07GraphQL & gRPC Resolver AuthZEvery nested GraphQL field resolver and gRPC handler enforces context-based policy checks.Top-level query checks auth, but nested edge { organization(id: "other") { billing } } skips auth.
BOLA-08Export & Async Job OwnershipAsync report generation (POST /reports -> GET /reports/{job_id}) binds job_id to caller's session.Sequential job_id downloadable by any authenticated user.

5. False-Positive Elimination & CVSS v3.1 Triage Rubric

False-Positive Gate

  1. Verify whether an upstream API Gateway, global middleware, or ORM hook already enforces the control before flagging a controller.
  2. Confirm the code path is reachable from an external entrypoint (not dead code, CLI-only admin script, or unit-test fixture).
Severity TierBaseline CVSS v3.1 VectorQualifying Security Impact
CRITICAL (9.1)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:NUnauthenticated BOLA/BFLA allowing read/write of arbitrary tenant accounts or API keys.
HIGH (8.1)CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:NAuthenticated cross-tenant read/modify of private records, invoices, or user profiles.
MEDIUM (6.5)CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:NAuthenticated horizontal read-only access to non-credential user metadata.

6. Production Remediation Patterns (Vulnerable vs. Hardened Code)

# ❌ VULNERABLE: Fetches invoice by ID alone; any logged-in user can read any tenant's invoice
@router.get("/invoices/{invoice_id}")
async def get_invoice(invoice_id: int, current_user: User = Depends(get_current_user), db: Session = Depends(get_db)):
    invoice = db.query(Invoice).filter(Invoice.id == invoice_id).first()
    if not invoice:
        raise HTTPException(status_code=404)
    return invoice

# ✅ HARDENED: Scopes query directly to authenticated user's tenant_id & verifies role
@router.get("/invoices/{invoice_id}", response_model=InvoiceReadDTO)
async def get_invoice(invoice_id: int, current_user: User = Depends(get_current_user), db: Session = Depends(get_db)):
    invoice = (
        db.query(Invoice)
        .filter(Invoice.id == invoice_id, Invoice.tenant_id == current_user.tenant_id)
        .first()
    )
    if not invoice:
        raise HTTPException(status_code=404, detail="Invoice not found")
    return invoice

7. Regression Testing & Continuous Verification

  1. Write a Positive Unit Test confirming authorized, schema-valid requests succeed.
  2. Write a Negative Security Regression Test confirming unauthorized, cross-tenant, or malformed inputs are deterministically rejected.
  3. Re-run viperclaw taint and viperclaw verify to confirm zero remaining unmitigated flows in .viperclaw/graph.db.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.