Main information breaches are on the upward thrust, and APIs are increasingly more getting used to realize get admission to to delicate information. The explanations for this are twofold: APIs are the primary defensive position into an utility (and it’s information), and increasingly packages are obtainable by way of the cloud and APIs. The entirety from non-critical capability, like track streaming and social media, to extraordinarily severe information, equivalent to monetary accounts and healthcare, is on the market 24×7 via APIs.
Why is it so fascinating to breach API safety? There are lots of nefarious causes, however listed below are only a few:
- Stealing In my view Identifiable Data (PII) and promoting it at the darkish internet or for identification robbery
- For asset robbery, extortion or ransom
- Inflicting utility instability or unavailability
- Espionage (company or political)
- Election interference
- Political instability
The record is going on. The provision of information and the risks of breaches make it severe to get API safety proper.
Every 12 months, the Open International Utility Safety Venture (OWASP) comes up with a listing of the Best 10 API Safety Dangers. We’ll take a handy guide a rough take a look at the present record, with examples of information breaches led to via every form of chance.
After that, we’ll communicate in regards to the API pipeline and techniques to stop commonplace API safety problems around the pipeline.
OWASP Best 10 API Safety Dangers (2023)
Let’s check out the OWASP Best 10 API Safety Dangers, ranked so as of incidence (from perfect to lowest).
API1:2023 – Damaged Object Stage Authorization (BOLA)
In a BOLA assault, object IDs for utility information are leaked in API responses and used to realize unauthorized get admission to to delicate information.
The massive Twitter (now X) API breach was once a BOLA assault, the place an API which may be used to seek out customers ended up leaking PII.
API2:2023 – Damaged Authentication
With damaged authentication, an attacker compromises vulnerable authentication strategies and beneficial properties get admission to to an utility (and in the long run, information).
Many safety breaches are led to via damaged authentication.
API3:2023 – Damaged Object Belongings Stage Authorization
That is very similar to BOLA, the place an attacker is in a position to acquire unauthorized get admission to to information.
API4:2023 – Unrestricted Useful resource Intake
On this situation, the attacker is in a position to get unrestricted get admission to to an utility and its sources. This sort of assault may cause utility instability and even outages. If massive quantities of utility sources are ate up with out restriction, the outcome might be very expensive (e.g. paid-tier cloud sources)
An instance of this is able to be a Denial of Provider (or DoS) assault, the place an utility is so beaten with site visitors, it might now not serve as.
API5:2023 – Damaged Serve as Stage Authorization (BFLA)
With BFLA, unauthorized get admission to to utility capability is permitted. This contains authorization problems between microservices.
An insurance coverage corporate was once the sufferer of a BFLA assault because of buyer information being to be had to the general public by way of a “safe phase” of the applying.
API6:2023 – Unrestricted Get entry to to Delicate Trade Flows
This danger comes to vulnerability to computerized abuse of utility transactions, as an example price ticket gross sales or thread feedback. As an example, “Dangerous bots” might be used to crush an utility and circumvent safety.
This came about with the Taylor Swift live performance price ticket snafu in November 2022. Scalper bots had been used to shop for restricted free up tickets for verified lovers, that have been then offered at an enormous benefit.
API7:2023 – Server Facet Request Forgery (SSRF)
Often referred to as “URL spoofing”, this comes to a server the usage of an enter URL to a far flung useful resource with out validating the given URL, which might permit attackers to get round a VPN or firewall and probably acquire get admission to to delicate information. The attacker makes use of the server to make the request seem respectable.
The large Capital One information breach in 2019 was once an SSRF assault, and ended in PII for 100 million bank card holders to be stolen. Extra lately, a category motion lawsuit was once filed.
API8:2023 – Safety Misconfiguration
Any vulnerable or misconfigured safety in an utility opens assault surfaces.
In Might 2023, Toyota printed a large information breach because of inadequate cloud configurations.
API9:2023 – Wrong Stock Control
Wrong API stock control contains undocumented (shadow) APIs, deprecated (zombie) APIs and unauthorized (rogue) APIs.
Shadow and zombie APIs are dangers as a result of they would possibly not have enough safety scrutiny. A rogue API can imply the similar factor as a shadow API, however it will also be the results of malicious code injection opening up a backdoor into an utility.
API10:2023 – Unsafe Intake of APIs
Susceptible safety in 3rd birthday celebration APIs utilized by an utility can permit get admission to to information.
An instance of this danger is an insecure AWS S3 bucket with get admission to to information, which appears to be accountable for lots of fresh information leaks. Although the applying which hosts the knowledge may be very protected, the knowledge may just nonetheless be obtainable via S3 APIs.
The API Pipeline
We pay attention about “pipelines” and “transferring in opposition to the left” always in tool building. However what do those ideas imply within the context of APIs?
The API pipeline spans all the API lifecycle, from preliminary building (“at the left”) to deployment into manufacturing (“at the proper”). That is illustrated under.
Let’s talk about the more than a few phases of the API pipeline.
Building/Coding
APIs are born in building, preferably via first crafting an OpenAPI specification (OAS spec) to formalize the API, specify parameters, determine conceivable go back parameters and codes, and many others.
Many builders use Built-in Building Environments (IDEs) to prepare the surroundings, equivalent to VSCode (open supply), PyCharm (group and paid-tier) or GoLand (paid-tier).
Relying at the IDE, there could also be extensions to assist as you write your OAS specifications. As an example, VSCode has a number of OAS spec linter extensions that may statically flag problems with the spec, equivalent to Spectral (open supply), and Postman (unfastened and paid-tier). The Spectral extension even has an OWASP Best 10 API Safety Dangers ruleset. Panoptica (unfastened trial and paid-tier) can run other OAS spec linters from the command line.
AI copilots are the entire rage now, and can be utilized to broaden the API consumer/server code. Standard AI copilots come with GitHub Copilot (paid-tier) and others.
Be aware that no longer all API safety problems can also be detected statically. Many problems can handiest be detected in a dynamic atmosphere, the place API calls are if truth be told being acted upon.
After the API code is completed, it’s in a position for unit checking out.
Unit Checking out
As soon as building is whole, the API code undergoes unit checking out, the place “mock” API calls are made to ensure that the APIs are behaving appropriately. A unit check atmosphere remains to be static as a result of, even though calls can also be made to consumer and server purposes, the applying isn’t working as a complete.
There are lots of equipment to auto-generate mock API code and run mock API servers, together with WireMock (open supply), Mockoon (open supply), Microcks (open supply), Postman (unfastened and paid-tier), RestAssured (open supply) and SoapUI (open supply).
As soon as unit assessments are written and passing, the API code is in a position for CI/CD.
Steady Integration/Steady Supply (CI/CD)
In CI/CD, the code is submitted for code overview, the picture is constructed and a few gating assessments are run automagically. The gating assessments come with static assessments, equivalent to unit assessments and OAS spec linters, and dynamic assessments like end-to-end purposeful assessments, the place the code is if truth be told put in and fundamental capability can also be examined in an automatic approach.
If the CI/CD assessments all move, the code is able to be merged into the code repository and examined in staging.
Staging
A staging atmosphere is very similar to a real manufacturing atmosphere, however is remoted for inside checking out. In staging, the applying is put in and a top quality assurance group can test the capability.
Top availability and function assessments will also be run in staging. Top availability checking out comes to verifying that no unmarried issues of failure exist to your utility. Efficiency checking out verifies that your utility plays at scale, which incorporates a excessive quantity of API site visitors.
Equipment for API efficiency and cargo checking out come with Locust (open supply), SoapUI and Postman.
Some other form of software this is useful all over staging is a fuzzer. A fuzzer passes unhealthy information into API endpoints to your utility and tries to negatively have an effect on the applying (e.g. make it prevent responding, make it crash, leak information, and many others.). Examples of fuzz checking out equipment are RESTler (open supply) and Panoptica.
Greenfield Deployment
The primary time an utility is deployed to manufacturing, it’s known as a “greenfield deployment.” In greenfield, since there aren’t any present artifacts, there aren’t any versioning or improve issues.
In a manufacturing atmosphere, you’ll be able to dynamically scan real-time API site visitors for safety dangers to give protection to your utility. The Panoptica CNAPP platform has a complete suite of API safety capability, which we’ll talk about under.
Brownfield Deployment
Brownfield deployment is when the applying is upgraded in an present manufacturing atmosphere.
With brownfield, such things as API backwards compatibility and versioning come into play. As an example, API purchasers may just proceed to make use of a previous OAS spec model after the applying has been upgraded with a brand new one. More than one API variations should be supported.
A canary deployment is a brownfield deployment the place other variations of the applying are working concurrently as a way to cut back chance with a brand new model. The canary deployment manages just a subset of the entire API site visitors. Right here once more, API backwards compatibility and versioning are necessary concerns.
Save you Not unusual API Safety Problems Around the Pipeline
Now that we’ve talked in regards to the OWASP Best 10 API Safety dangers and the total API pipeline, let’s check out some commonplace API safety problems and the best way to save you them around the pipeline.
BOLA
BOLAs had been probably the most prevalent roughly API safety factor in 2023, in step with OWASP. They’re integrated in problems API1:2023 (Damaged Object Stage Authorization) and API3:2023 (Damaged Object Belongings Stage Authorization).
As up to now discussed, in a BOLA assault, an finish person is in a position to get admission to information that they don’t have the authorization to get admission to, normally as a result of metadata is leaked in API responses from the applying.
Since information, particularly PII, is a big goal of breaches, any unauthorized get admission to is a large safety downside.
How can BOLAs be averted around the API pipeline?
- Throughout building, be sure you have a robust authorization type to your utility that doesn’t permit get admission to to information with out authorization, and ensure no information is leaked in API responses.
- In building and CI/CD, use OAS spec linters (mentioned previous) to flag possible authorization problems.
- Throughout unit checking out and CI/CD, run mock API site visitors that tries to get admission to information with out authorization.
- In CI/CD and staging, run a fuzzer towards your API endpoints that may ship unhealthy enter into the APIs and flag any surprising get admission to to information.
- In staging and manufacturing, run dynamic API safety equipment to check out API site visitors and flag possible BOLA problems. Panoptica has BOLA detection features.
BFLAs
BFLAs happen when utility capability is accessed with out the correct authorization, both via an finish person calling into the applying or between utility microservices. BOLA (above) is set getting access to information, BFLA is set getting access to capability. Gaining unauthorized get admission to to capability can in the long run result in information breaches. BFLAs are OWASP factor API5:2023 (Damaged Serve as Stage Authorization).
How can BFLAs be averted around the API pipeline?
- Throughout building, be sure you have a robust authorization type for getting access to utility capability from finish customers and between microservices.
- In unit checking out and CI/CD, run mock API site visitors that tries to get admission to utility capability with out authorization.
- In staging and manufacturing, run dynamic API safety equipment to check out API site visitors and flag possible BFLA problems. Panoptica has the facility to be told the BFLA authorization type after which stumble on any possible violations in real-time site visitors.
Susceptible Authentication
Susceptible authentication into an utility is more straightforward for an attacker to compromise. It will give danger actors get admission to to person accounts and information. Susceptible (or damaged) authentication is integrated in OWASP problems API2:2023 (Damaged Authentication) and API8:2023 (Safety Misconfiguration).
One type of that is fundamental authentication, which calls for a username and password, the place the password itself is “vulnerable.” This contains quick passwords, passwords which might be too commonplace (e.g. can also be present in a dictionary seek), or passwords which might be reused throughout accounts.
Susceptible authentication will also be because of vulnerable endpoint safety, as an example the usage of HTTP as an alternative of HTTPs.
In spite of everything, encryption problems fall into this class. Having endpoints without a encryption or vulnerable encryption can open assault surfaces into your utility. If there isn’t any encryption, all API site visitors is “within the transparent” which means it may be tapped and simply learn. Susceptible encryption may just contain shorter encryption keys that may be simply compromised.
How can vulnerable authentication be averted around the API pipeline?
- Broaden protected endpoints (e.g. HTTPs) with robust encryption enabled.
- For fundamental auth, require robust passwords and multi-factor authentication (MFA).
- In building and CI/CD, use OAS spec linters (in particular with the OWASP Best 10 ruleset) to flag insecure endpoint problems.
- In unit checking out and CI/CD, run mock API site visitors that makes use of vulnerable authentication and tries to realize get admission to.
- In staging and manufacturing, run dynamic API safety equipment to flag vulnerable authentication in real-time API site visitors. Panoptica can stumble on many varieties of vulnerable authentication.
Shadow APIs
OWASP factor API9:2023 (Wrong Stock Control) contains shadow APIs. Shadow APIs aren’t documented in an OAS spec. They’re a safety chance you would possibly not even know you could have.
As your utility evolves, it’s not going that the protection of shadow APIs may even evolve. They may also be forgotten completely, exposing an ongoing safety loophole or backdoor into your utility.
How can shadow APIs be averted around the API pipeline?
- Throughout building, be sure to take an stock of all APIs and file every of them in an OAS spec.
- In staging and manufacturing, run dynamic API safety equipment that may stumble on shadow APIs in real-time site visitors and reconstruct an OAS spec for them to file them correctly. Panoptica has those features.
Zombie APIs
OWASP factor API9:2023 (Wrong Stock Control) additionally contains zombie APIs. Zombies APIs are APIs which might be deprecated within the OAS spec however are nonetheless energetic inside the utility. They happen in brownfield and canary manufacturing environments, the place more than one API variations could also be in use.
Like shadow APIs, zombie APIs are not going to adapt along with your utility and may just obtain much less scrutiny from a safety viewpoint, thus leaving a backdoor into your utility.
How can zombie APIs be averted around the API pipeline?
- Take away reinforce for zombie (deprecated) APIs once conceivable.
- In staging and manufacturing, run dynamic API safety equipment that may stumble on zombie APIs in real-time site visitors, equivalent to Panoptica.
Susceptible 3rd Birthday celebration Authentication
Although your utility information get admission to is actually protected, vulnerable 3rd birthday celebration authentication may just nonetheless divulge your information to threats. 3rd birthday celebration get admission to on your information contains databases, S3 buckets, and many others. Susceptible third birthday celebration authentication is integrated in OWASP problems API8:2023 (Safety Misconfiguration) and API10:2023 (Unsafe Intake of APIs).
How can vulnerable 3rd birthday celebration authentication be averted around the API pipeline?
- Throughout building, stay an stock of all 3rd birthday celebration APIs and services and products which might be being utilized by your utility.
- Examine that 3rd birthday celebration get admission to is protected.
- In CI/CD and staging, use a device to assess the protection of threerd birthday celebration API calls. The Panoptica CLI has this capability.
- In staging and manufacturing, use cloud safety scanners to stumble on vulnerable 3rd birthday celebration authentication. Examples of cloud safety scanning equipment are AWS Config (paid carrier), Azure Automation and Regulate (unfastened and paid-tier), GCP Cloud Asset Stock (unfastened) and CloudQuery (open supply and paid-tier).
Useful resource Intake
Unrestricted useful resource intake is OWASP factor API4:2023. If an utility is inundated with many API calls inside of a brief time frame, it might have destructive penalties. As an example, utility sources equivalent to CPU, RAM and garage can also be swiftly ate up or exhausted, resulting in probably upper operational prices, slower reaction time and even utility failure and outages.
How can unrestricted useful resource intake be averted around the API pipeline?
- Throughout building, upload rate-limiting to the API processing to your utility, together with a most charge of API requests and an affordable timeout.
- In staging, use efficiency checking out that exceeds the allowed charge of API requests and verifies that the applying remains to be functioning as anticipated.
- In staging and manufacturing, use an API gateway in entrance of your utility to throttle and rate-limit API requests. Some standard API gateways are AWS API Gateway (unfastened and paid-tier), GCP API Gateway (unfastened and paid-tier), Kong (open supply and paid-tier), Tyk (open supply) and Azure API Control (unfastened and paid-tier). Be aware that the applying nonetheless wishes it’s personal rate-limiting capability when the usage of an API gateway.
OWASP factor API6:2023 (Unrestricted Get entry to to Delicate Trade Flows) is expounded to unrestricted useful resource intake, however it signifies that automation, unhealthy bots or AI are concerned within the API abuse, compounding the useful resource intake.
URL Spoofing
With a URL spoofing assault, an invalid or malicious URL is handed into an API request, and the server proxies the URL with out validating it. The suspicious URL can be a pretend website or a webhook. This is able to permit get admission to to delicate information and PII. This sort of vulnerability is roofed in OWASP factor API7:2023 (Server Facet Request Forgery).
How can URL spoofing be averted around the API pipeline? Protecting towards this sort of assault can also be advanced. This is a great useful resource to get began. The high-level gist of prevention measures is:
- Throughout building, carry out validation at the given URL, together with the IP deal with and area identify (see above useful resource hyperlink).
- Create a listing of allowed URLs, if conceivable, and validate the given URL towards the record (see above useful resource hyperlink).
- In unit checking out and CI/CD, run mock API site visitors that makes an attempt to move an invalid URL into the API.
Information Injection
Information injection can permit danger actors to move malicious information, configurations or techniques into an utility by way of APIs. This is able to permit get admission to to information (e.g. BOLA) or make an utility volatile.
How can information injection be averted around the API pipeline?
- Throughout building, come with strict sort checking (i.e. take a look at for right kind form of information in a request, don’t permit surprising information varieties) and enter validation in API processing.
- Determine an higher restrict on measurement and amount of information that may be enter in a request. As an example, have a most measurement for a string enter.
- In building and CI/CD, use OAS spec linters to stumble on problems with information enter.
- In unit checking out and CI/CD, run mock API site visitors that tries to inject invalid information.
- In CI/CD and staging, run a fuzzer towards your API endpoints that sends invalid or malformed information into your API. The Panoptica CLI contains fuzzing features.
- In staging and manufacturing, run dynamic API safety equipment that may evaluate API site visitors towards the OAS spec and flag information discrepancies (together with spec float). The Panoptica CNAPP platform has this capability.
Code Injection
Code injection is the place unwanted code is added to an utility. As IDE plugins and AI copilots are increasingly more used to generate API consumer and server code, there’s a chance that “unhealthy” code might be injected into your utility. This may have unintentional and even malicious unwanted side effects. As an example, a rogue (malicious) API might be injected into your utility growing backdoor get admission to. Rogue APIs fall below OWASP factor API9:2023 (Wrong Stock Control).
How can code injection be averted around the API pipeline?
- Throughout building, it’s necessary to test any generated code with thorough code opinions.
- In CI/CD, staging and manufacturing, symbol scans can seek for any Not unusual Vulnerabilities and Exposures (CVEs) within the utility. Panoptica can scan each Kubernetes container photographs and digital device photographs for problems.
- In staging and manufacturing, run dynamic API safety equipment to scan for any rogue APIs. Panoptica has this capacity.
Conclusion
From the OWASP Best 10 API Safety Dangers, in the course of the API pipeline and directly to commonplace API safety problems and the best way to save you them, we’ve lined numerous flooring, with loads of software ideas alongside the way in which.
Wishing you and your packages the perfect in API safety!
Be informed extra in regards to the Panoptica CNAPP platform
and it’s API safety features.
Take a look at a Cisco DevNet Studying Lab.
Proportion: