Skip to main content

The latest trends in API attacks for 2024 reveal an evolving threat landscape driven by the increasing reliance on APIs and advancements in attacker capabilities. Here are some notable types of API attacks and trends:

  1. BOLA (Broken Object Level Authorization): Attackers exploit API endpoints to access unauthorized data by manipulating object identifiers in API requests. This is one of the most common vulnerabilities, as it targets weak authorization mechanisms ​Imperva.
  2. Bots-as-a-Service (BaaS): Advanced bots are now used to automate large-scale API attacks. These bots circumvent security measures like rate-limiting, CAPTCHA, and WAFs using techniques such as proxy rotation and fingerprint forging. This has made sophisticated API attacks more accessible to less experienced attackers​ securityWeek.
  3. Injection Attacks: These involve injecting malicious payloads into API inputs, such as SQL, XML, or JSON injection. These attacks exploit poorly sanitized inputs to execute unauthorized commands or retrieve sensitive data​ ImpervaSecurityWeek.
  4. Exploitation of API Misconfigurations: Misconfigured APIs, such as those with overly permissive CORS settings or exposed API keys, are prime targets for attackers. These issues often arise from rushed deployments or insufficient testing​ Imperva.
  5. Automated Threats through AI: AI and machine learning tools are being weaponized to identify and exploit vulnerabilities at scale. Attackers use AI to automate reconnaissance and craft highly targeted attacks against API endpoints ​SecurityWeek.
  6. Insufficient Rate Limiting: APIs without proper rate limiting are prone to abuse through brute force attacks or scraping, which can lead to data breaches or service disruptions ​ImpervaSecurityWeek.
  7. Shadow APIs: These are undocumented or forgotten APIs that are unintentionally left exposed, providing an attack vector for exploitation ​Imperva.
  8. Mass Assignment Attacks: Attackers exploit API endpoints that blindly accept and process user-supplied data, enabling them to modify fields they shouldn’t have access to ​Imperva.

To better understand API attacks, let’s explore one specific vulnerability: Broken Object Level Authorization (BOLA). This type of attack is common due to APIs frequently exposing object IDs. Attackers manipulate these IDs to access unauthorized data.

How BOLA Works with Code Example

Consider an API that retrieves user profile data:

API Endpoint:

sqlCopy codeGET /api/user/{userId}

Expected Behavior:

When a user logs in, their user ID is validated, and the API fetches their data.

Example Request:

httpCopy codeGET /api/user/12345 HTTP/1.1

Host: example.com

Authorization: Bearer valid_token_for_user_12345

The server responds with:

jsonCopy code{

  “userId”: “12345”,

  “name”: “John Doe”,

  “email”: “john.doe@example.com”

}

Attack Propagation:

If the API lacks proper authorization checks, an attacker can modify the userId parameter to access data belonging to other users.

Malicious Request:

httpCopy codeGET /api/user/67890 HTTP/1.1

Host: example.com

Authorization: Bearer valid_token_for_user_12345

If the API does not verify that the token belongs to userId: 67890, it leaks unauthorized data:

jsonCopy code{
  “userId”: “67890”,
  “name”: “Jane Smith”,
  “email”: “jane.smith@example.com”
}

To illustrate how Broken Object Level Authorization (BOLA) vulnerabilities can be exploited using code examples, let’s take a deeper look at a real-world scenario in Kenya. We’ll use M-Pesa, Kenya Power, and the Kenyan banking sector to understand the dynamics of such attacks, demonstrating with code examples how attackers could exploit these vulnerabilities.

Example 1: M-Pesa API Vulnerability
Scenario:
M-Pesa API endpoints might fail to properly authenticate a user’s request, allowing attackers to manipulate the request URL and access another user’s transaction data. This is a classic case of Broken Object Level Authorization (BOLA).

Code Example:
python
Copy code
import requests

# Assume user A (Alfred Kinoti) is logged in, and has an API token
api_token = ‘Bearer token_for_alfred_kinoti’

# API URL that fetches transaction history for a user by userID
url = “https://api.m-pesa.co.ke/v1/transactions/”

# Alfred Kinoti’s correct user ID is 12345, but attacker changes it
user_id = “67890”  # Attacker uses another user ID

# Attack request
headers = {“Authorization”: api_token}
response = requests.get(url + user_id, headers=headers)

# Response data (potentially unauthorized)
print(response.json())
In this example, Alfred Kinoti is the legitimate user, but the attacker modifies the user_id in the URL to fetch another user’s transaction history. If the API does not check that the user’s token matches the user_id, it will respond with data that the attacker is not authorized to see.

