Skip to main content

How to Run a Penetration Test on a REST API

Yanis Grigy, CEO12 min read

You run a useful REST API penetration test by scoping the live surface first, then testing it with authenticated requests from at least two identities, and finally repeating the same checks after fixes. That workflow is repeatable in [https://fleuret.ai/pentest](our pentest workflow) when you need ongoing API testing, evidence, and retests instead of a one-off scan.

That matters because APIs are now part of the default application stack. According to https://www.anthropic.com/research/anthropic-economic-index-september-2025-report, 99% of organizations used third-party service APIs embedded in their applications in 2023. Once the API is production traffic, you are testing business logic, access control, and change drift, not just endpoints.

Key takeaways

  • A REST API pentest should start from scope, an OpenAPI file, and authenticated access, not from blind crawling.

  • Two distinct user identities are required to catch BOLA/IDOR and role-based authorization flaws.

  • The highest-value tests hit authentication, authorization, schema abuse, rate limits, and business-flow abuse before generic fuzzing.

  • Automate spec-based checks in CI/CD, but keep human review for edge-case authorization and workflow abuse.

  • Key Takeaways

Start with scope, access, and two test identities

What to collect before testing

Start by defining the target, the environment, and who can approve the work. If you want real findings, collect written authorization, the in-scope base URL, the OpenAPI or Swagger file, test accounts, rate-limit expectations, and a contact for logs and incident questions. Pure black-box API testing misses too much. At minimum, you need authenticated access so you can see what a real user can reach.

  • Confirm written authorization, the in-scope base URL, and any excluded routes before a request leaves your machine.

  • Ask for the current OpenAPI definition, because that is usually the fastest route to the actual attack surface.

  • Prepare two test identities with different roles, plus any admin or service account that is explicitly allowed.

  • Record rate-limit expectations, logging contacts, and safe hours for burst testing so you do not create avoidable noise.

“Authorization testing (BOLA/IDOR) ¶ This is the #1 API risk and requires explicit test cases because scanners cannot derive valid object IDs” — OWASP, API Security Project, https://owasp.github.io/DevSecOpsGuideline/2-Process/2-4-Test/2-4-4-API-Security

Two identities matter because a single token cannot reveal whether one user can reach another user’s objects or functions. That is how you catch BOLA/IDOR and role mistakes instead of just proving the API accepts a login.

Why one token is not enough

A lone bearer token tells you almost nothing about authorization boundaries. To expose broken object-level authorization, request a resource as user A, then replay the same object reference from user B and confirm the API denies it. To expose broken function-level authorization, try the same administrative route from a lower-privileged role and confirm the server enforces the role on the backend, not just in the UI. That is the difference between a login test and an actual authorization test.

We usually keep the identities, scope notes, and retest history together in Fleuret so the same cases can be replayed after every fix. That saves time when the API team ships often and the tester is not the same person who handled the first round.

Map the attack surface from spec and real traffic

Use the OpenAPI file as the fastest route

Machine-readable API descriptions in OpenAPI or Swagger are the fastest route to the attack surface. Feed the spec into your test plan first, then enumerate every path, verb, parameter, header, auth scheme, pagination pattern, file upload, admin route, and versioned endpoint. That gives you a clean inventory before you spend time on manual discovery.

“Modern REST APIs commonly publish a machine-readable description in OpenAPI (formerly Swagger). Unlike the WADL option noted above, this format is widely adopted, and for an assessment it is the fastest route to the attack surface.” — OWASP, https://cheatsheetseries.owasp.org/cheatsheets/REST_Assessment_Cheat_Sheet.html

  • Paths and verbs — list every endpoint and method, including hidden admin routes and versioned paths.

  • Parameters and headers — map query, body, path, and header inputs that may affect logic or access control.

  • Auth schemes — record OAuth 2.0, OpenID Connect, JWT, and any custom session mechanism.

  • Pagination and filters — note page size, cursor use, deep paging, and expensive search parameters.

  • Uploads and parsers — capture file upload routes, content types, and parser-sensitive inputs.

Find what the spec misses

Spec drift is normal, so do not trust the file alone. Compare it with proxy captures, changelogs, and observed traffic from a real session, because undocumented endpoints and stale schemas are common in live services. If the spec says one thing and traffic shows another, test both. A release branch can also expose private admin routes that never made it into the published schema.

Test authentication and authorization first

Authentication checks

Authentication problems are the quickest way to create a serious finding, so test them before anything else. Check missing authentication on sensitive routes, weak session handling, malformed tokens, expired tokens, revoked-session handling, JWT tampering, and whether the API accepts a token with the wrong issuer, audience, scope, or role. With OAuth 2.0 and OpenID Connect, validate refresh behavior and token revocation, not just login success. If the API accepts a structurally valid JWT that should no longer work, that is a real flaw.

  • Send requests with no token, bad token, expired token, and a token from the wrong issuer or audience.

  • Replay a revoked or logged-out session and confirm the server rejects it.

  • Alter JWT claims only where the test environment and authorization allow it, then verify the backend refuses the tampered token.

Authorization checks across users and roles

Broken object-level authorization and broken function-level authorization both need explicit tests. Use user A to request /accounts/123, then use user B to replay the same object reference and confirm access is denied. Repeat that pattern for nested properties, administrative functions, and cross-tenant data. This is where many teams stop too early: the login works, the token is valid, and yet user B can still read or change user A’s data.

For authorization, compare at least two user identities with different roles and data ownership. Test direct object references, list endpoints, update endpoints, and any route that reveals whether a record exists. A clean denial on read does not guarantee a clean denial on update. In practice, the dangerous bug is often the one extra method the backend forgot to protect.

Probe validation, resource limits, and business flows

Schema and input abuse

Test the API against the schema with positive, negative, and boundary cases. Positive tests confirm valid inputs work; negative tests confirm invalid types, missing fields, and wrong formats fail; boundary tests check length, depth, count, and numeric limits. In JSON APIs, look for mass assignment, where extra fields such as role or is_admin are accepted even though they should be server-controlled. Also test parameter pollution, unsupported HTTP methods, and parser edge cases around file uploads and content types.

  • Mass assignment — send extra JSON fields and check whether the server overwrites protected attributes.

  • Parameter pollution — repeat the same parameter in multiple places and inspect precedence.

  • Method abuse — try PUT, PATCH, DELETE, and unexpected OPTIONS behavior on sensitive routes.

  • Parser edges — vary content type, file extensions, encodings, and malformed bodies.

Consumption and workflow abuse

Resource exhaustion is a real API risk, so test burst requests, large payloads, deep pagination, expensive filters, and concurrent token use. A rate limit that exists on paper but falls apart under parallel requests is still a flaw. Then move to business-flow abuse: checkout, payout, password reset, invitation, and refund flows often break in places a generic scanner never understands. That is where you catch duplicate redemption, replay, or state changes out of order.

For remediation planning, the pressure is real. IBM reported that the global average cost of a data breach fell to $4.44 million in 2025, and the average was measured across 600 breached organizations between March 2024 and February 2025, according to https://newsroom.ibm.com/2025-07-30-ibm-report-13-of-organizations-reported-breaches-of-ai-models-or-applications,-97-of-which-reported-lacking-proper-ai-access-controls. You do not need that exact number to justify fixing API exposure, but it explains why weak authz and replayable flows are expensive.

  • Burst traffic — send parallel requests and watch for weak throttling or queue collapse.

  • Deep paging — request large offsets or cursors to see whether the API burns cycles unnecessarily.

  • Workflow abuse — repeat sensitive steps out of order and confirm the backend blocks them.

Automate the repeatable parts in CI/CD

What to automate

Automate discovery, schema-based fuzzing, and baseline regression checks, then keep human review for authorization edge cases and business logic. Schemathesis is a good example of schema-driven testing, and ZAP can import an OpenAPI spec for API-aware DAST instead of crawling blindly. The value is not that one tool finds everything; the value is that the pipeline catches regressions as the API changes.

Use fail, warn, and pass thresholds in the pipeline. A broken authz control should fail the build; a suspicious but unconfirmed issue can warn; a clean run passes. That keeps the output useful to engineering instead of turning every minor deviation into a hard stop.

What still needs human review

Human judgment is still needed for BOLA/IDOR verification, role boundaries, chained requests, and workflow abuse that depends on timing or state. That is also where a recurring service helps more than a single scan. For teams that need repeat assessments after fixes, the https://fleuret.ai/platform keeps the cadence and evidence together, and the https://fleuret.ai/cassini workflow is one of the ways to structure that follow-up.

Here is the practical split. Automated checks cover the obvious regressions. Manual testing covers the part that still takes judgment: does this user see the wrong object, and can they complete the wrong action all the way through?

The verdict is simple: automate the boring part, not the judgment. That gives you coverage without pretending a scanner can decide every authorization case.

How Fleuret handles REST API penetration testing

Where it fits in the workflow

The right place for Fleuret is after scope and identities are defined, because that is when repeatable work starts. It is the operational layer for recurring API pentests, evidence, and retesting instead of ad hoc scripts. If your API changes every sprint, the hard part is not finding one bug. The hard part is keeping the same test motion alive while the attack surface moves.

That is especially true for teams under frequent release pressure. A small SaaS team might ship twice a week, while a payments or healthcare team may need a tighter cadence because a regression can affect customer-facing flows and audit evidence at the same time.

Teams and use cases it suits

A realistic case is a payments team that needs authenticated API testing, repeat assessments after major releases, and compliance-ready reporting for a production REST API. In that setup, the workflow has to survive handoffs between security, engineering, and audit. We built Fleuret for that kind of repetitive, evidence-heavy work, not for a one-off demo.

If you want the broader vendor view of how we position the process, the https://fleuret.ai/security page and the https://fleuret.ai/demo page show the operating model, while [https://fleuret.ai/blog/api-pentesting-for-nis2-compliance-and-audit-evidence](API pentesting for NIS2 compliance) goes deeper on audit evidence.

That matters because evidence collection is expensive in its own right. According to https://insight.thomsonreuters.com.au/business/resources/resource/top-three-insights-in-the-2023-cost-of-compliance-report, companies with fewer than 500 employees spent on average over 2,000 hours per year on routine compliance activities in 2023, including collecting audit evidence. When the retest output is already tied to the finding, the fix, and the date, you save a lot of rework.

Report findings so engineers can fix them fast

What a useful finding looks like

A useful API finding is reproducible in one request chain and short enough for an engineer to act on. At minimum, include the endpoint, method, prerequisite identity, exact request, expected versus actual result, severity, business impact, remediation, and retest status. If the issue depends on two identities, say so in the finding and attach both request traces.

  • Record the exact route, method, headers, body, and the identity used to reproduce the issue.

  • State the expected result and the actual result in one line each.

  • Explain the business impact in plain words, such as cross-tenant data exposure, unauthorized payout, or account takeover risk.

Retest and close the loop

Reduce false positives by reproducing the issue with the real request chain, not a single raw packet, and by confirming authorization with the second identity where relevant. Triage in this order: internet-exposed authz flaws, auth bypass, sensitive data exposure, resource exhaustion, then lower-risk validation bugs. When the fix lands, rerun the same request chain and mark the finding closed only after the server rejects the abuse in the same context.

In one recent vulnerability report, the average mean time to remediate high- and critical-severity application and API vulnerabilities in 2025 was 54.81 days, according to https://www.edgescan.com/what-the-2026-vulnerability-statistics-report-tells-us-about-the-state-of-security/. That is long enough for a weak API issue to sit in production through several release cycles, which is why retesting has to be built into the workflow rather than left to memory.

Next step

Take the current OpenAPI file, two real user roles, and one production-like test environment, then run the workflow in this order: auth, authorization, schema abuse, resource limits, and business flows. If you need that to happen repeatedly with evidence and retests attached, set up a recurring process instead of treating the pentest as a yearly event. That is the point where a platform like Fleuret saves time without changing the testing logic.


Share this postShare on LinkedIn

Your turn.
En garde.

The Free plan runs SAST, DAST, SCA and secret scanning for 2 users and 10 repos, no call needed. Several apps or an audit deadline? Book a demo instead.