API security

Building repeatable API authorisation regression tests

Release boundary: code, package, server arranged to illustrate building repeatable api authorisation regression tests.

Regression tests need negative permission cases as well as successful API journeys. Understanding repeatable API authorisation regression tests helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Authorisation determines which resources and operations an established identity may use. It must be enforced where protected data is read or changed. User interface restrictions, obscure identifiers and documentation can help usability, but they do not replace the service's own permission decision.

Comprehensive authorisation documentation is essential to ensure that security decisions are consistently applied, auditable, and aligned with organisational policies. This reduces the risk of unauthorised access by making security requirements clear and actionable for developers, administrators, and testers.

Why it matters

Consider a realistic failure: a release keeps an endpoint functional while silently dropping a tenant check.

A missing check can expose another account's information or let an ordinary user perform a privileged action. The result should be described by the actual records and operations reached, including whether access crosses a customer or organisational boundary.

An API review follows the server-side behaviour behind the interface. Direct requests, alternate methods and background operations can reveal boundaries that the normal frontend journey does not exercise.

How penetration testers check for it

Build a matrix of roles, owners, tenants, operations and important state changes.

  • Confirm that authorisation documentation defines rules for restricting function-level and data-specific access based on consumer permissions and resource attributes.
  • Confirm that authorisation documentation defines rules for field-level access restrictions (both read and write) based on consumer permissions and resource attributes. Note that these rules might depend on other attribute values of the relevant data object, such as state or status.
  • Confirm that the application's documentation defines the environmental and contextual attributes (including but not limited to, time of day, user location, IP address, or device) that are used in the application to make security decisions, including those pertaining to authentication and authorisation.
  • Confirm that authentication and authorisation documentation defines how environmental and contextual factors are used in decision-making, in addition to function-level, data-specific, and field-level authorisation. This should include the attributes evaluated, thresholds for risk, and actions taken.
  • Confirm that the application ensures that function-level access is restricted to consumers with explicit permissions.
  • Confirm that the application ensures that data-specific access is restricted to consumers with explicit permissions to specific data items to mitigate insecure direct object reference (IDOR) and broken object level authorisation (BOLA).
  • Confirm that the application ensures that field-level access is restricted to consumers with explicit permissions to specific fields to mitigate broken object property level authorisation (BOPLA).
  • Confirm that adaptive security controls based on a consumer's environmental and contextual attributes are implemented for authentication and authorisation decisions, as defined in the application's documentation. These controls must be applied when the consumer tries to start a new session and also during an existing session.
  • Confirm that the application enforces authorisation rules at a trusted service layer and doesn't rely on controls that an untrusted consumer could manipulate, such as client-side JavaScript.
  • Confirm that changes to values on which authorisation decisions are made are applied immediately. Where changes cannot be applied immediately,, there must be mitigating controls to alert when a consumer performs an action when they are no longer authorised to do so and revert the change. Note that this alternative would not mitigate information leakage.
  • Confirm that access to an object is based on the originating subject's permissions, not on the permissions of any intermediary or service acting on their behalf. For example, if a consumer calls a web service using a self-contained token for authentication, and the service then requests data from a different service, the second service will use the consumer's token, rather than a machine-to-machine token from the first service, to make permission decisions.
  • Confirm that multi-tenant applications use cross-tenant controls to ensure consumer operations will never affect tenants with which they do not have permissions to interact.
  • Confirm that access to administrative interfaces incorporates multiple layers of security, including continuous consumer identity verification, device security posture assessment, and contextual risk analysis, ensuring that network location or trusted endpoints are not the sole factors for authorisation even though they may reduce the likelihood of unauthorised access.
  • Test nested resources, background processing and state changes.
  • Confirm rejection as well as the legitimate successful journey.

How to fix it

Keep access rules explicit and run repeatable rejection tests alongside functional checks.

  • Define explicit access rules and default-deny behaviour.
  • Bind resource selection to trusted ownership and tenant context.
  • Enforce permission checks at each protected operation.
  • Maintain regression cases for unauthorised users and changed permissions.

A successful response alone does not prove unauthorised access. Establish whose resource was affected and what the caller was legitimately entitled to do.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss your APIs and integrations.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo