The API Was Working Exactly as Designed
Key Intel / TL;DR
  • › The most damaging API attacks often use endpoints exactly as built, sending valid requests at a volume and in a pattern no human user would.
  • › Credential stuffing, account enumeration, scraping, gift card and coupon testing, and inventory hoarding all look like normal traffic one request at a time.
  • › Vulnerability scanners and penetration tests rarely flag this, because there is no flaw to find, only a business flow with no limit on how often it runs.
  • › Limits belong on identities and business outcomes, such as failed logins per account and lookups per customer, and not only on requests per IP address.
  • › Every endpoint that answers a yes or no question about your customers is an oracle, and it needs to answer the same way for every input.

Picture the incident review. The login API was not breached, and no vulnerability was exploited. Over a weekend, it accepted 4 million login attempts from 60,000 residential IP addresses, each one a correct, well-formed request with a username and password taken from somebody else’s breach. Roughly one in a thousand worked, because people reuse passwords, and on Monday morning 4,000 customer accounts belonged to someone else.

The API did exactly what it was built to do. It checked each password and answered honestly. That is the category of attack this article is about, and it is the one most security programs are least equipped to see.

No Flaw to Find

Most API security work looks for defects. A missing authorization check lets one user read another’s records, which we covered in fine-grained authorization and BOLA. An undocumented old version is still answering, which we covered in the APIs you do not know you are running. A webhook accepts unsigned requests, which was the subject of the webhook signature nobody is checking. Those are real problems, and a scanner or a tester can find each of them.

Abuse is different. The login endpoint that checks a password, the search endpoint that returns prices, the endpoint that tells you whether an email address already has an account, and the one that checks a gift card balance are all working correctly. The problem is that nothing limits how often, how fast, or how systematically anybody can use them, and an attacker with automation uses them millions of times.

Because there is no defect, the usual assurance activities come back clean. A penetration test with a fixed number of days rarely spends them on running a business flow a million times, and a scanner has nothing in its catalog that matches “this works, but too well.”

What It Looks Like in Practice

A handful of patterns account for most of the damage, and each looks normal one request at a time. Credential stuffing runs breached username and password pairs against the login endpoint, the scenario in the opening. Account enumeration asks the registration, login, or password reset endpoints whether an email address exists, and builds a list of your customers from the differences in the answers. Scraping pulls prices, listings, or profile data through search and catalog endpoints, often feeding a competitor or a fraud operation.

Gift card and coupon testing guesses codes against a balance or validation endpoint until valid ones turn up. Inventory hoarding adds limited stock to carts or reservations without completing purchases, so real customers find it sold out. And in an industry with loyalty points, airline miles, or account credit, any endpoint that moves value can be drained by somebody who has taken over enough accounts.

What all of these have in common is that the attacker never needs to break anything. They need volume, persistence, and a supply of IP addresses that do not look related, which residential proxy services now sell cheaply.

Why the Usual Rate Limit Does Not Help

Most APIs have some rate limiting, usually a cap on requests per IP address per minute. That stops a single machine hammering an endpoint, and it does almost nothing against a distributed attack that sends a handful of requests from each of tens of thousands of addresses. Each source stays politely under the limit while the total runs into millions.

Web application firewalls have a similar blind spot. They are good at spotting malicious payloads, such as injection strings, and abuse traffic contains no malicious payload at all. It is a valid username and a plausible password, sent in a valid request.

Limits That Match the Abuse

Limit by identity and outcome

The controls that work count the thing you actually care about, at the level the attacker cannot easily spread across addresses. Count failed logins per account, per username, and across the whole service, not only per IP address. Count balance checks per customer and per card range, searches per session, and password reset requests per email address. When a limit is tied to the account or the business outcome, spreading requests across thousands of IP addresses no longer gets around it.

Watch the totals as well as the sources

A sudden rise in the global failure rate on the login endpoint is one of the clearest signs of credential stuffing, even when every individual source looks harmless. Alert on the ratio of failed to successful logins across the service, and on spikes in password reset requests, new account creation, and balance checks.

Close the oracles

An endpoint that answers a yes or no question about your customers can be used to ask that question millions of times. Login, registration, and password reset should respond identically, in content and in timing, whether the account exists or not. Balance and validation endpoints should require something an outsider does not have, such as an authenticated session or a second factor tied to the card.

Add friction where the value is

Not every endpoint needs the same protection. Put stronger checks, such as a step-up challenge, device signals, or a delay that grows with repeated failures, on the flows that move money, change account details, or reveal personal information, and leave browsing fast. We made the case for watching account recovery in resetting the password does not kill the session, and abuse is often how attackers reach that flow in the first place.

Give the problem an owner

Abuse often lands between teams. Security sees no vulnerability, the fraud team sees losses but not the API traffic, and the product team owns the endpoint but is measured on conversion. Name one owner for abuse on each customer-facing API, and give them the logs from all three views.

A Test Worth Running

Pick your login endpoint and your password reset endpoint. Ask your team three questions: how many failed logins can one account take in an hour before anything changes, whether the response differs when the email address exists, and whether anybody would be alerted if the service-wide failure rate tripled overnight.

If the answers are “unlimited,” “yes,” and “no,” you have found the gap this article describes, and it is almost certainly being probed already. Our API security best practices cover the defects. This is the part that sits beside them, where the API is behaving perfectly and the business is losing anyway.

Chris Armour is Director of Information Security at Grab The Axe.

Distribute Intel
Chris Armour
Director of Information Security
Chris Armour
The Breaker & Builder.

Operating on the philosophy that 'you can't build a secure system if you don't know how to break it,' Chris leads our engineering division. A top 1% National Cyber League competitor, he hardens our digital infrastructure against the very exploits he has mastered.

View Author Page →