API security testing starts with an uncomfortable question: how many endpoints does your application expose today? Not the ones in your OpenAPI spec, but the ones your code actually serves.
For most teams, those two numbers don’t match. The spec was written months ago, the code kept moving, and along the way came internal routes, export endpoints, and old versions nobody documented. These are shadow APIs, and you can’t test what nobody knows exists.
TL;DR
API security testing in two layers: inventory from code, proof at runtime
You can't secure the APIs you don't know you have. API security testing starts with a reliable inventory, and the most reliable source is the code itself, not the spec.
- Inventory drift: comparing code and spec reveals endpoints that exist but aren't documented (shadow APIs) and documented operations nothing serves anymore (orphan APIs), both under OWASP API9:2023.
- Flaws in the handler: many API flaws aren't injection bugs. They are a missing ownership check (BOLA), an admin route without a role check, or a response that returns more fields than it should. You see them best by reading the handler.
- Runtime proof: runtime testing confirms what the code suggests: which endpoints answer without authentication, where your gateway already compensates, and what is exploitable in the deployed application.
- One finding per problem: together, the two layers give you a single finding per issue, ranked by the data it exposes (personal, payment, health, credentials).
The first step: build your API inventory from code, compare it with your OpenAPI spec, then point runtime tests at the full catalog, not just the documented part.
Why typical API security testing falls short
Most teams protect their APIs with three pieces: a gateway that enforces authentication at the edge, a scanner that walks the spec, and a manual pentest once or twice a year. All three help, but they share a blind spot.
They all depend on someone knowing which endpoints exist. The scanner only tests what’s in the spec. The pentest covers the scope it was given. And the gateway enforces authentication at the edge, but it can’t see that the handler never checks whether order 4512 belongs to the user asking for it.
That’s why the OWASP API Security Top 10 dedicates a full category to improper inventory management (API9:2023), and why its number one risk is Broken Object Level Authorization (API1): a logic flaw with no signature and no injection pattern.
Layer 1: an API inventory built from code
Reliable API security testing starts with an inventory built from the one source that doesn’t drift: the code. Xygeni API Security inspects your dependency manifests, detects the web frameworks you use, and extracts every endpoint, including routes declared across several files.
It reads popular web frameworks across the main server-side languages, such as Spring Boot, ASP.NET Core, Django, FastAPI, Express and Laravel, plus OpenAPI 3.x and Swagger 2.x specs. The result is a catalog of services, modules and endpoints, with their methods, parameters, request bodies and response shapes.
With code and spec side by side, drift becomes obvious:
- Shadow APIs: endpoints the code serves, but the spec doesn’t document.
- Orphan APIs: spec operations that no handler serves anymore.
If you’re not ready to switch on detection, discovery mode builds the catalog and its gaps on its own. It’s a good way to open the conversation with development teams without adding noise on day one.
Which flaws you catch by reading the handler
Many API flaws aren’t injection bugs: they’re a missing check. Because Xygeni reads routes, handlers, and specs together, it can express flaws that pattern-based scanners can’t. Every finding maps to its OWASP API Security Top 10 (2023) category and to CWE.
API flaws you catch by reading the code
Each flaw maps to its category in the OWASP API Security Top 10, so findings speak the same language as your auditors and pentesters.
| Flaw | What it looks for in code | OWASP category |
|---|---|---|
| Broken Object Level AuthorizationBOLA / IDOR | Endpoints that load an object by an ID from the request without checking it belongs to the user | API1 |
| Excessive data exposure | Responses that return more fields than needed | API3 |
| Broken Function Level Authorization | Admin routes without a role check | API5 |
| Unauthenticated endpoints and mass assignment | Open routes, and request bodies that accept fields they shouldn't | API2 and API3 |
| Shadow and orphan APIs | Differences between code and spec | API9 |
For BOLA, per-language analysis looks for ownership checks, repository scoping, and identity binding. It also resolves authorization rules declared centrally in your framework configuration, and you can add the names of your own ownership-check functions to cut noise further. GraphQL APIs get their own specific checks.
The detail that changes prioritization: every field is tagged as personal, payment, health, credential, or cryptographic data. An unauthenticated endpoint returning personal data is ranked critical, instead of getting lost in the queue behind a hundred minor findings.
Layer 2: runtime testing
Code tells you what could happen. Runtime testing tells you what does happen. Complete API security testing needs both views, and Xygeni connects them through the same endpoint inventory at three levels:
- API Security live check. It sends one non-destructive request per candidate endpoint to confirm or refute authentication findings. If the environment answers 401 or 403, the finding is marked refuted: proof that your gateway already compensates there.
- Xygeni DAST. It tests running web apps and APIs from a signed Docker image that runs in your own CI runners or internal network. Against production it uses passive intensity, which sends no attack payloads. For active testing, the recommendation is a staging environment with a test account.
- AI Pentesting. An AI agent plans and runs non-damaging attacks against authorized targets to prove which findings are exploitable, mapped to the OWASP API Security Top 10.
One problem, one finding
The value of combining the inventory with runtime testing isn’t more alerts. It’s fewer, better ones. AI SAST findings in the handler, DAST findings on the running endpoint, and API flaws are correlated in the ASPM Risk Graph, with sensitivity tags attached.
API inventory from code vs. runtime testing
Neither layer replaces the other. Complete API security testing uses both, connected through the same endpoint inventory:
| Dimension | API inventory from code | Runtime testing |
|---|---|---|
| When it runs | Before deployment, on every pull request | Against the deployed application (staging, or passive in production) |
| What it sees best | Shadow APIs, BOLA, missing role checks, data exposure | What actually answers, environment configuration, exploitability |
| What it gives the other layer | The full catalog of endpoints to test | Confirmation or refutation of what the code suggests |
A flaw in the handler and the exposed endpoint that reaches it are one problem, with one owner. And if you already run another DAST tool, Xygeni imports its results into the same risk view, without asking you to replace it.
Want to see both layers working together? Watch our session From Code to Runtime: Why SAST + DAST Are Both Essential for Modern AppSec, where we walk through how code findings and runtime tests confirm each other.
How to fit API security testing into your development lifecycle
The pattern that works best for mid-sized teams is simple:
- On every pull request: API Security in CI on the changed code, plus incremental DAST scans.
- Before commit: as a pre-commit gate on staged files.
- Nightly or on merge: a full DAST scan.
- Before each major release: AI Pentesting against staging to validate the backlog and confirm each fix closed the hole.
The API Security scanner runs anywhere, including air-gapped environments, and reports to Xygeni SaaS or your on-premise platform. Results come out as JSON, SARIF 2.1.0, CSV and Markdown for pull request comments.
API security testing and compliance
For teams in banking, insurance, or the public sector, API security testing is also evidence. Every finding carries compliance tags for GDPR Article 32, PCI DSS 4.0 (requirements 3.4, 6.4.3, 7.1, 7.2 and 8) and NIST SP 800-53 (AC-3, AC-6, IA-2, IA-5), visible in the platform and in JSON and SARIF output.
If your organization falls under DORA or NIS2, runtime testing gives you continuous evidence between the manual pentests your regulators still require.
Test the API you actually run, not the one you documented
API security testing that only reads the spec tests the API you think you have, not the one you actually run. Start with an inventory built from code, confirm it with runtime testing, and rank every flaw by the data the endpoint exposes.
Want to see every endpoint your code exposes? Book a session with an engineer to build the API inventory of one of your repositories and review its findings. Or start free with code and dependency scanning today!
FAQs
Do I need API security testing if I already have an API gateway?
Yes. A gateway enforces authentication at the edge, but it can’t see a missing ownership check inside a handler or a response that returns too many fields. Xygeni’s live check even shows where your gateway already compensates, by marking those findings as refuted.
How do I find shadow or undocumented APIs?
Compare what your code serves with what your spec documents. Xygeni API Security does this automatically: it discovers endpoints from source code, flags those missing from your OpenAPI or Swagger spec as shadow APIs, and flags spec operations with no handler as orphans.
Is it safe to run runtime tests against production?
With Xygeni DAST’s passive intensity, yes: it sends no attack payloads, lets you cap the request rate and identifies its traffic with the X-Xygeni-DAST header. For active testing and AI Pentesting, the recommendation is a staging environment with a test account.







