Parasoft Logo

Discover TÜV-certified GoogleTest with Agentic AI for C/C++ testing!
Get the Details »

Geometric background with hints of blue and green
Guide to API Security whitepaper cover image

Whitepaper

Guide to API Security

Curious what’s in the guide? Start with the preview below.

Jump to Section

Why APIs Are an Attractive Attack Vector

Today’s adversaries are goal oriented, whether that goal is stealing trade secrets, personal information on consumers, or harming a business through a denial-of-service attack. Finding zero-day vulnerabilities and attacking custom applications is hard. A simpler attack vector is always preferred, whether that’s attacking a supplier in a supply chain with poor software security practices, tricking a user into revealing insider credentials, or exploiting a known vulnerability in a common open source software component.

APIs represent over 80% of all web traffic and offer attackers similar attack techniques as vulnerable open source software.

  • Like open source software, most organizations lack visibility to all the APIs they use and context about how the APIs are used. API use has increased greatly over the past 10 years, driven by the adoption of microservices to simplify and accelerate software development. According to a study by Ping Identity, 25% of the companies surveyed have over 1,000 APIs, while 35% report having between 400–1,000 APIs. More worrisome, 51% are unsure if their security team have visibility to all the APIs used in their organization.
  • Like source code in open source software, API documentation may be available to an attacker and can expose an application’s logic and data. Even private APIs can be easily understood if the APIs use insecure methods like HTTP, text-based REST, and SOAP protocols.
  • Known vulnerabilities in open source software and in commonly used public APIs provide a ready-made attack vector for attackers. In 2019, a vulnerability in the Twitter Kit framework API failed to properly validate the api.twitter.com SSL certificate left millions of iOS users vulnerable to man in the middle attacks.

Leaky and Poorly Designed APIs

Often, the problems leading to API-related breaches are not because the attacker (and in some instances security researcher) is particularly clever or diligent. Instead, many of the issues are related to poor design and implementation of the API.

Central tenants of software security are strong authentication/authorization, the principal of least privileges, and data protection, as well as to test for both abuse and misuse cases. Recent security exposures at Clubhouse, John Deere, and Experian are examples that show how basic software security practices were not followed, leading to leaked information on users, customers, and consumers.

"Poorly designed APIs can disrupt businesses and erode confidence in consumers especially when they expose privacy issues."

—Security Solutions Expert at Parasoft

"Poorly designed APIs can disrupt businesses and erode confidence in consumers especially when they expose privacy issues. The Clubhouse API vulnerabilities that allow ghosting, trolling, and eavesdropping are examples of why security must be designed in and follow sound software engineering practices where least privilege is a core building block to eliminate a class of security issues," explains the security solutions expert at Parasoft.

In each case, the security researchers who identified the vulnerabilities simply used the API—as it was designed—to access information on millions of users and/or customers, as well as misuse and abuse the intended functionality in the API. Some of the API designs were open to any user without authentication and provided the ability to look up any (or all) users and download names, addresses, purchases, and other information. These were avoidable errors in the design, implementation, and testing of the APIs.

Technical Challenges Are Significant

A well-designed API requires input from product owners, architects, and security to properly understand abuse and misuse cases to design security in. Using the examples above, authentication controls are critical since the authentication mechanism is exposed to everyone, including an organization’s adversaries.

Authentication controls, therefore, go beyond simply requiring users and systems to authenticate. They include controls to prevent credential stuffing and brute force attacks, weak passwords, revealing sensitive information like auth tokens and weak encryption keys.

Strong authentication controls are only a first step. As noted by the OWASP API Security Top 10, organizations need to also ensure proper authorization at both the object level and function level.

  • Input validation is required to prevent injection flaws.
  • Rate limiting is required to restrict the number of lookups a single user could conduct each minute, hour, or day.
  • Adequate logging and monitoring are required to expose attacks more quickly.

