Understanding the OWASP API Security Top 10

The Open Web Application Security Project (OWASP) is a non-profit foundation dedicated to improving software security. Their API Security Top 10 is a critical resource for developers, security professionals, and architects, highlighting the most critical security risks to APIs. This guide provides a detailed breakdown of each risk and how to mitigate it.

API1:2019 - Broken Object Level Authorization (BOLA)

What it is: BOLA occurs when an application doesn't correctly validate that a user has permission to access a specific object (e.g., a record, file, or resource). An attacker can exploit this by manipulating the ID of an object sent in an API request to access data they shouldn't be able to see.

Example: An e-commerce API endpoint GET /api/v1/orders/{orderId} retrieves order details. A user is authenticated, but the application fails to check if the orderId belongs to that user. An attacker could cycle through orderId values to view other customers' orders.

Mitigation:

  • Implement robust authorization checks at the object level for every request.
  • Use random, non-sequential, and unique IDs (UUIDs) for resources to make them harder to guess.
  • Verify that the logged-in user has the necessary permissions for the requested object.

API2:2019 - Broken User Authentication

What it is: This vulnerability involves weaknesses in authentication mechanisms. Flaws can include weak password policies, insecure password recovery, exposing session IDs in URLs, or not validating tokens correctly.

Example: An API uses JWTs for authentication but fails to validate the token's signature. An attacker could forge a token with a different user ID (e.g., an admin) and gain unauthorized access.

Mitigation:

  • Implement multi-factor authentication (MFA).
  • Use strong password policies and secure password hashing (e.g., Argon2, bcrypt).
  • Use short-lived access tokens and a secure refresh token mechanism.
  • Never expose session tokens in URLs.

API3:2019 - Excessive Data Exposure

What it is: APIs often expose more data than the client application requires. Even if the sensitive data isn't displayed in the UI, it's still present in the API response and can be intercepted by an attacker.

Example: A user profile endpoint /api/v1/users/me returns a JSON object containing the user's name, email, address, and credit card number, even though the mobile app only displays the name and email.

Mitigation:

  • Design API responses to only include the data necessary for the specific client function.
  • Avoid relying on the client-side to filter sensitive data.
  • Implement a schema-based response validation to ensure no extra data is sent.

API4:2019 - Lack of Resources & Rate Limiting

What it is: APIs without proper rate limiting or resource controls are vulnerable to denial-of-service (DoS) attacks or brute-force attacks. Attackers can overwhelm the API with requests, degrading performance or causing an outage.

Example: A login endpoint has no limit on the number of attempts. An attacker can use an automated script to try millions of password combinations (credential stuffing).

Mitigation:

  • Implement rate limiting based on IP address, user account, or API key.
  • Set limits on request payload size, number of records returned per request, and server-side execution time.
  • Use a Web Application and API Protection (WAAP) solution to manage traffic.

API5:2019 - Broken Function Level Authorization

What it is: This flaw occurs when an application fails to restrict access to certain functions or administrative endpoints. Regular users might be able to access functionality reserved for administrators.

Example: An admin endpoint POST /api/v1/admin/users/delete is exposed. While not linked in the UI for regular users, an attacker who discovers the endpoint can send a request to it and delete users.

Mitigation:

  • Enforce strict, role-based access controls by default.
  • Ensure all administrative functions check the user's role and permissions before executing.
  • Structure your API design to separate regular and administrative functions clearly.

API6:2019 - Mass Assignment

What it is: Mass assignment happens when a framework automatically binds incoming request parameters to object properties. An attacker can exploit this by passing unexpected parameters to modify object properties they shouldn't have access to.

Example: A user profile update endpoint allows a user to change their username. The underlying code automatically maps all request parameters to the user object. An attacker adds an isAdmin: true field to the JSON payload, which the framework assigns to the user object, elevating their privileges.

Mitigation:

  • Use an "allow list" approach, explicitly defining which properties can be updated by the client.
  • Avoid binding request data directly to internal objects. Use Data Transfer Objects (DTOs) to mediate.

API7:2019 - Security Misconfiguration

What it is: This is a broad category covering insecure default configurations, verbose error messages containing sensitive information, unnecessary HTTP methods being enabled, or missing security headers.

Example: An API server sends back detailed stack traces in error messages, revealing underlying frameworks, library versions, and internal file paths that an attacker can use for reconnaissance.

Mitigation:

  • Establish a repeatable hardening process for your application stack.
  • Restrict administrative access and disable unnecessary features.
  • Configure proper CORS policies and security headers (e.g., Content-Security-Policy).
  • Return generic error messages to users.

API8:2019 - Injection

What it is: Injection flaws, such as SQL, NoSQL, or Command Injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker's malicious data can trick the interpreter into executing unintended commands.

Example: An API endpoint that searches for products uses raw user input to construct a SQL query: SELECT * FROM products WHERE name = ' + userInput + '. An attacker can provide input like ' OR 1=1; -- to retrieve all products.

Mitigation:

  • Use safe, parameterized APIs (e.g., prepared statements) for data queries.
  • Validate and sanitize all user-provided input.
  • Implement the principle of least privilege for database access.

API9:2019 - Improper Assets Management

What it is: This risk relates to issues with API versioning and inventory. Older, unpatched API versions might remain active and exposed, or development/staging environments might be accessible from the public internet.

Example: api.example.com/v1 is deprecated and vulnerable, but it was never taken offline. Attackers discover it and exploit its known flaws, even though api.example.com/v2 is secure.

Mitigation:

  • Maintain a complete inventory of all API endpoints, including their versions and environments.
  • Implement a robust deprecation plan for older API versions.
  • Use API gateways to manage and secure access to all APIs.
  • Block access to non-production environments from the public internet.

API10:2019 - Insufficient Logging & Monitoring

What it is: Without adequate logging and monitoring, it's difficult to detect and respond to attacks. Attackers rely on the lack of monitoring to operate undetected.

Example: An attacker performs a slow, low-volume credential stuffing attack over several days. Without proper logging and alerting on failed login attempts, the attack goes unnoticed.

Mitigation:

  • Log all failed authentication attempts, access control failures, and input validation errors.
  • Ensure logs are formatted in a way that can be easily consumed by a centralized SIEM or monitoring system.
  • Implement alerts for suspicious activities to enable a timely response.

Related Articles

© PEAKHOUR.IO PTY LTD 2025   ABN 76 619 930 826    All rights reserved.