Cluster 9 · OWASP API3:2023 · additionalProperties: false

Stopping Mass Assignment with additionalProperties: false & ReadOnly Fields

Close OWASP API3:2023 Broken Object Property Level Authorization (BOPLA) and Mass Assignment gaps by enforcing additionalProperties: false, readOnly server attributes, and strict request DTOs.

Zero Telemetry · Strict CSP (connect-src 'none')

1. Paste OpenAPI Spec (Quick-Lint) & Controls

OAS 2.0 / 3.0 / 3.1 · OWASP API Top 10
Parsed JSON OpenAPI 3.0.1 · 2 ops · 1 {id} routes · 1 nullable: true · ~522 tok
OWASP API Top 10 & MCP Readiness Checklist (100 Points)
Low API Exploit & Token Risk
85 / 100 (B)
HARDENED — OWASP & MCP READY

Passing: 7 · Fixes Needed: 1 · Target: OpenAPI 3.1.0

Est. MCP Schema Tokens
2,832 tok
$12.74/mo at 50 turns/day ($3/1M)
Reclaimable Diet Savings
-992 tok
Saves $4.46/mo via MCPDiet
API2-AUTH (OWASP API2:2023): Explicit components.securitySchemes (Bearer JWT / OAuth2 scopes) + global/op security PASS
Bearer JWT / OAuth2 securitySchemes and security[] requirements are enforced.
API1-BOLA (OWASP API1:2023): Object-ID routes ({id}) enforce explicit 401/403 responses & tenant ownership scopes PASS
Parameterized {id} endpoints verify tenant ownership and document 401/403 status codes.
API3-BOPLA (OWASP API3:2023): additionalProperties: false + readOnly: true on server-owned fields (role, id, plan) CRITICAL FIX
Unbounded object schemas allow attackers to inject role, plan, or tenantId fields (OWASP API3 Mass Assignment / BOPLA).
API4-BOUNDS (OWASP API4:2023): maxLength, maxItems, maximum & bounded pagination (limit <= 100 / cursor) on inputs PASS
Strings, arrays, and pagination limits define strict maxLength, maxItems, and maximum bounds.
API8-TLS (OWASP API8:2023): HTTPS-only servers[] URLs (zero http:// prod) + strict CORS allowlist & headers PASS
Production servers[] enforce HTTPS-only URLs and strict origin allowlist CORS.
API4-429 (OWASP API4 / API8): Explicit 401, 403 & 429 Too Many Requests responses with Retry-After / X-RateLimit-* PASS
401, 403, and 429 Too Many Requests responses include Retry-After / X-RateLimit-* headers.
API9-INV (OWASP API9:2023): Versioned base paths + deprecated: true ops declare Sunset header & replacement path PASS
Deprecated endpoints publish Sunset headers and migration paths; zero shadow APIs.
MCP-TOKEN (AI / MCP Readiness): Concise tool descriptions (<= 120 tok/op) & OpenAPI 3.1 type arrays (no nullable: true) PASS
Operation descriptions stay lean (~47 tok/op) and OpenAPI 3.1.0 avoids nullable drift.
openapi-owasp-remediation.yaml
openapi: "3.1.0"
info:
  title: "User & Billing Profile API"
  version: "1.0.0"
components:
  schemas:
    WorkspaceMemberCreateRequest:
      type: object
      additionalProperties: false
      required:
        - email
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        role:
          type: string
          readOnly: true
        email:
          type: string
          format: email
          maxLength: 254
        tags:
          type: array
          maxItems: 20
          items:
            type: string
            maxLength: 32
        nickname:
          type:
            - string
            - "null"
          maxLength: 64
Zero-Upload SpecDiff $49 Remediation PR

Audit Full OpenAPI Specs or Ship a Hardened PR Today

Run a 100% browser-side breaking-change diff, OWASP API Top 10 scan & SARIF 2.1.0 export on SpecDiff (https://spec.runglab.dev), order a $49 Done-For-You OpenAPI & MCP Remediation PR on Creem, or automate via POST /v1/openapi/audit (API Hub), remote MCP tool audit_openapi_spec, and Apify Cloud PPE.

OpenAPI Controls, Bounds & Verification Reference

Rule / Control Hardened Pattern Security & Token Rationale
additionalProperties: false Required on every input object Blocks unknown JSON keys like `isAdmin: true` or `credits: 99999` at schema validation
readOnly: true On id, role, planTier, createdAt Prevents clients & LLM tool callers from mutating server-managed properties
Separate Request vs Response UserUpdateRequest vs UserResponse Avoids sharing one DB entity schema across PATCH inputs and GET outputs
MCP Empirical Parallel 54.5% of live MCP servers omit it In our 100-server MCP audit, loose schemas caused both hallucinated args and property pollution

Zero-Mass-Assignment Request vs Response Schema Pattern

anti-mass-assignment.yaml
components:
  schemas:
    AccountUpdateRequest:
      type: object
      additionalProperties: false
      properties:
        displayName:
          type: string
          minLength: 1
          maxLength: 80
        timezone:
          type: string
          maxLength: 64
    AccountResponse:
      type: object
      additionalProperties: false
      required: [id, email, role, planTier]
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        email:
          type: string
          format: email
        role:
          type: string
          enum: [member, admin]
          readOnly: true
        planTier:
          type: string
          readOnly: true

Express / Zod & FastAPI Strict Input Enforcement

strict-dto-runtime.ts
// Zod (TypeScript / Node): always use z.strictObject() instead of z.object()
import { z } from "zod";

export const AccountUpdateSchema = z.strictObject({
  displayName: z.string().min(1).max(80).optional(),
  timezone: z.string().max(64).optional()
}); // Rejects { role: "admin" } with HTTP 400 before touching ORM!

Key Engineering Takeaways

  • JSON Schema defaults `additionalProperties` to `true`, meaning any OpenAPI requestBody object without `additionalProperties: false` silently permits extra keys (`role`, `isAdmin`, `subscriptionCredits`).
  • In RungLab's 100-server live MCP study (/research/mcp-100-servers-context-tax/), 54.5% of servers omitted `additionalProperties: false` — letting LLMs hallucinate unexpected parameters or overwrite server state.
  • Combining separate `Request` DTOs with `readOnly: true` annotations guarantees both runtime request validators and OpenAPI code generators block forbidden properties.

Common Contract Pitfalls to Avoid

  • Reusing a single `User` ORM model for `GET` responses and `PATCH /users/{id}` request bodies.
  • Unwrapping Zod `.shape` or Pydantic defaults with `extra='allow'` instead of `extra='forbid'` / `z.strictObject()`.
  • Returning sensitive PII (`passwordHash`, `stripeCustomerSecret`, internal `adminNotes`) in shared response schemas without field-level `writeOnly` or split DTOs.

More OpenAPI OWASP & MCP Optimization Guides

← Back to OpenAPI OWASP & MCP Scorer Hub · 2026 N=26 OpenAPI & MCP Benchmark → · MCP Context Token Cost Calculator → · CORS Preflight & Webhook HMAC Debugger → · SpecDiff Live Diff & SARIF → · $49 Remediation PR →

Frequently Asked Questions

Does additionalProperties: false work cleanly with allOf inheritance in OpenAPI 3.0?

Be careful: in JSON Schema / OpenAPI 3.0, placing `additionalProperties: false` inside one branch of `allOf` rejects properties defined in sibling `allOf` subschemas. Use flat composed DTOs or JSON Schema 2020-12 `unevaluatedProperties: false` in OpenAPI 3.1.

Why does OWASP API3:2023 combine Excessive Data Exposure and Mass Assignment?

Both stem from missing property-level authorization (BOPLA): exposing unauthorized fields in responses and accepting unauthorized fields in payloads.

How can I scan my OpenAPI schemas for missing additionalProperties: false?

Use the interactive scorer above, paste your spec into https://spec.runglab.dev, or run `audit_openapi_spec` via dev.runglab/devtools MCP.