StackHawk
๏ƒ‰

Itโ€™s Not That APIs Are Statefulโ€”Itโ€™s That Context Matters

Scott Gerlach   |   Jun 3, 2025

LinkedIn
X (Twitter)
Facebook
Reddit
Subscribe To StackHawk Posts

Most APIs Arenโ€™t Statefulโ€”But Real Attacks Are

APIs are stateless, attacks aren't.

A lot of conversations about API security use the term โ€œstateful.โ€ But thatโ€™s not quite right.

APIs are usually designed to be statelessโ€”each request should stand alone. But real-world usage doesnโ€™t work that way. Neither do attacks.

Attackers donโ€™t look for vulnerabilities in isolation. They chain steps together: log in, get a token, reuse it across endpoints, elevate access, manipulate business logic.

The security problem isnโ€™t that APIs maintain state.
The problem is that most security tools donโ€™t understand context between calls.

The confusion stems from how we talk about API security. When security teams say “we need stateful testing,” they’re really saying “we need to understand how our APIs work together in practice.” 

Consider a typical SaaS tenant provisioning flow: authenticate โ†’ validate subscription tier โ†’ create tenant โ†’ assign admin permissions โ†’ configure integrations. Each API call is stateless, but the business logic depends entirely on the sequence. Skip tenant validation and you might provision enterprise features for trial users. Reverse the permission assignment and you could create admin accounts before tenant boundaries exist.

Or take a financial services API workflow: authenticate โ†’ verify account ownership โ†’ validate transaction limits โ†’ execute transfer โ†’ update balances โ†’ trigger compliance reporting. Test these endpoints in isolation and they all look secure. But what happens when you bypass the limit validation by making the transfer call directly? What if you can trigger compliance reporting without actually executing transfers?

This is why 83% of organizations report that their current API security tools miss critical vulnerabilities in productionโ€”they’re testing APIs like they exist in isolation, not like they’re used in the real world.


What We Hear from Teams

We talk to security and engineering teams every week. Hereโ€™s what we hear:

“We can test single endpoints, but we’re blind to chained risks.”

Translation: They can verify that /api/users/{id} returns a 200 response, but they can’t test whether an attacker can manipulate the {id} parameter after authenticating as a different user to access sensitive data.

“We know attackers could spend days probing just one APIโ€ฆ we’re lucky if we can test it once.”

The reality? Attackers probe API sequences methodically. They’ll test every permission boundary, every data flow, every token scope. Meanwhile, security teams run a single scan and call it good. That’s not testingโ€”that’s theater.

“It’s not that our APIs are statefulโ€”it’s that the workflows matter. And no scanner we’ve used gets that.”

Here’s what they mean: Their login API might work perfectly in isolation, but when chained with profile updates and permission changes, it exposes privilege escalation paths that traditional scanners never discover.

Real Security Starts Before an API Goes Live

One of the most effective ways to test workflows? Start before they even become active.

A customer told us that within two minutes of a developer committing code, StackHawk surfaced:

– A new API being created

– The engineer responsible  

– The type of sensitive data that API would handle

But here’s what makes this story powerful: This wasn’t just about discovery. The commit included a new endpoint that would handle customer payment dataโ€”and the initial implementation had no authentication requirements.

Without StackHawk’s source-code-based discovery, this API would have moved through staging, into production, and potentially exposed thousands of customer payment records. Traditional security tools would have found it eventuallyโ€”maybe during the next quarterly pen test, maybe when attackers started exploiting it.

Instead, that alert kicked off a proactive conversation within hours:

**Immediate Actions Taken:**

– Security team reviewed the API’s intended data flows

– Development team added authentication requirements before the next commit  

– They designed workflow tests that validated both the happy path and abuse cases

– They set up continuous monitoring for similar patterns across other repositories

The result? A critical vulnerability prevented before it ever touched production. And a development team that now understands how their code changes impact the attack surface in real-time.

That’s not just visibility. That’s real, contextual security that starts where the code livesโ€”not where attackers eventually find it.


Where Legacy Tools Fall Short

Traditional DAST tools (and even many newer API scanners) fall into a trap:

  • They treat each endpoint as an independent, atomic test.
  • They donโ€™t maintain session state or track token usage across calls.
  • They canโ€™t simulate real user journeys like signup โ†’ login โ†’ resource access โ†’ modification.
  • And they often donโ€™t support the flexibility to test how APIs behave across contexts, users, or request orders.

That means they miss:

  • Broken object-level authorization (BOLA)
  • Business logic vulnerabilities
  • Token replay issues
  • Context-dependent failures

Let’s get specific about what this means in practice:

The BOLA Problem: 

Traditional scanners might test GET /api/users/123 and confirm it returns user data. But they can’t test whether user 456 can access user 123’s data by manipulating the request after authentication. That requires maintaining session context and testing authorization boundaries across user contexts.

Business Logic Blind Spots:

Consider a banking API where you can transfer money between accounts. A traditional scanner tests the transfer endpoint and confirms it works. But can you transfer money from accounts you don’t own? Can you transfer negative amounts to effectively steal money? Can you bypass daily limits by making multiple simultaneous requests? 

These vulnerabilities only emerge when you test the API as part of a workflow, not as an isolated endpoint.

The Token Lifecycle Gap:

Modern applications use JWTs, OAuth tokens, and session cookies that change state over time. Legacy tools typically authenticate once and reuse the same token for every test. They miss:

