Testing an API for bugs is one thing. Testing it against someone who actually wants to break in is a completely different mindset. Threat modeling is how I shift from “does this work correctly” to “how could this be abused, and what happens if it is.” In this article, I’ll walk you through what threat modeling actually means for APIs, and how to build a threat model into your testing process step by step.
What Is Threat Modeling?
Threat modeling is a structured way of asking: what could go wrong, who would want to make it go wrong, and how bad would it be if they succeeded? Instead of randomly poking at an API hoping to find something, threat modeling gives you a systematic method for identifying the most realistic and most damaging risks first, so your testing time goes where it matters most.
Why APIs Need Dedicated Threat Modeling
APIs are attractive targets because they:
- Expose business logic and data directly, often with less “friction” than a website UI.
- Are frequently called by machines, making automated attacks (like credential stuffing or scraping) easy to run at scale.
- Often connect multiple systems together, meaning a single weak API can become the entry point into an entire company’s infrastructure.
Step 1: Understand What You’re Protecting
Start by mapping out the API’s assets:
- What data does it store or return (personal information, payment data, business secrets)?
- What actions can it perform (create orders, transfer funds, delete accounts)?
- Which systems does it talk to behind the scenes (databases, third-party services, internal microservices)?
I like to draw this out as a simple diagram: client → API gateway → application logic → database/external services. Every arrow in that diagram is a potential attack surface.
Step 2: Identify Entry Points
List every way data enters the API:
- URL path parameters and query strings.
- Request headers (including custom ones).
- Request bodies (JSON, form data, file uploads).
- Authentication tokens and cookies.
- Webhooks or callbacks the API receives from other systems.
Every one of these is a place an attacker could try to inject unexpected data.
Step 3: Use a Structured Threat Framework
Two frameworks I rely on constantly:
STRIDE
STRIDE breaks threats into six categories:
- Spoofing — pretending to be someone else (stolen credentials, forged tokens).
- Tampering — modifying data in transit or at rest (changing a price in a request body).
- Repudiation — denying an action was taken, due to lack of proper logging.
- Information Disclosure — leaking data that shouldn’t be exposed (verbose error messages, over-permissive endpoints).
- Denial of Service — overwhelming the API so legitimate users can’t use it.
- Elevation of Privilege — a regular user gaining admin-level access.
OWASP API Security Top 10
This is a list specifically built for APIs, and I check every API I test against it:
- Broken Object Level Authorization (BOLA) — accessing another user’s data by changing an ID.
- Broken Authentication — weak or improperly implemented login and token systems.
- Broken Object Property Level Authorization — being able to read or write fields you shouldn’t.
- Unrestricted Resource Consumption — no limits on request size, rate, or expensive operations.
- Broken Function Level Authorization — regular users reaching admin-only endpoints.
- Unrestricted Access to Sensitive Business Flows — abusing legitimate features at scale (like bulk account creation).
- Server Side Request Forgery (SSRF) — tricking the API into making requests to internal systems.
- Security Misconfiguration — default credentials, open debug endpoints, verbose errors.
- Improper Inventory Management — old, undocumented, or “shadow” API versions still running in production.
- Unsafe Consumption of APIs — trusting data from third-party APIs without validating it.
Step 4: Rank Threats by Likelihood and Impact
Not every threat deserves equal attention. For each threat you identify, ask:
- How likely is this? Is it something a script kiddie could stumble into, or does it require insider access?
- How bad would it be? Would it leak a few non-sensitive fields, or could it expose every user’s password hash?
A simple high/medium/low scoring on both axes helps you prioritize. A threat that’s both high-likelihood and high-impact — like a broken authorization check on a payments endpoint — goes to the top of your test plan immediately.
Step 5: Design Tests Around Each Threat
Once threats are ranked, turn each one into a concrete test case. For example:
- Threat: BOLA on the
/orders/{id}endpoint. - Test: Log in as User A, note an order ID, then log in as User B and try to fetch User A’s order directly by ID.
- Threat: SSRF through a “profile picture from URL” feature.
- Test: Submit an internal IP address or cloud metadata endpoint (like
169.254.169.254) as the image URL and see if the server fetches it. - Threat: Excessive data exposure in a search endpoint.
- Test: Compare the full database record for a user against what the API actually returns, checking for fields that shouldn’t be public.
Step 6: Test the Boundaries, Not Just the Middle
Attackers rarely follow the “happy path.” Focus your threat-driven tests on:
- Unexpected input combinations.
- Sequence-breaking (calling endpoints out of the expected order, like confirming an order before creating it).
- Race conditions (sending the same request many times simultaneously).
- Abuse of legitimate features at scale (using a “forgot password” endpoint to enumerate valid email addresses).
Step 7: Document and Re-Model Regularly
A threat model isn’t a one-time document. Revisit it whenever:
- New endpoints or features are added.
- The API’s authentication or authorization logic changes.
- A new third-party integration is introduced.
- A real incident occurs — treat it as a signal that your threat model missed something.
Tools That Help
While the thinking is manual, these tools support the process well:
- OWASP Threat Dragon for drawing and documenting threat models.
- Burp Suite or OWASP ZAP for actively probing APIs based on identified threats.
- Postman or Insomnia with scripted test collections built directly around your threat scenarios.
Final Thoughts
Threat modeling turns API testing from a guessing game into a focused, prioritized process. By mapping your assets, identifying entry points, applying frameworks like STRIDE and the OWASP API Security Top 10, and turning real threats into concrete test cases, you catch the vulnerabilities that actually matter before an attacker does.