API discovery is essential. Visibility to all APIs is required. One cannot secure something without first knowing it exists. Understanding the attack surface and which APIs are exposed is essential for security testing. API test coverage and discovery are important data points to minimize risk associated with API attacks. As mentioned, the shift from monolithic applications to microservices has greatly increased the number of API in the average organization. This fundamental shift will require organizations to be more proactive in their API discovery and attack surface analysis.

Key Challenges in API Security

Poorly Documented & Undocumented APIs

In best practice, software projects include detailed documentation for internal parties to simplify maintenance and help developers new to a project understand how the application works. Likewise, APIs require documentation for dev using the API, whether internal developers and testers or third parties. In reality, pressure to add features and accelerate time to market often means documentation is limited.

This is especially true with APIs, which are usually simpler and intended for internal use. Without proper internal docs, DevOps engineers have imperfect knowledge on how an API works. Without API contracts, definitions, and specifications, QA and security are left to model the intended behavior of APIs and guess use and misuse cases.

Testers Are Not Trained in Security

Security resources are scarce in most organizations. It’s a growing national issue. QA and DevOps engineering are usually focused on functional testing, ensuring the features listed in the requirements document perform to specifications.

While this includes use cases like throughput and capacity testing, it can miss security tests that often focus on abuse and misuse cases, such as, calling an API with intentionally wrong arguments or not properly handling the values returned by the API.

API Interactions Are Complex

Security and testing are often familiar with use cases for a user interface. API use cases are more complex, in particular between microservices.

While the security issues and exposures previously mentioned above are straightforward, the rapid increase in microservices and resulting APIs complicates security, potentially allowing sophisticated attackers to link multiple APIs in a multistep attack. Access control policies with different hierarchies, groups, and roles can be confusing to defenders and lead to inadequate security controls.

Testing and securing APIs require an understanding of an application’s logic about which security often has less information. APIs are more like Lego blocks that can be assembled in a variety of ways. Adversaries may use APIs in unintended ways—even linking APIs to attack an application—like how many ways can one reach the shopping cart or store payment information?

"APIs are surprisingly flexible. Being able to fully test possible combinations is critical to making sure that your APIs are secure."

—Arthur Hicken, Chief Evangelist at Parasoft

Complete testing requires programmatic visibility to the APIs and their interactions, edge cases, protocols, and knowledge of expected data types. Creating tests is possible with sufficient resources, of course, but this skill has a very steep learning curve.

Complexity in API security testing chart

What Can API Security Testing Do for You?

Traditional Security Testing Tools Struggle

Traditional tools used in traditional ways are only a partial solution. Static analysis tools typically examine source code. While these tools identify some issues with API, they lack knowledge of intended functionality, which limits their completeness.

Dynamic analysis scanners also help, but often only look for entry points in the user interface and may have no awareness of APIs and their functionality.

While it is possible for a skilled pen tester to identify weaknesses in APIs, it scales poorly and isn’t practical from a time and cost standpoint. It’s also incompatible with rapid development methodologies like CI/CD and DevSecOps.

These tools don’t understand API authentication mechanisms and need to be aware of protocols such as OAuth2 and JSON Web Tokens.

They also struggle with content types and HTTP responses that impact how vulnerabilities in APIs are detected. In addition, there are no links these tools can crawl to discover APIs, which fundamentally changes security testing for APIs.

Adopting Best Practices for API Security Testing

Adding API security testing to the software development life cycle is possible, even in rapid development environments, when organizations provide DevOps engineers with the correct tools and support.

Importantly, security testing must consider common design flaws as well as implementation and configuration errors. Building more secure software is not a secret. There are several guidelines and standards organizations can use to identify and mitigate risk.

One, the OWASP Application Security Verification Standards (ASVS), is particularly helpful when considering designing and implementing APIs. ASVS describes itself as "a list of application security requirements or tests that can be used by architects, developers, testers, security professionals, tool vendors, and consumers to define, build, test and verify secure applications."

While achieving ASVS certification is an admirable goal, organizations seeking to incrementally improve their software security programs can use ASVS guidelines in a less formal way.

It Takes More Than Shifting Left