– Token expiration and refresh logic failures

– Scope creep where tokens gain additional permissions over time  

– Race conditions in token validation

– Cross-user token reuse vulnerabilities

Real-World Attack Patterns:

Attackers don’t just probe single endpoints. They map workflows, identify data flows, and exploit the gaps between services. They’ll:

1. Create a legitimate account

2. Analyze the authentication flow to understand token structure

3. Test token reuse across different API endpoints

4. Look for privilege escalation paths through chained requests

5. Exploit business logic by manipulating request sequences

If your security tool can’t replicate these patterns, you’re testing in a fantasy world while attackers operate in reality.


Context-Driven Security Testing

Security teams need to test APIs not just in isolationโ€”but in sequences that reflect real behavior.

That’s not about simulating a full app. It’s about being able to:

Authenticate First, Then Test Authorization: Don’t just test that login worksโ€”test what happens when you use those credentials across every other endpoint. Can a standard user access admin functions? Can tokens be replayed across different sessions?

Chain Requests to Replicate Known Workflows: Map your critical business flows and test them end-to-end. SaaS tenant provisioning, user onboarding, data pipeline processing, financial transaction flowsโ€”every workflow that touches sensitive data or business logic should be tested as a sequence, not just individual steps.

Pass Data Between Requests to Validate Multi-Step Logic: Real applications pass data between API calls. User IDs, transaction IDs, session tokensโ€”test how your APIs handle data flows and whether attackers can manipulate those flows to bypass security controls.

Simulate Attacker Manipulation of Operation Order: What happens if an attacker skips the authentication step? Reverses the order of operations? Makes parallel requests that should be sequential? These aren’t edge casesโ€”they’re common attack patterns.

The Developer-Friendly Difference: Traditional security tools require security experts to configure complex test scenarios. StackHawk lets developers define workflows using familiar tools and syntaxโ€”meaning security testing becomes part of the development workflow, not a separate process that slows everything down.

This approach transforms security from “scan and pray” to “test with intent”โ€”focusing on the workflows that matter most to your business and the attack patterns that matter most to your adversaries.

The Business Impact of Context-Aware Testing

Let’s talk ROI. Traditional API security testing generates noiseโ€”thousands of findings that development teams can’t prioritize and security teams can’t validate.

Context-aware testing flips this equation:

Fewer, But Critical Findings: Instead of 500 potential vulnerabilities across isolated endpoints, you get 15 confirmed vulnerabilities in actual workflows. Development teams can prioritize fixes based on real business impact, not theoretical risk scores.

Faster Time to Remediation: When developers receive findings that include the exact request sequence, authentication context, and business logic being exploited, they can reproduce and fix issues in minutes, not days.

Reduced False Positives: Testing APIs in isolation creates false positivesโ€”endpoints that appear vulnerable but are actually protected by upstream authentication or authorization logic. Context-aware testing dramatically reduces these false positives by testing the complete attack path.

Measurable Security Improvement: Security leaders can demonstrate program effectiveness with metrics that matter: “We prevented 12 business-logic vulnerabilities from reaching production” carries more weight than “We scanned 847 API endpoints.”

The difference between traditional and context-aware API security testing isn’t just technicalโ€”it’s strategic. One approach generates busy work; the other prevents business-impacting security incidents.

You Donโ€™t Need to Rebuild the UI to Test Security

Letโ€™s be clear: you donโ€™t need to simulate every interaction.

What you need is flexibilityโ€”a developer-friendly way to define sequences and test the parts of your app where risk compounds.

The goal isnโ€™t more complexity. Itโ€™s better signal.
Thatโ€™s how you move from “scan everything” to “test what matters.”

The Bottom Line

Your API might be statelessโ€”but your attackers arenโ€™t.

If your security tool only tests individual requests, itโ€™s missing the chain.

You need API security testing that understands how your application actually worksโ€”and where context introduces risk.


โœ… Want to learn how StackHawk helps teams test real-world API workflows? โ†’ Get a Demo

Read on for the rest of the Blog Series:

Why Legacy DAST Fails for Modern Applications and How to Fix It: https://www.stackhawk.com/blog/why-legacy-dast-fails-for-modern-applications-and-how-to-fix-it/

Modern Apps Might Not Even Have a Frontendโ€”So Why Is Your Security Scanner Still Crawling?: https://www.stackhawk.com/blog/why-crawling-fails-for-api-first-apps/

Legacy DAST is Dead! Long Live Modern DAST!: https://www.stackhawk.com/blog/long-live-dast-evolution-of-dynamic-api-security-testing/

FEATURED POSTS

Discover the Best API Discovery Tools in 2025

APIs power todayโ€™s software, but with AI tools accelerating development, many organizations donโ€™t even know how many APIs they haveโ€”or how secure they are. Shadow, zombie, and rogue APIs can quietly expand your attack surface, leaving critical vulnerabilities unchecked. Thatโ€™s why modern API discovery tools are essential. This guide breaks down what API discovery is, why it matters more than ever in 2025, and how to choose the right tool to secure your entire API landscape.

Security Testing for the Modern Dev Team

See how StackHawk makes web application and API security part of software delivery.

Watch a Demo

Subscribe to Our Newsletter

Keep up with all of the hottest news from the Hawkโ€™s nest.

"*" indicates required fields

More Hawksome Posts