Excessive Data Exposure in API Responses

API responses return more properties than the client needs, including sensitive ones, and rely on the client to hide them, so anyone reading the raw response sees them.

SeverityMedium
CVSS 3.14.3 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N Open in the calculator
CVSS 4.05.3 CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-213: Exposure of Sensitive Information Due to Incompatible Policies
CategoryInformation Disclosure

Description

The API returns whole objects, or more of their properties than the client application uses, and relies on the client to display only what each user should see. The additional properties are visible to anyone who reads the raw response in a browser's developer tools or an intercepting proxy, so any authenticated user, and on public endpoints anyone, can collect the extra data by reading responses directly or by scripting requests to the affected endpoints.

Typical examples are user objects that include email addresses, telephone numbers, dates of birth, password hashes, multi-factor secrets, internal flags or roles; search, listing and mention endpoints that return full records of other users when the interface shows only their names; and objects carrying internal notes, cost prices or other fields meant for staff. Depending on the fields, this can expose other users' personal data, credentials or secrets that enable further attacks, or commercially sensitive information, and where a listing or search endpoint is affected, data about many users can be harvested quickly. The impact rises with the sensitivity of the exposed properties and the number of records that can be reached.

The weakness often comes from serialising database entities or ORM models directly to JSON, from generic endpoints shared by the public client and internal tools, and, in GraphQL, from types whose sensitive fields are not protected by field-level authorisation. It is part of what the OWASP API Security Top 10 calls broken object property level authorisation, the read-side counterpart of mass assignment.

The weakness is identified by comparing each API response with what the user interface displays, for each role, and reviewing every property for data the caller should not receive, with particular attention to responses that describe other users.

Remediation

Decide on the server which properties each caller may receive:

  • Return explicit response models (data transfer objects or view models) that list the properties each endpoint needs, instead of serialising database entities or ORM objects directly. Where a framework serialiser is used, configure it with an allowlist of fields rather than a list of exclusions.
  • Where different roles need different views of the same object, build a separate response model for each role, or apply property-level authorisation in the serialiser.
  • Never include secrets such as password hashes, tokens, API keys or multi-factor seeds in any response.
  • In GraphQL, apply authorisation in the resolvers of sensitive fields, not only at the type or query level.
  • Define response schemas in the API specification and validate responses against them in testing, so that new properties cannot appear unnoticed.

Confirm the fix by repeating the affected requests for each role and checking that responses contain only the documented, necessary properties.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More APIs Findings

Every APIs finding