Impact:
If this vulnerability were exploited, it could lead to the exposure of transaction histories, account balances, and other sensitive information, which could be used for financial fraud or identity theft.

Example 2: Kenya Power API Exposure
Scenario:
Kenya Power’s API allows customers to view billing information. However, if authorization checks are not strictly enforced, an attacker could manipulate the API request to retrieve data from another customer’s account.

Code Example:
python
Copy code
import requests

# Assume the API uses a token for authorization
token = “Bearer valid_token_for_customer_alfred”

# URL endpoint for accessing customer account data
url = “https://api.kenyapower.co.ke/v1/customer/”

# Correct user ID for Alfred Kinoti
user_id = “12345”  # Alfred’s user ID

# Attacker tries to access Jane Smith’s account by changing the user_id
attacker_user_id = “67890”

# Malicious request by the attacker
headers = {“Authorization”: token}
response = requests.get(url + attacker_user_id, headers=headers)

# If the API doesn’t validate the token for the user, it may return Jane Smith’s data
print(response.json())
In this case, the attacker can change the user_id to another customer’s ID, such as Jane Smith, and if the API doesn’t properly authenticate the request, it will expose Jane’s data.

Impact:
Such an attack could expose customer details, including account numbers, billing history, and personal contact information.

Example 3: Kenyan Banking Sector API Breach
Scenario:
A bank’s mobile app has a vulnerable API endpoint that allows users to view their financial details. However, if the system does not verify that the authenticated user has permission to access a particular account, an attacker could manipulate the request to view sensitive data from other customers.

Code Example:
python
Copy code
import requests

# Example API URL for retrieving financial details
url = “https://api.kenyanbank.co.ke/v1/accounts/”

# Assume user “Alfred Kinoti” has a valid token
token = “Bearer valid_token_for_alfred_kinoti”

# Attacker changes the user ID to access another user’s financial information
attacker_user_id = “67890”  # A different customer’s account number

# Malicious API request by the attacker
headers = {“Authorization”: token}
response = requests.get(url + attacker_user_id, headers=headers)

# If the API does not enforce strict authorization, it may return unauthorized account details
print(response.json())
If the API fails to perform proper access control, the attacker can retrieve sensitive account data from another user’s account, including bank balances, transaction history, and credit card details.

Propagation of the Attack:
Exploiting the Vulnerability: Attackers can easily manipulate the user_id or other object identifiers within the API request to access unauthorized data. This is because the API does not verify that the request is being made by the rightful user of the data.

Escalation: Once an attacker accesses one user’s data, they can repeat the process with different IDs to access more accounts. In the case of M-Pesa or a banking API, they could retrieve transaction histories, reroute funds, or even initiate fraudulent transactions.

Mass Exploitation: In large-scale attacks, once an attacker has figured out how to bypass authorization checks, they can use automated scripts to target thousands or millions of users’ accounts, leading to widespread data breaches and financial theft.

How Kenya Can Address These Vulnerabilities:
Strong Access Control:

Role-Based Access Control (RBAC): Ensure that users are only allowed to access their own data. Each request should include not only an authentication token but also a check that ensures the authenticated user matches the user ID or resource ID in the API request.
API Authorization Checks:

Implement Object-Level Authorization: For each API call, validate that the user’s permissions allow them to access the specific object (e.g., user profile or financial data). The server should reject any requests where the user is not authorized for the requested resource.
Secure API Design:

Ensure that API endpoints are not exposed unnecessarily, and sensitive data is encrypted in transit using protocols like HTTPS.
Logging and Monitoring:

Continuous logging and monitoring can help identify suspicious patterns, such as repeated attempts to access unauthorized resources. Prompt alerts can help mitigate attacks in real-time.

Mitigation Strategies

  • Implement strong authentication and authorization mechanisms.
  • Regularly audit and document all APIs, including shadow APIs.
  • Apply rate limiting and use anomaly detection systems.
  • Use API gateways for centralized management and monitoring.
  • Employ AI-driven tools for proactive vulnerability identification ​Imperva SecurityWeek.

These trends emphasize the need for robust API security measures to address both existing vulnerabilities and emerging threats.

Conclusion
BOLA vulnerabilities can have catastrophic effects, particularly in sensitive areas like banking, mobile money systems, and utilities like Kenya Power. Attackers can exploit such vulnerabilities to access private and financial information, potentially causing significant damage. To prevent such attacks, developers need to implement strong authorization checks and regularly audit APIs for security gaps.