Engineering
February 6, 2024
11 min read

API Security Risks and How to Mitigate Them

Kong

Today, more organizations than ever before rely on web and mobile applications and partner integrations to help them automate and scale, making APIs essential to today’s software ecosystem. But because APIs are gateways to sensitive data, this also makes them an attractive target for hackers who are constantly evolving their strategies to access private information. 

Organizations must first understand significant API security vulnerabilities to be proactive about protecting their APIs from bad actors. In this post, we’ll go over some of the top security risks to APIs and how to mitigate them so that you can keep your application, information, and users secure from attackers.

What is an API security risk?

An API security risk is a vulnerability that allows attackers to hack into software systems, gain access to sensitive or confidential data, or launch other malicious activities, such as DDoS attacks or injection attacks. API security risks are often the result of poor API design, implementation, or configuration. Risks can also arise from outdated security measures that were valid at the time of implementation but haven’t adapted to new attack vectors.

Unfortunately, because APIs enable interactions between different services, software, and systems, points of access can become vulnerable — and there are even more evolving mechanisms for hackers to enter systems. Let’s look at some methods attackers use to disrupt software systems, manipulate data, and gain unauthorized access to confidential information.

Common API security risks

Broken object-level aAuthorization (BOLA)

Broken object-level authorization (BOLA) occurs when attackers can access other users’ data by sending requests for data objects that should be protected with authorization controls. Unsafe coding practices often make these attacks possible, such as granting access before checking permissions or validating user identities on inputs. BOLA threats are especially dangerous when developers fail to protect API resources and secure access controls.

BOLA threats have raised concern in recent years because there are collections of related data — or objects — on every website or application that developers use to access your information quickly. For instance, if you use an online profile to schedule appointments with your health provider, your “profile object” will contain information like your full name, address, username, and so on — and potentially more sensitive data, such as your diagnosis and insurance details. 

If an attacker gains access to profile objects because of improper authorization controls, they could automate those requests, causing a massive data breach of sensitive information. The growth of APIs has only exacerbated this issue, earning this API security threat the #1 spot on OWASP’s top 10 security risks of 2023.

Broken user authentication

Broken user authentication is a term used to describe authentication vulnerabilities that allow attackers to impersonate users in a website or application. This type of security threat is relegated to session management and credential management because these areas can contain faulty security practices that allow attackers to imitate other users — whether by stealing their login credentials or taking over their user sessions. 

Hackers have a long list of strategies for exploiting broken user authentication, including credential stuffing (using a known list of usernames and passwords to force their way in), unverified API endpoints (targeting endpoints that lack verification with CAPTCHA), and weak password attacks (employing strategic password guesses). 

Though often undermined, broken user authentication hacks are responsible for some of the largest data breaches in history, and development teams should be prepared to face them.

Improper asset management

All deployed API assets need strong technical oversight so they don’t break down over time. Improper asset management occurs when developers expose their deployed assets by losing track of their ownership or neglecting their upkeep.

Improper asset management is a sneaky security threat because it’s constantly happening — without companies being aware of it. APIs will be written by development teams and left undocumented so that, during periods of high turnover, new teams are in the dark about how they were most recently updated or managed. Organizational restructures will leave services lying in fragments managed by different teams. Some APIs will run for years without ownership ever being established at all. 

Even if an API is fulfilling its duty, it may be the ideal target when it stands unsecured and outdated — all it takes is an experienced attacker to spot it.

Excessive data exposure

Developers don’t set out to call attention to an API’s weaknesses, but sometimes, that’s precisely what happens. 

Excessive data exposure refers to when an API responds to a request with additional data that is expected to be filtered or ignored by the user — a shortcut that some development teams use to enhance their productivity. But when attackers see this additional data come through, they may attempt to mine as much of it as possible. This situation is hazardous when data includes information that is sensitive, confidential, or protected under regulatory requirements.

Excessive data exposure threats can be difficult to track since attacks are so sly. For example, all an attacker needs to do is enter the mobile app as a client and intercept API traffic to locate additional data sent in the API’s response. Once attackers know that excessive data is being leaked in one location, they’ll perform automated attacks to look for it everywhere — which can lead to a catastrophic data breach. You can completely control your communications by removing extraneous data from your API responses.

Lack of resources & rate limiting

