OWASP API Security Top 10 and Beyond!

Introduction to OWASP API Security Top 10

What is OWASP API Security Top 10?

  • Open Web Application Security Project (OWASP) - a non-profit organization help to improve application security, launched in 2001

  • OWASP API Security Top 10 - launched because of rapid gap in API security and almost applications uses API, compiled from news, breaches, API incidents, bug bounty platforms and mapped to external sources (CWE and NIST)

Updates to the API Security Top 10

  • Risk Ratings - based on OWASP rating methodology, these factors could significantly affect overall likelihood of an attacker finding and exploiting a particular vulnerability and does not impact the actual business

Risk Ratings

Formula: Risk = Likelihood * Impact

API1:2023 Broken Object Level Authorization

BOLA

  • BOLA - occurs when an API provider does not have sufficient control in place to enforce authorization, API users should only have access to sensitive resources that belong to them, if BOLA is present, the hackers can now have access to other users' sensitive data.

Attack Vector Description
Security Weakness Description
Impacts Description
  • In BOLA User A can obtain User B's resources

via API
BOLA Example
BOLA Test

API2:2023 Broken Authentication

Broken Authentication

  • Broken Authentication - refers to weakness within the API authentication process, all API that serves sensitive data needs a mechanism to authenticate users

  • Authentication - process that is used to verify the identity of an API user, process done with the use of username and password combination, token and MFA

Attack Vector Description
Security Weakness Description
Impacts Description
  • Weak Password Policy

    • Allows simple passwords

    • Allows brute force attempts against users

    • Allows change of password without asking password confirmation

    • Allows change of email without asking password confirmation

    • Discloses token or password in URL

    • GraphQL queries allows many authentication requests in single request

    • Lacking authentication for sensitive requests

  • Credentials Stuffing - one of authentication attacks

    • Attack using number of username and password combinations

    • Credentials used in this attack are collected from data breaches

    • Allows bruteforce of many username and password combinations

  • Predictable Tokens

    • Tokens obtained through a weak token generation authentication process

    • Weak tokens can be easily guessed, deduced, or calculated by an attacker

    • Using incremental or guessable token IDs

  • Misconfigured JSON Web Tokens

    • JWTs commonly used for API authentication and authorization

    • Provides flexibility to customize algorithms used for signing the token, the key/secret that is used, and the information used in the payload

    • Security Misconfigurations:

      • API provider accepts unsigned JWT tokens

      • API provider does not check JWT expiration

      • API provider sensitive information within encoded JWT payload

      • JWT is signed with a weak key

  • API Authentication

    • REST requires APIs to be stateless

    • APIs, therefore, require users to register to acquire tokens

    • Token is used for future requests

  • Issues with Authentication

    • Insufficient token randomness (entropy)

    • Vulnerabilities in registration process

    • Password reset process

    • MFA features

  • OWASP Preventative Measures

    • Know all about possible flows to authenticate to the API

    • Understand your authentication mechanisms and how they are used - OAuth is not authentication, and neither the API keys

    • Use standards for authentication, token generation, or password storage

    • Treat credential recovery/forgot password endpoints as login endpoints in terms of brute force, rate limiting, and lockout protections

    • Require re-authentication for sensitive operations (e.g., changing the account owner email address/2FA phone number)

    • Use the OWASP Authentication cheatsheet

    • Implement MFA, where possible

    • Implement anti-brute force mechanisms to mitigate credential stuffing, dictionary attacks, and brute force attacks

    • Implement account lockout/captcha mechanisms to prevent brute force attacks against specific users

    • Implement weak-password checks

    • API keys should not be used for user authentication - they should only be used for API clients authentication

API3:2023 Broken Object Property Level Authorization

Broken Object Property Level Authorization

  • BOPLA - combination of 2 items, excessive data exposure and mass assignment

  • Excessive Data Exposure - when API provider responds to a request with an entire data object

  • Mass Assignment - weakness that allows for user input to alter sensitive object

BOPLA
Attack Vector Description
Security Weakness Description
Impacts Description

API4:2023 Unrestricted Resource Consumption

Unrestricted Resource Consumption

  • Unrestricted Resource Consumption - an API issue where the provider of the API does not have safeguards in place to prevent excessive use of their API

Attack Vector Description
Security Weakness Description
Impacts Description

API5:2023 Broken Function Level Authorization

Broken Function Level Authorization

  • Broken Function Level Authorization - where API functions has insufficient access controls, and also about altering and deleting data

BOLA vs BFLA
Attack Vector Description
Secutrity Weakness Description
Impacts Description
  • BFLA Vulnerability

    • User can use functionality of another user

    • API provider cam have different privilege levels

      • Public users, merchants, partners, vendors, admins

    • Can be exploited for:

      • Unauthorized use of lateral functions

      • Privilege escalation

    • Targeted API functions-endpoints with:

      • Sensitive info

      • Resources that belong to another group

      • Account management

    • Different endpoints for privileged actions

      • /{userid}/account/balance - user account info

      • /admin/account/{userid} - administrator endpoint

    • Admin endpoint can be exploited if API has improper access controls

      • An admin can perform admin actions, account takeover

    • APIs don't always have admin endpoints

      • HTTP request methods can control access to functionality

      • E.g., GET, POST, PUT, and DELETE

    • Attack can exploit unrestricted methods to exploit API functionality

  • Testing for BFLA

    • Identify endpoints an attacker could use to their advantage

      • Altering user accounts

      • Deleting user resources

      • Gaining access to restricted endpoints

  • Here a DELETE method used in place of PUT, response: "This is an admin function. Try to access the admin API."

DELETE function
  • Attacker could target admin path with DELETE: /identify/api/v2/admin/videos/758, the admin path/method does not have authorization controls, this is a BFLA vulnerability

Admin DELETE function
  • OWASP Preventative Measures

    • Have easy-to-analyze authorization module for all business functions

    • Deny all access by default, require explicit grants to each roles to every functions

    • Review functions against function level authorization flaws

    • Ensure admin controllers inherit from an administrative abstract controller that implements authorization checks based on the user's group/role

    • Ensure admin functions inside a regular controller implement authorization checks based on the user's group/role

API6:2023 Unrestricted Access to Sensitive Business Flows

Unrestricted Access to Sensitive Business Flows

  • Unrestricted Access to Sensitive Business Flows - represents the risk of an attacker being able to identify and exploit API-driven workflow

Attack Vector Description
Security Weakness Description
Impacts Description
Sensitive Flow
  • OWASP Preventative Measures

    • Mitigation done in 2 layers:

      • Business - identify business flows that might harm the business if they are excessively used

      • Engineering - choose the right protection mechanisms to mitigate the business risk

    • Slow down automated threats

      • Device fingerprinting: deny service to unexpected client devices

      • Human detection: use captcha or advanced biometric solutions

      • Non-human patterns: analyze trafiice to detect non-human patterns

      • Consider blocking IP address of Tor exit nodes, well-known proxies

    • Secure and limit access to APIs consumed directly by machines

API7:2023 Server Side Request Forgery

SSRF

  • SSRF - vulnerability that takes place when a user is able to control the remote resources retrieved by an application

Attack Vector Description
Security Weakness Description
Impacts Description
  • SSRF Summary

    • App retrieves remote resources without input validation

    • Attacker can control what resources a server requests

    • Allows attackers to access sensitive data, compromise host

    • Attacker leverages target server to process their requests

    • SSRF bug bounty payouts based on level of impact

SSRF Types
In-Band SSRF
Out-og-Band SSRF

API8:2023 Security Misconfiguration

Security Misconfiguration

  • Security Misconfiguration - all host APIs that is misconfigured can be detrimental to the CIA of the provider

Attack Vector Description
Security Weakness Description
Impacts Description

API9:2023 Improper Inventory Management

Improper Inventory Management

  • Improper Inventory Management - represents the risks involved with exposing non-production and unsupported API versions

