{
  "slug": "Your-NestJS-API-Is-Leaking-Password-Hashes---And-You-Probably-Don-t-Know-It-dcaea709a987",
  "title": "Your NestJS API Is Leaking Password Hashes — And You Probably Don’t Know It",
  "subtitle": "A deep dive into Broken Object Property Level Authorization (BOPLA) — the silent API vulnerability hiding in your Prisma includes",
  "excerpt": "A deep dive into Broken Object Property Level Authorization (BOPLA) — the silent API vulnerability hiding in your Prisma includes",
  "date": "2026-11-11",
  "tags": [
    "API Security",
    "NestJS",
    "Prisma",
    "OWASP",
    "TypeScript"
  ],
  "readingTime": "2 min",
  "url": "https://medium.com/devops-dev/your-nestjs-api-is-leaking-password-hashes-and-you-probably-dont-know-it-dcaea709a987",
  "hero": "https://miro.medium.com/v2/resize:fit:720/format:webp/1*jTRxwTYrH67pD6Y6hAwUFA.png",
  "content": [
    {
      "type": "paragraph",
      "html": "In an audit of a NestJS address book API, Mobin Shaterian found that a feature intended to let the frontend request related records could expose password hashes to an authenticated user. The API checked access to the address book but left the response fields up to the client."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "What is broken object property level authorization?"
    },
    {
      "type": "paragraph",
      "html": "Broken Object Property Level Authorization (BOPLA) is OWASP API3:2023. It occurs when an API lets a client read or modify object properties without checking whether the client is authorized to access those properties. In this audit, the problem was on the read side. Access to an address book did not imply access to all fields on its related records."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Why it happened"
    },
    {
      "type": "paragraph",
      "html": "The pagination DTO accepted a JSON relation selector from the client, and the service passed that selector into Prisma. The detail endpoint also accepted a raw relation selector. Neither path defined which related fields belonged in the public response."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "How to fix it in NestJS and Prisma"
    },
    {
      "type": "list",
      "ordered": true,
      "items": [
        "Remove the raw relation selector from shared pagination DTOs and public controllers.",
        "Use validated, endpoint-specific flags for the relations the frontend needs.",
        "Build the Prisma query on the server. Use explicit <code>select</code> allowlists for returned fields, including fields on nested relations.",
        "Map database results into response DTOs that contain only fields authorized for the caller. Apply the same response contract to list and detail endpoints."
      ]
    },
    {
      "type": "heading",
      "level": 2,
      "text": "What to check before shipping"
    },
    {
      "type": "list",
      "ordered": false,
      "items": [
        "Does any controller pass client-supplied objects directly to Prisma?",
        "Are nested fields explicitly selected, and does the selection match the caller’s permissions?",
        "Do regression tests confirm that secrets and internal fields are absent from both list and detail responses?",
        "Does NestJS validate incoming DTOs and reject or remove unexpected fields?",
        "Do pages, emails, and exports safely handle free-text values returned by the API?"
      ]
    }
  ]
}