All API requests consume resources, but not all APIs are configured to protect themselves from overuse. This blunder can quickly lead to the API becoming overwhelmed to the point that it can no longer accept service requests, otherwise known as a lack of resources and rate limiting. 

In some cases, attackers may intentionally consume an API’s resources to plummet its availability, but there are also less malicious instances of such risks.

Some businesses may make too many requests of an API by accident when development teams have not put rate limiting in place. Configuration mistakes can be made in the API gateway or the API itself, at the load balancer, at the CDN, etc. Occasionally, development teams set limits too low because they haven’t performed sufficient load testing.

No matter the overhaul’s source, downtime in API performance is a direct risk to business operations and can cost a company revenue, time, and consumer trust.

Broken function level authorization

Authorization protection is a strong pillar of API security, but it’s no easy task; modern applications are laden with many different user and sub-user types, groups, and roles that make proper authorization challenging to implement. Broken function level authorization (BFLA) threats arise from misconfigured or inappropriately applied authorization techniques.

Instances of BFLA aren’t challenging for attackers to spot because of the formulaic structure of APIs. In fact, attackers can target authorization flaws by intercepting application traffic, manipulating outward-facing code, or pinpointing exposed endpoints. An attacker may slightly change an API request to target general or administrative API functions (instead of an individual object like in broken object-level authorization). 

Unfortunately, attackers maliciously targeting broken function-level authorization can take over a user’s account, create or delete accounts without warning, access confidential or unauthorized resources, or even gain administrative access by escalating privileges.

Injection attacks

Even though they’re one of the oldest tricks in the book, injection attacks are a persistent and viscous problem in web application security. They encompass a wide range of attack vectors in which an attacker feeds malicious input to a web program. The software then interprets that input as a legitimate command that alters the execution of the API program or service. This change of events can cause a breach of sensitive information and user permissions or allow the attacker to run harmful code.

Inadequate user input validation puts web applications at risk for injection attacks, which can swiftly result in denial of service, endangered data integrity, data theft and loss, or an entirely compromised API system. 

SQL injections (SQLi) and cross-site scripting (XSS) are two of the most common types of injection attacks that are exceptionally detrimental because they operate with a large attack surface. A plethora of free tools and resources are available online for carrying out these attacks, which means that companies constantly need to be on high alert.

DDoS attacks

Distributed denial-of-service (DDoS) attacks are malicious actions that overwhelm a server, network, or service with internet traffic, thereby disrupting the targeted infrastructure’s typical traffic. These attacks are carried out with networks of compromised computer systems or Internet servers that attackers remotely control — otherwise known as botnets. Each of the individual bots in a botnet will send requests to the victim’s IP address in an attempt to overwhelm the server and bring about denial-of-service. Distinguishing attack traffic from regular traffic is exceedingly difficult because the bots pose as legitimate Internet devices to those monitoring traffic. 

Now that we’ve covered the various methods of malicious actors to access a company's private information, we can now get into the proper measures for fortifying that sensitive data and bulletproofing our APIs.  

API & Microservices Security Redefined: beyond gateways & service mesh boundaries

How to mitigate API security risks

OAuth

OAuth is an industry-standard solution for protecting your API authorization, and if you’re not already using it, you should be. OAuth 2.0 allows applications to securely access resources hosted by other web apps and delegate access to their own resources without revealing any original credentials. 

OAuth 2.0 offers a host of perks for both users and applications, including constant security analysis, proactive responses, and explicit resource ownership; The OAuth standard works for most use cases and core functionalities, making it a de-facto industry standard for web authorization.

Data encryption

Encrypting your data is a nonnegotiable step to ensuring API security because it helps protect sensitive information from being accessed, manipulated, or stolen by hackers. It also aids in protecting data at rest, such as storage systems, file systems, and databases. 

Every interaction between APIs and clients should be secured through an SSL (Secure Sockets Layer) connection or TLS (Transport Layer Security) encryption protocol, such as HTTPS (Hypertext Transfer Protocol Secure). This line of defense protects all communications from third parties by using undecipherable data. For data at rest, you can use other encryption techniques like file-level, column-level, or transparent data encryption.

Of course, any form of encryption comes with encryption keys. You’ll need to establish a foolproof key management strategy restricted to authorized personnel so that you can generate and store keys soundly. It’s also advisable to rotate encryption keys often in case of a security breach.

Tokens

