🔐 Mastering API Security — API4:2023 — Unrestricted Resource Consumption / Execution timeouts

Senad Cavkusic
3 min readMay 19, 2024

--

Execution timeouts

When discussing API security, the spotlight often falls on vulnerabilities like Broken Object Level Authorization (BOLA), Excessive Data Exposure (EDE), or Broken Function Level Authorization (BFLA). However, another critical issue that frequently gets overlooked is API4:2023 — Unrestricted Resource Consumption.

Resource consumption

The Challenge of Unrestricted Resource Consumption

Unrestricted resource consumption is a formidable challenge in API security. This vulnerability can debilitate APIs, leading to service disruptions and system instability. It is imperative for organizations to implement robust measures to mitigate this threat.

Understanding Execution Timeouts

To address unrestricted resource consumption, one must understand the concept of execution timeouts.

The Importance of Execution Timeouts in API Security

Execution timeouts are pivotal in ensuring that APIs do not become a gateway for attacks leading to service disruptions or system outages. Execution timeouts refer to the maximum duration an API call is allowed to process before being forcibly terminated. This mechanism is essential for preventing operations from hanging indefinitely, which can consume excessive system resources such as CPU and memory, leading to performance degradation and service unavailability.

The Risks of No Execution Timeouts

Without execution timeouts, any API request can potentially run indefinitely. This not only impacts the server’s ability to handle other requests but can also lead to resource exhaustion. By implementing timeouts, organizations can ensure that their systems remain responsive and stable.

APIs without well-defined timeouts are particularly susceptible to Denial of Service (DoS) attacks. In these scenarios, malicious actors send requests designed to engage the API for the longest possible times. This can be especially damaging if the API performs complex, resource-intensive operations.

Real-World Scenario: E-commerce API

Consider an e-commerce API handling customer transactions. One significant risk is a transaction that stalls during the payment or order processing phase. This can occur due to various reasons such as network delays, payment gateway issues, or backend malfunctions.

When a transaction stalls, it typically holds onto the resources it has engaged — most critically, the inventory items being purchased. For instance, if a customer attempts to buy the last unit of a popular item and the transaction stalls after reducing the inventory but before finalizing the payment, that item remains unavailable to other customers. This situation can lead to lost sales opportunities and a poor user experience, as the product appears out of stock when, in fact, it’s tied up in an incomplete transaction.

Keys to Effective Timeout Management

To effectively manage execution timeouts, organizations should focus on the following strategies:

  • Timeout Implementation — Define and implement appropriate timeout values for different API operations based on their complexity and resource consumption. Each API endpoint might require different timeout settings depending on the nature of the operation it performs.
  • Monitoring and Alerts — Continuously monitor API performance and timeout occurrences. Set up alerts to identify potential issues proactively. Monitoring helps in understanding normal API behavior and identifying anomalies that could indicate an attack or a system malfunction.
  • Graceful Handling and Rollback Mechanism — Implement mechanisms to gracefully handle and rollback incomplete transactions or operations when a timeout occurs. This ensures that resources are freed up and the system remains stable. For example, if a transaction times out, the system should automatically reverse any changes made up to that point, ensuring data consistency and freeing up locked resources.
Execution timeouts

Conclusion

By addressing the challenge of unrestricted resource consumption through well-defined execution timeouts, organizations can significantly enhance their API security posture. This not only prevents service disruptions and system instability but also ensures robust and reliable service delivery. In the next posts, I will dive deeper into additional strategies and real-world examples to further mitigate this critical vulnerability. Stay tuned!

Stay informed and stay safe!

--

--

Senad Cavkusic
Senad Cavkusic

Written by Senad Cavkusic

Master of Cyber Security | Senior Security Researcher | CEH | CPT | CDFE | Certified ISO 27001 Lead Implementer | Developer | linkedin.com/in/senad-cavkusic

No responses yet