API security
Learn how a shift left approach to API security enables teams to catch and remediate API security threats.
What is API security?
API security is the practice of preventing and mitigating attacks that originate at the API level, and it is a crucial pillar of any organization's overall security strategy.
APIs not only enable users to interact with applications, but also facilitate communication between their underlying internal services—many of which transmit or store sensitive data. An insecure API can therefore provide an entry point for attackers and seriously compromise an application's security posture.
In this article, we'll begin by discussing why API-first companies are shifting API security to the left. Then, we'll explore the most common API security vulnerabilities—and how the Postman API Platform can help teams avoid them.
How does a "shift left" approach to API security support the API-first development model?
APIs are the building blocks of modern software, and more and more organizations are focusing on them in order to unlock new features and advance business objectives. This trend is reflected in Postman's 2022 State of the API Report, which finds that 89% of survey respondents expect their investment in APIs to increase or stay the same in the coming year. Respondents also reported a heightened awareness of the importance of API security, with 50% of respondents citing API security as one of their top four priorities, and over 70% of respondents indicating that security plays a significant role in their decision whether to integrate with a third-party API.
Some organizations are addressing API security concerns by prioritizing security at the very beginning of the API lifecycle. This strategy requires teams to plan for potential security issues during the API design process—and to run continuous security checks during development and deployment. This “shift left” approach to security is a hallmark of API-first companies, which develop APIs before building the applications and integrations that depend on them. By focusing on intentional planning, API-first teams are able to iterate faster, address issues sooner, and improve productivity.
What are the most common API security threats and vulnerabilities?
APIs are crucial to the success of modern businesses and have therefore emerged as a primary attack target. The Open Web Application Security Project (OWASP) already maintains a top ten list of general security threats to web applications, but the growing security threat to APIs led OWASP to create a dedicated project to track the top ten most critical API security risks. These two lists address a wide range of vulnerabilities, which can be broken down into the following categories:
Poor security hygiene
This is the most basic category of security vulnerabilities, but it is also one of the most important. Failure to maintain good security hygiene can lead to major breaches that could have easily been prevented. For instance, teams should ensure that their tokens and API keys are not hard-coded or included in their API client libraries' source code, Git history, or documentation. They should also use Transport Layer Security (TLS) to encrypt all API communications, whether the API is delivered as an HTTP-based REST API or a Protobuf-based gRPC API.
Authentication and authorization vulnerabilities
APIs often give users different permissions depending on their role. Authentication and authorization issues therefore pose a significant security threat because they enable users to perform actions and access data that should be restricted.
There are many ways for these issues to enter an API. For instance, organizations might fail to perform method-level authorization checks to confirm that the object being read or written to is within the user's authorization scope. Additionally, if authorization is scoped by API endpoints but individual objects have more granular permissions, there is a risk that improperly-checked permissions could result in access violations (this is related to the following vulnerability: lack of read and write granularity). Teams might also fail to use cryptographic methods, such as public key encryption, in user authentication workflows, which introduces the risk of spoofing.
Lack of read and write granularity
Data objects have many properties—some of which are sensitive, and some of which are not. For example, an instance of a User object may have a username property (which is not sensitive) and a password property (which is sensitive). Sometimes, developers fail to protect sensitive properties on the server side and instead rely on clients to filter them out, which leaves them accessible to malicious parties. This vulnerability is known as excessive data exposure.
Similarly, users should not be able to update internal properties (such as user.id) and permission-related properties (such as user.is_admin). Unfortunately, developers sometimes introduce a mass assignment vulnerability by programming an API to simultaneously assign every piece of data it receives from a client. Instead, developers should implement logic that checks each property and only assigns a new value to properties that can be updated by the user in question.
Failure to implement quotas and throttling
Quotas and throttling are intended to limit the number of requests to a particular service in order to conserve computational resources and ensure high availability. APIs that don't implement quotas or throttling can leave applications vulnerable to brute force attacks, in which an attacker systematically guesses a password in order to gain access, and Denial of Service (DoS) attacks, in which an attacker floods an API with traffic in order to exhaust the resources of a downstream service and take it offline.
Improperly set or missing HTTP headers
When a web client sends an initial request to an API, the response should have appropriate HTTP headers, including security headers. Security headers give the browser instructions for safely interacting with the API. For instance, HTTP Strict Transport Security (HSTS) headers can be used to enforce valid certificates and TLS communication, and Access-Control and Cross-Origin Resource Policy (CORP) headers can prevent a valid client from being misused to perform API requests on behalf of potentially malicious third-parties.
Additionally, improperly set headers, such as the Cache-Control and Vary headers, can result in private data leaking to other API clients if proxies or load balancers are used in front of the web server.
Failure to perform input validation, sanitization, and encoding at the method level
API injection occurs when an attacker sends malicious code through an API, often within a request's parameters or body. This malicious code might be executed on the server side (for example, in a SQL query or during the deserialization of data), or it may be executed on the client side if it gets embedded in HTML content and it was not properly escaped beforehand. This malicious code might then change permissions or database records that should be protected, or even result in arbitrary remote code execution (RCE). It's therefore crucial for developers to leverage Web Application Firewalls (WAFs) and perform input validation, sanitization, and encoding at the method level, which will prevent any malformed or unsafe data from entering the workflow. Libraries like OWASP's ESAPI can help reduce the occurrence of this vulnerability.
Inaccurate inventory and documentation
Teams are often responsible for numerous API artifacts, such as endpoints, versions, and third-party services. But as these artifacts multiply, it becomes increasingly difficult to document and manage them securely. For instance, if a team forgets to retire an old API version, hackers may be able to exploit a vulnerability that was subsequently patched. This issue, which is known as improper assets management, is compounded when teams fail to maintain up-to-date documentation that adequately documents every API asset and its role in the larger system.
Inadequate logging and monitoring practices
Logs record the details of all system activity, so it's important to enable logging for every service and infrastructure component in your environment—including APIs. But even small systems can generate millions of logs a day, making it extremely difficult to identify suspicious activity in a timely manner. Logs may also contain sensitive data, which needs to be handled appropriately to ensure security and compliance. Teams should therefore augment their logging practices with a robust monitoring strategy in order to surface security breaches and sensitive data in their log stream.
Which API security vulnerabilities are most relevant to other types of API architectures?
While REST remains the most popular API architecture, some developers choose to leverage SOAP, GraphQL, WebSockets, or gRPC to support their specific use cases. Each of these architectures has its own security concerns, which we will explore in this section.
What are some best practices for API security?
Every API is different and will therefore have unique security needs. Nevertheless, the following best practices can help you avoid the security vulnerabilities that we discussed above—regardless of your API's type or use case.
Learn more with Postman Academy's API security and governance course
What are some examples of common API security breaches?
API security breaches often follow similar attack patterns, and they can lead to devastating consequences for the business. Some common security breaches include:
Why use Postman for API security?
When developing an API security strategy, it's important to use tools that help you avoid exploitable security vulnerabilities while providing full coverage throughout the API lifecycle. With Postman, you can:
Get started with the Common API vulnerabilities template
Get started with Postman
June 3 & 4, 2025 in Los Angeles, CA
Step into the future of APIs and AI at POST/CON 25. Join developers, architects, and tech leaders to build smarter, faster, and more secure APIs in the age of generative AI.