API tokens are collections of unique code containing relevant user information. Though small, tokens are packed with data that helps verify a user’s access — preventing attackers from gaining malicious access to systems since tokens cannot be transferred between servers. In simple terms, the API token delivers a payload (or a unique passkey) that is verified by the API. Then, the access token is sent alongside every future query to the API, ensuring that the API will respond to the user’s requests as long as they have the correct token. 

One type of API token is a single sign-on (SSO) token, which is often used to verify logins across multiple sites. Because API tokens are usually device-specific, users need to use different tokens for their computers, tablets, and smartphones, helping to keep their accounts even more secure. 

API throttling and rate limiting

APIs receive an unfathomable amount of daily requests — a factor that can overwhelm them if development teams aren’t careful. API throttling and rate limiting can help prevent attackers from abusing high usage demands. While the two concepts are typically used in conjunction, they’re not the same. 

  • An API throttler monitors the amount of API requests made on a server or network level and controls the traffic the API can accommodate. The throttler controls when your API can make and respond to calls within a specific time period to ensure it stays functional and available to all users. 

  • Rate limiting is similar in that it limits the number of requests that can be made within a certain period of time, but it works at the user level. Rate limiting ensures that a single user cannot exhaust an API with too many requests, in an effort to prevent DDOS attacks. Both of these techniques help prevent a crash in your API system while still providing your customers access to services.

Service mesh

Utilizing a service mesh for a microservices-based application can be a great way to manage and streamline complicated network functions within the services, creating a more secure, reliable, and efficient API ecosystem. The service mesh assists the server endpoints by directing incoming requests to the proper server and managing overall network unpredictability. It also manages security protocols like encryption, authentication, and authorization.

The service mesh also cuts down on the amount of code needed for internal app communication, which works well for an ecosystem of network addresses that are constantly changing. This approach helps simplify your application and accelerate delivery, which can give your development team more time to focus on security and innovation when used with API gateways.

It’s important to note though that service mesh for the sake of service mesh can make the system more complicated (and therefore potentially less secure) if operators aren’t sure what they’re doing. 

API gateways

An API gateway is a central entry point for all user API requests. It works by routing requests to the appropriate backend services, pulling the correct data, and delivering it back to users. The API gateway packages data for each user’s technology and manages critical functions like user authentication and traffic control, which provide secure and threat protection to the API.

API gateways are ideal for applications with cloud-native microservices architecture because they provide reliable delivery of services while ensuring protected access control. These gateways put a barrier before an application’s backend, add another layer of call authentication, and provide input validation.

Zero Trust framework

Zero Trust is a security framework that requires every user to be continuously authenticated and authorized to maintain access to applications and data. 

The basic principle is that all traffic, internal or external, is assumed unauthorized unless explicitly granted access. This guards against the risk of a bad actor exploiting a vulnerability in one area of the system and then gaining access to everything.

A significant benefit of Zero Trust is that networks can be located anywhere, with security extended to the cloud, locally, or in a hybrid environment. Zero Trust involves technologies like identity protection, next-generation endpoint security, and multi-factor authentication to verify user identities.

Zero Trust goes the extra mile in verification because it helps enforce security policies, compliance, and other specific requirements before granting access and controls.

Threat models

Threat modeling is a tool companies use to identify potential threat agents to their applications and servers — essentially performing an API risk assessment. By taking on the role of an attacker, companies can gain insight into security implications and other aspects of their systems that may be vulnerable during the design stage or later. 

Threat modeling can help developers clarify their security efforts and document threats to their applications so they can make a plan of action. This foresight can prevent rash responses to attacks, identify design flaws, detect early issues in the SDLC, and much more. Threat modeling offers the ultimate outside view of an application’s structure, environment, and security that every development team should have on hand.

Conclusion

With APIs powering the digital landscape of today’s applications and servers, developers must be prepared to respond to serious API security vulnerabilities. API threat protection gives you an edge over attackers, so you can outsmart them before they launch malicious activities or access sensitive data.

In this post, we discussed common API security risks and the actions you can take to mitigate or prevent them altogether. Kong offers a cloud-native API platform that aids in this process, including services like rate limiting, API throttling, authentication mechanisms, secure data transmission, and much more. 

Using these tools to bolster your company’s API security can give your development teams more time to innovate business solutions. If you want more information, request a demo from Kong today.