Attack Vector Description
Security Weakness Description
Impacts Description
  • Summary

    • Exposes unsupported APIs

    • Old API versions are more likely to contain vulnerabilities

    • Can lead to other vulnerabilities

      • Excessive data exposure, info disclosure, mass assignment, improper rate-limiting, API injection

  • Detecting Improper Inventory

    • Test with outdated API documentation, changelogs and version history on repositories

    • Version information: /v1/, /v2/, /v3/

    • APIs in development paths: /alpha/, /beta/, /test/, /uat/, /demo/

  • Discovering Improper Inventory

    • Techniques: guessing, fuzzing, or brute force requests

    • Testing focuses on unsupported and non-production API versions

    • Typical new version paths

      • api.target.com/v3

      • /api/v2/accounts

      • /api/v3/accounts

      • /v2/accounts

    • API versioning could be also maintained as header:

      • Accept: version=2

      • Accept: api-version=3

    • Versioning can be set within query parameter or request body

      • /api/accounts?ver=2

  • Non-production API versions example:

    • api.test.target.com

    • api.uat.target.com

    • beta.api.com

    • /api/private

    • /api/partner

    • /api/test

  • OWASP Preventative Measures

    • Inventory, document all API hosts and the API versions

    • Inventory, document integrated services - role, data flow, sensitivity

    • Document API details: authentication, errors, redirects, rate limiting, CORS, endpoints (parameters, requests and responses)

    • Auto-generate documentation, and include in CI/CD

    • Make API documentation available to authorized consumers

    • User external API protection firewalls for all versions, not just the current

    • Avoid using production data with non-production API deployments

    • Perform risk analysis when publishing newer versions of APIs

API10:2023 Unsafe Consumption of APIs

Unsafe Consumption of APIs

  • Unsafe Consumption of APIs - trust issues, when an app is consuming the data of third-party APIs it should treat those with a similar trust to user input

Attack Vector Description
Security Weakness Description
Impacts Description

Beyond the Top 10

Injection

  • Injection - when attacker is able to send commands that are executed by the systems that support web app, SQLi, XSS, Command Injection

Attack Vector Description
Security Weakness Description
Impacts Description

Insufficient Logging and Monitoring

  • Insufficient Logging and Monitoring - in order to detect attack we need a monitoring mechanism in place

Attack Vector Description
Security Weakness Description
Impacts Description

Business Logic Flaws

  • Business Logic Flaws - weaknesses within app that are unique to the policies and features of a given API provider

Attack Vector Description
Security Weakness Description
Impacts Description
  • Summary

    • BLF - are misuse/abuse of intended app functionality

    • Example, an API allows only upload certain encoded payloads

      • But does not validate encoded payloads

      • Allowing user upload any encoded file

      • Users to upload and execute arbitrary code

    • BLF come from assumption of API consumers will follow directions and only use API in certain way

    • Orgs rely so much in access control, expecting users acts normally

    • Even good-natured API consumers makes mistakes

  • BLF Example:

    • Experian API leak

    • Experian partner authorized to use their API to perform credit checks

    • Partner added the API's credit check functionality to their web app

    • Exposed all partner-level requests to users

    • Request could be intercepted, Experian API would respond with credit scores

    • Experian trusted the partner not to expose API

    • Credentials constantly leaked and stolen

    • Logic vulnerabilities have impact

    • Examine API documentation for signs of business logic vulnerabilities

      • Statements like:

        • "Only use feature X, to perform function Y"

        • "Do not do X with endpoint Y"

        • "Only admins should perform request X"

    • These statements may indicate reliance on trust

    • Attacker will disobey such requests and to test for technical security controls

  • Bypassing Web UIs

    • Cannot assume users will exclusively use a browser

    • Attacker can easily intercept requests and alter API request

    • This could allow attackers to capture share API keys or abuse parameters

    • Attackers could bypass MFA by altering the parameter

Manipulating request
  • Preventative Measures

    • Use a threat modelling approach

    • Reduce or remove trust relationships

    • Train developers to avoid BLF

    • Implement a bug bounty program, third-party pentesting or a responsible disclosure policy

Last updated