Integrating API security activities early in the software development life cycle is possible, even in rapid development environments, when organizations provide their development teams with the correct tools and support.

Start at the Beginning

Security testing early is essential for preventing and detecting security issues with APIs, but everything starts with a good design. Designing a secure API is not a secret. Among other things, APIs require clear definitions for the parameters allowed by security controls, rate metering to prevent brute force attacks, and enforcement of strong authentication mechanisms to prevent API misuse.

Remediation cost by each stage of the SDLC

The Rising Cost of Delayed Security

Postponing security testing until late in the software development life cycle results in delays and higher development costs. Fixing bugs becomes more expensive in the maintenance phase. The rising costs are due, in large part, to the difficulty of refactoring software to fix bugs or change open source libraries, while maintaining the features and functionality of the original design.

In the ASVS standards, shifting left considers API functionality, authentication, and authorization in the design phase of the life cycle. This entails authenticating communication between application components, including APIs; all components using least privilege principles; encrypting calls to APIs; and API URLs not exposing sensitive information such as session tokens.

Know What to Defend Against

OWASP provides guidance through the OWASP API Top 10, which describes the consensus opinion on the most common and damaging vulnerabilities found in APIs. Many of these are concerned with identity and access management issues, while some like Injection and Logging issues are already used and integrated in most application security testing suites.

A Novel Approach to Comprehensive API Security Testing

A better method for testing APIs is to leverage functional testing to provide visibility to the APIs underlying the application and their functionality, and augment test generation using artificial intelligence (AI) to build appropriate test cases.

"API testing can be surprisingly complex. It requires knowledge of testing, how the APIs are used, and how they could be used in different ways than the user stories. When you add security to the mix, you need even more knowledge because again the API layer is deeper and more technical than the UI layer," explains Arthur Hicken, Chief Evangelist at Parasoft.

"API testing can be surprisingly complex. When you add security to the mix … the API layer is deeper and more technical than the UI layer."

—Arthur Hicken, Chief Evangelist at Parasoft

Parasoft SOAtest’s Smart API Test Generator leverages a browser plugin that uses AI to automatically convert manual and automated UI tests into automated API tests. Instead of simply collecting traffic, recording it, and playing it back, Smart API Test Generator applies AI to discover meaningful patterns, apply threat models, and understand relationships between those API calls. It can then generate automated API test scenarios that perform the same actions as your UI tests but are fully automated and easily extendable.

Smart API Test Generator Benefits

  • Build API security tests without security expertise. Security resources are limited at even the largest organizations, in particular resources with experience in API security testing. SOAtest Smart API Test Generator eliminates barriers to API testing and flattens the learning curve, allowing novice users to build effective, scriptless test suites. No coding required.
  • Augment security team knowledge. SOAtest’s Smart API Test Generator can also be used while security teams are testing applications, further extending the test cases generated.
  • Accelerate testing cycles. Automating the development of API tests means spending less time investigating test cases, looking for patterns, and manually building relationships to form each test scenario. When the UI changes, Smart API Test Generator’s scriptless API tests are easily updated.
  • Scalable API testing. Automatically generated and scriptless API tests using visual tooling and test flow logic allow teams to cover more application logic with less effort, resulting in complete, end-to-end test scenarios.
  • Uncover and test undocumented APIs. By monitoring the interactions between the UI and the underlying APIs, the Smart API Test Generator not only tests the known and OpenAPI documented APIs, but also uncovers and builds tests for the undocumented APIs that were intended only for internal use and escaped your governance process.
  • Leverage dynamic analysis for deeper coverage. Through its integration with Dynamic Analysis tools, SOAtest can guide DAST testing to expose the attack surface of APIs and provide deeper testing coverage that standalone DAST tools can’t reach.
  • Contextual training. Parasoft security solutions provide specific contextual training as well as high-level security training is available directly through the documentation. Training ranges from free to paid and includes video, hands-on, and more.
Team of developers

Ready to dive deeper?

Get Full Whitepaper