Api Vulnerabilities and Risks 2024sr004 1
Api Vulnerabilities and Risks 2024sr004 1
June 2024
SPECIAL REPORT
CMU/SEI-2024-SR-004
DOI: 10.1184/R1/25282342
CERT® Division
https://www.sei.cmu.edu
The view, opinions, and/or findings contained in this material are those of the author(s) and should not be con-
strued as an official Government position, policy, or decision, unless designated by other documentation.
[DISTRIBUTION STATEMENT A] This material has been approved for public release and unlimited distribu-
tion. Please see Copyright notice for non-US Government use and distribution.
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Re-
quests for permission for non-licensed uses should be directed to the Software Engineering Institute at per-
[email protected].
DM24-0284
Abstract iii
1 Introduction to APIs 1
1.1 API Endpoints 1
1.2 Microservice Architectures 1
1.3 Common API Risks and Vulnerabilities 2
References/Bibliography 21
Application programming interfaces (APIs) are increasingly common, and they are often designed
and implemented in a way that creates security risks. This report describes 11 common vulnerabil-
ities and 3 risks related to APIs, providing suggestions about how to fix or reduce their impact.
Recommendations include using a standard API documentation process, using automated testing,
and ensuring the security of the identity and access management system.
Application programming interfaces (APIs) have unique risks, especially when these risks are
compared to other types of network security risks. One of the main goals of cybersecurity is to re-
duce the attack surface that malicious actors can use to penetrate a network, but APIs are inten-
tionally designed to be exposed to the public or third parties for use. This means that APIs, by na-
ture, increase the attack surface of a network, and if APIs are not designed correctly, their
availability can lead to significant security issues [Hussain 2022].
From the attacker’s perspective, one of the most time-consuming parts of planning a network at-
tack is the reconnaissance required to find potential network attack vectors. Since APIs must be
exposed to the public, the amount of time the attacker spends finding attack vectors into the API’s
network is greatly reduced, making them an easier target for potential breaches.
Each endpoint serves a different purpose, but they are all connected to the same application. The
following are a few examples of how an API endpoint might be used:
• logins (The necessary inputs for that endpoint are a username and password.)
• password resets (The required input might only be an email, so a password reset link can be
sent.)
• administrators changing application settings (The required input for access might be a
username and password.)
• enabling interaction between microservices (The required inputs might be user IDs or other
user information, product or order information, or whole data structure objects.)
The distributed, loosely coupled design of these microservice architectures allow them to have
greater scalability, flexibility, and continuous deployments when compared to monolithic archi-
tectures. According to National Institute of Standards and Technology (NIST) special publication
(SP) 800-204, “Microservices generally communicate with each other using Application Program-
ming Interfaces (APIs), which require several core features to support complex interactions be-
tween a substantial number of components” [Chandramouli 2019]. There are often support struc-
tures that also help API ecosystems by offering solutions, such as API gateways and service
meshes. This report only discusses APIs, but the use and configuration of supporting structures
(e.g., identity access management [IAM] servers, API gateways, service meshes) are also im-
portant to overall API security.
Furthermore, API architectures come in many variations, each with its own design and security
strengths and weaknesses. Examples include the following:
• The commonly used representational state transfer (REST) API is usually used with JavaS-
cript Object Notation (JSON); it is lightweight and flexible with few security features [Red
Hat 2020].
• The Simple Object Access Protocol (SOAP) uses Extensible Markup Language (XML) and
is much more complex than REST; it has its own web services security (WS-Security) exten-
sion [Singhal 2007].
• The Graph Query Language (GraphQL) is another type of API that was designed to optimize
API queries; it can easily be exploited with simple misconfigurations [Red Hat 2019].
The specific API architecture and configuration a designer uses to create their API will have a
major impact on its security. However, a deep analysis of API architectural design options and
their associated security configurations is beyond the scope of this report.
Risks and vulnerabilities associated with APIs are similar to security risks associated with any
other network. These vulnerabilities include authorization problems, network connectivity issues,
lack of awareness and training for development staff, hardware malfunctions, and Internet-based
attacks associated with poor authentication. While this report could include extensive discussions
about each of these topics, it instead focuses on the risks that are exclusive to or more common in
APIs as compared to non-API connections.
In this section, we describe the top API vulnerabilities and include examples and recommenda-
tions. The first ten vulnerabilities build on the security risks that OWASP describes in its Top 10
API Security Risks—2023 release [OWASP 2023].
OWASP’s Security Risk Ranking. BOLA is number 1 on OWASP’s Top 10 API Security
Risks—2023 [OWASP 2023, API1:2023].
Example. Assume an authenticated user named John Doe enters the following:
localbank.com/access/users?id=110
It returns the response shown below with his account information. The API returns his own record
correctly.
{
“userid”: “110”,
“firstname”: “John”,
“lastname”: “Doe”,
“accountbalance”: “5000.00”
}
Assume that the same authenticated John Doe enters the following:
localbank.com/access/users?id=111
It returns account information for the user associated with id 111, Catherine Ming. See below. In
this case, the API has a BOLA issue because John Doe should not be able to access Catherine
Ming’s information.
{
“userid”: “111”,
“firstname”: “Catherine”,
“lastname”: “Ming”,
“accountbalance”: “11325.16”
}
If an attacker gains authentication on an account that is not theirs, then they can read or alter the
victim’s sensitive data or change the victim’s account settings. Once the attacker gets control of
the account, that access is difficult to detect.
Example. One common type of broken authentication is called credential stuffing. This attack
works by using stolen credentials, often a username and password, and submitting those creden-
tials on another site to break into the rightful user’s account. This type of attack can be successful
because some users reuse the same username and password for multiple sites. Once an attacker
finds a username/password set that grants them access to the API, they not only compromise the
victim’s account, but they now have greater access to the internal network where the API is run-
ning.
Password Policies
1. Require complex, hard-to-guess passwords that contain numbers, symbols, and letters with a
mix of capitalization.
2. Limit the number of authentication attempts in a short time frame to prevent brute-force at-
tacks and credential stuffing.
3. Require email confirmation for password changes.
4. Ensure that URLs do not disclose password information.
5. Ensure that all passwords are stored in hashed text, not plaintext.
Token Policies
1. Ensure that values have enough randomness that they are difficult to guess.
2. Accept tokens for authentication only if they are signed.
3. Set a short expiration time for tokens to prevent their reuse.
OWASP’s Security Risk Ranking. BOPLA is number 3 on OWASP’s Top 10 API Security
Risks—2023 [OWASP 2023, API3:2023].
Example. Assume that the www.university.com/students HTTP/1.1 API GET request re-
turns the following list of names of 2023 graduates from a university.
“students”:
{
{
“firstname”: “Jake”,
“lastname”: “Care”,
“major”: “political science”,
“email”: “[email protected]”,
“address”: “123 Fourth St”,
“birthday”: “04/07/92”
},
{
“firstname”: “Haley”,
“lastname”: “Miles”,
“major”: “civil engineering”,
“email”: “[email protected]”,
“address”: “934 Eighth St”,
“birthday”: “01/17/92”
}
}
The information provided to a user sending a GET request for the graduates should show only the
graduates’ names and possibly their degrees. However, the API request also returns the students’
email addresses, postal addresses, and birthdays. This is sensitive information that should not be
disclosed without authorization.
Failure to implement the following or configuring them incorrectly could lead to an unrestricted
resource consumption vulnerability:
• execution timeouts
• maximum allocatable memory
Example. Assume that the following GraphQL query returns the titles of the two most recently
published New York Times articles:
query getCompany(name: “New York Times”) {
getArticles(last: 2) {
title
}
}
Assume that the following GraphQL query returns the 10,000 most recently published New York
Times articles with the title, author, text, and date of each. (This query is obviously large and
would require a huge number of resources for the API to service, which might slow down servic-
ing for other clients or shut down the API altogether.)
query getCompany(name: “New York Times”) {
getArticles(last: 10000) {
title
author
text
date
}
}
OWASP’s Security Risk Ranking. BFLA is number 5 on OWASP’s Top 10 API Security
Risks—2023 [OWASP 2023, API5:2023].
Example. Assume a school with an online system stores students’ grades in a way that both stu-
dents and teachers can access. Students should be allowed to view their own grades, but only
teachers should be able to modify them. The student API endpoint for accessing their grades is
/viewgrades/, and the endpoint for teachers to alter student grades is /altergrades/. A BFLA
vulnerability is present if, for example, a student named Jimmy logs into their account, types the
following URL, and is able to access the teacher page where student grades can be changed:
www.school.com/altergrades?student=jimmy.
The authorization to use a function that can alter or delete data has been given to a user who
should not have that authorization.
OWASP’s Security Risk Ranking. Unrestricted Access to Sensitive Business Flows is number 6
on OWASP’s Top 10 API Security Risks—2023 [OWASP 2023, API6:2023].
Example. Assume that Company A recently acquired a shipment of 1,000 highly sought gaming
personal computers (PCs). A scalper then sets up a script to automatically buy all 1,000 computers
just as they became available to buy online. The scalper then takes all 1,000 computers and sells
them at a higher price. This attack disrupts the regular business flow by preventing regular cus-
tomers from buying the PCs at the market price.
OWASP’s Security Risk Ranking. SSRF is number 7 on OWASP’s Top 10 API Security
Risks—2023 [OWASP 2023, API7:2023].
There is a wide range of configurations that can be mishandled in during the API design and im-
plementation process from the network level to the application level. These include misconfigured
headers, misconfigured data encryption for data transfers, allowance of HTTP verb tampering, in-
sufficient data validation and sanitation, or overly descriptive error messages.
This kind of default configuration in cross-origin resource sharing (CORS) HTTP headers can en-
able an attacker to fetch and send information to an external location.
Since deployment is easy with microservice architectures, it is now easy to deploy and subse-
quently forget about certain microservices and their associated APIs. Unless the inventory of all
APIs is properly managed in a microservice system, these forgotten APIs will eventually become
outdated and insecure but will remain discoverable by DNS enumeration or other Internet scan-
ning. Often, developers fail to add proper security to microservices and APIs that are in develop-
ment, which also makes pre-production APIs vulnerable. Exploitation of these insecure APIs can
result in sensitive data leaks, server takeovers, and lateral or vertical movement within network
systems.
Exploitation of this vulnerability requires the user to have information about the third-party inte-
grations for the specific API. If a third-party API integrated with the API is compromised, it could
lead to sensitive data leaks, denial of service (DoS), data injections, or other attacks.
Example. As illustrated in Figure 5, assume an API gateway accepts all incoming requests for an
API. When it gets a request from a user, the request goes through a sanitization process to ensure
it does not have any malicious attributes like Structured Query Language (SQL) or cross-site
scripting (XSS) injections. However, when the API gateway gets a request from a third-party API,
it does not do the same sanitation checks and instead simply forwards the request to the backend
Example. Consider an LDAP query. Assume an attacker wants to get all the usernames and pass-
words in an LDAP backend database; they could go to an application’s login page and type the
following:
Username: *)(username=*
Password: *
This query returns all the non-null usernames and passwords in the database, which constitutes a
data leak of sensitive information.
This section describes the top API risks, including recommendations for mitigating them.
Example. Log4J is a critical vulnerability in the Java-based logging library that was discovered in
2022. It allows remote code execution and the complete takeover of the victim machine. Any sys-
tem that has Log4j integrated into its software is vulnerable to attack until the vulnerability is
patched.
Example. As illustrated in Figure 6, assume a Sales Information API must call a Product Descrip-
tion API to complete a client request it receives from the API gateway, but also assume that the
Product Description API goes down. In this case, the Sales Information microservice can no
Monolithic API architectures expose fewer IP-addressable remote procedure calls compared to
microservice architectures [Chandramouli 2019]. The result is that these microservice architec-
tures often have a larger attack surface. There are also many support structures, like the service
discovery mechanism, needed to create a secure microservice system that creates more avenues
for potential compromise if they are tampered with. Microservice architectures are generally more
complex than monolithic architectures, which increases the likelihood of missed checks and mis-
configurations that lead to vulnerabilities [Chandramouli 2019].
APIs are increasingly common, and they are often designed and implemented in a way that cre-
ates security risks. This report summarized 11 common vulnerabilities and 3 risks associated with
APIs and provided recommendations about fixing or reducing their impact. Some of the most
common recommendations include the following:
• having a standard API documentation process
• using automated testing throughout the development process
• ensuring the identity and access management system is secure
Future work could extend the findings in this report to (1) explore integrating zero trust measures
into the design of APIs and the development process and (2) create a set of rules and recommen-
dations for API best practices.
[Chandramouli 2019]
Chandramouli, Ramaswamy. Security Strategies for Microservices-based Application Systems.
NIST SP 800-204. August 2019. https://csrc.nist.gov/pubs/sp/800/204/final
[Green 2016]
Green, Matthew & Smith, Matthew. Developers Are Not the Enemy!: The Need for Usable Secu-
rity APIs. IEEE Security & Privacy. Volume 14. Issue 5. 2016. Pages 40–46. https://ieeex-
plore.ieee.org/abstract/document/7676144
[Hussain 2022]
Hussain, Al Alaa Abdul Al Muhsen; & Ipate, Pro Florentin. Application Programming Interface
(API) Security: Cybersecurity Vulnerabilities Due to the Growing Use of APIs in Digital Commu-
nications. International Research Journal of Innovations in Engineering and Technology. Volume
6. Number 6. 2022. Page 108. https://www.proquest.com/open-
view/34b6b229f88e1cfb944a42b8dfebe934/1?pq-origsite=gscholar&cbl=5314840
[Lercher 2023]
Lercher, Alexander; Glock, Johann; Macho, Christian; & Pinzger, Martin. Microservice API Evo-
lution in Practice: A Study on Strategies and Challenges. Cornell University. August 24, 2023.
https://arxiv.org/pdf/2311.08175.pdf
[OWASP 2023]
Open Worldwide Application Security Project (OWASP). Top 10 API Security Risks—2023.
OWASP Website. 2023. https://owasp.org/API-Security/editions/2023/en/0x00-header/
[Traceable 2023]
Traceable Inc. API Security Reference Architecture for a Zero Trust World. Traceable Website.
2023. https://www.traceable.ai/resources/lp/whitepaper-api-security-reference-architecture
[Wallen 2023]
Wallen, Charles; Alberts, Christopher; Bandor, Michael; & Woody, Carol. Software Bill of Mate-
rials Framework: Leveraging SBOMs for Risk Reduction. Software Engineering Institute, Carne-
gie Mellon University. June 2023. https://insights.sei.cmu.edu/library/software-bill-of-materials-
framework-leveraging-sboms-for-risk-reduction/
17. SECURITY CLASSIFICATION OF 18. SECURITY CLASSIFICATION 19. SECURITY CLASSIFICATION 20. LIMITATION OF
REPORT OF THIS PAGE OF ABSTRACT ABSTRACT
Unclassified Unclassified Unclassified UL
NSN 7540-01-280-5500 Standard Form 298 (Rev. 2-89) Prescribed by ANSI Std. Z39-18 298-102