TheOpen Web Application Security Project(OWASP) published its first OWASP API Security Top 10 list in December 2019, and since then, theAPI security community has grown rapidly, with API security start-ups attracting significant investment and increasing interest from developers and security practitioners alike to learn resources on the topic. Unfortunately, during this period, there has also been a marked rise in the number of security incidents relating to insecure APIs. Recent analysis suggests a 681% rise in API attacks and that nearly one in two organizations has experienced a security incident relatedto APIs.
In a way,APIs are a victim of their own success– becauseof their rapid proliferation and the high economic value of the data they protect, they are now the most popular targetfor attackers.
We’ll now have a look at the so-called API economy and how the near-exponential growth in the number of APIs creates challenges for organizations as they become the favorite vectorfor attackers.
The growth of the API economy
To fully appreciate the importance of API security, let us first consider the growth of the so-called API economy. Let’s understand a bit more about what is meant by this term – Forbes defines an API economy as “an enabler for turning a business or organization into a platform.” A platform can leverage APIs to dothe following:
- Provide services and data to consumers fora price
- Consume services and data from other providers to enhanceyour business
What is the API economy?
The API revolution has led to the emergence of API-first businesses such as Twilio and has allowed other organizations to expose their core offerings via APIs (Google Maps is a good example). The disruptive nature of theAPI economy is best seen in the financial services industry – typically, this has been an industry resistant to innovation due to regulatory and compliance requirements. By using APIs to expose selected core services, banks can embrace new models without disrupting their core IT systems. By adopting open standards that can be certified – such as theOpen Banking API– banks can achieve interoperability while ensuring transactional integrity. The online money transfer service Wise uses APIs to provide B2B and B2C services and offersbanking-as-a-service(BaaS) to thirdparties by renting outtheir APIs.
Advantages of an API economy
There are several key benefits to anAPI economy:
- Reduced time-to-market: Organizations can use APIs to consume services from third parties rather than having to create those services themselves, resulting in faster developmentlife cycles.
- Drive value: Organizations can expose new and innovative services using APIs and opennew markets.
- Competitive advantage: By getting to market faster and using APIs to drive innovation, adopters can increase theircompetitive advantage.
- Improved efficiency: APIs allow IT teams to deliver immediate value by exposing APIs, rather than having to build and deploy mobile orweb applications.
- Security: Mobile and web applications expose a vast attack surface to adversaries. By focusing development on APIs, this attack surface can be reduced and focusgiven to the hardening and security ofthese APIs.
API adoption allows organizations to deliver more value and functionality while simultaneously reducing cost and timeto market.
The scale of the API economy
It is difficultto provide an accurate estimation of the scale of an API economy, and even if it was possible, this estimate would soon be invalidated due to the nearly exponential growth of the space. TheAPI community at Nordic APIs (https://nordicapis.com/20-impressive-api-economy-statistics/) has produced a survey on the scale of the API economy; the following are someheadline figures:
- Over90%of developersuse APIs
- The popular API test platform Postman has over46 millionAPI collections
- 83%of all internet traffic belongsto APIs
- There are over2 millionAPIGitHub repositories
- The API management market is valued at$5.1 billionin 2023
- 93%of communication service providers useOpenAPI specifications
- 91%of organizations have had an APIsecurity incident
On the back of a growing API economy, major capital investment has poured into the market for API tool vendors, management platforms, andsecurity tools.
Challenges to an API economy
The rapid adoption of APIs brings with it several challenges in addition to the benefits. The first challenge is that of inventory — because APIs can be easily built and deployed and have a finite lifetime, organizations are struggling to keep track of their API inventory, resulting in shadow (hidden) and zombie (outdated) APIs.
The second challenge is that of governance — as APIs proliferate, organizations face challenges with governing the development and deployment process, ensuring that data and privacy requirements are met and that the API life cycle is managed from cradleto grave.
The biggest challenge, however, is that of security. As noted earlier in this section, APIs can reduce an organization’s overall attack surface; however, this comes at the cost of a new security paradigm – APIs are a new attack surface, and the threats are different. In the next section, we’ll explore these security challenges inmore detail.
APIs are popular with developers
Developers love APIs — nearly all developers work with APIs and nearly all modern architectures are API-centric. While containerization has driven the breakdown of the monolith and the emergence of microservices, it is APIs that form the connecting tissue betweenthese services.
The benefit of APIs to developers are numerous, includingthe following:
- They form an abstraction between services and allow encapsulationof functionality.
- They define a clear interface via an OpenAPI specification that serves as a contract forthe API.
- They allow a truly polyglot environment where different APIs can be implemented in the most suitable programming language for the taskat hand.
- They simplify data exchange as APIs generally use JSON, XML,or YAML.
- They facilitate ease of testing, using tools such as Postman or tools that can validate API functionality against theOpenAPI Specification.
- They propel ease of development. The API development ecosystem is rich with powerful tooling for the development and testing of APIs. Moreover, fully featured APIframeworks exist for most modernprogramming languages.
These factors have fueled theAPI-firstparadigm where applications are built in a bottom-up approach, starting with the APIs, then thebusiness logic, and theuser interface(UI) last.
APIs are increasingly popular with attackers
While APIs are undoubtedly popular with developers, they are even more popular with attackers. Gartner reports that APIs are the number one attack vector for cybercriminals in 2022, and barely a week goes by without an API breach or vulnerabilitybeing disclosed.
There are several key reasons why APIsare a favoredattack target:
- APIs are likely to be publicly accessible: By their nature, APIs are intended to be interconnected with other systems, requiring them to be exposed on public networks. This facilitates easy discovery and attackby adversaries.
- APIs are often well documented: To aid easy adoption and integration, good APIs should be documented using tools such as theSwagger UI. Unfortunately, such documentation can also be invaluable to attackers in understanding how theAPIs work.
- API attacks can be automated: API interaction isheadless(not requiring a UI or human interaction) and can easily be automated with scripts or dedicated attack tools. APIs are, in many cases, easier to attack than mobile orweb applications.
- APIs expose valuable data: Most importantly, APIs are designed to allow access to key data assets (PII, financial, or market data), which are likely to be the highest prize for an attacker. Attackers increasingly attack APIs that inadvertently expose excessive data or allow mass exfiltration, which might not be the case with awell-crafted UI.
Your existing tools do not work well for APIs
The relatively recent emergence of APIs as the de facto conduit for application connectivity poses significant challenges to security teams and testers. Much of the existingapplication security(AppSec) toolingthat exists was designed in an era when web applications were the primary asset to be protected. Commonsecurity tools such asstatic application security testing(SAST),dynamic application security testing(DAST), andsoftware composition analysis(SCA) are far less effective in assessing APIs than they are with web ormobile applications.
Traditional perimeter protections such as network firewalls orweb application firewalls(WAFs) are ineffective in protecting APIs, since they lack the context of the API interface and the expected request and response traffic. Such tools tend to be high in both false positives andfalse negatives.
More modern API technologies, suchasAPI management portals(APIMs) and gateways, are essential for the operation of APIs at scale, but while they do provide security features, they do not address allattack vectors.
The key takeaway is that while tools are important as part of a defense strategy, they need to be augmented by solid defensive design and coding techniques — this is the focus of the final section ofthis book.
Developers often lack an understanding of API security
It is important to understand why insecure code exists in the first place if we want to addressthe problem.
Developers are, by nature, creative problem solvers who thrive on a challenge – unfortunately, this leads them to beover-optimistic, which can lead them to take shortcuts and optimizations, or perhaps work to unrealistic delivery schedules. This is so-calledhappy pathcoding, wheredevelopers do not fully appreciate how their code could fail or be misused by an attacker, sometimes withdire consequences.
Coupled with over-optimism is a sense ofover-confidence– developers will assume they fully understand a problem but may be unaware that they are missing some crucial detail or subtlety, which again can have adverse effects. An example is the adoption of a new API framework and not carefully considering the default settings and deploying avulnerable product.
Developers will often have a misplaced sense that bad things only happen to other people and not them. Despite witnessing examples of well-known breaches, many developers believe they will never fall victim to a similar misfortune. This general phenomenon is known as theschadenfreude effect.
The development process can be stressful with constant pressure to deliver to schedule, and this can result in compromising full implementation in favor of meeting deadlines. For example, this can include the omission of error handling code or data validation with the intent of coming back to implement them in later releases. With time pressures, this rarely happens, and code is often left in anincomplete state.
Often, developers inherit a code base to maintain that may contain significanttechnical debt or legacy code. Without a full understanding of the system and its complexities and foibles, developers may be disinclined to make changes to the code base in case theybreak functionality.