How to Find Shadow and Undocumented APIs Before Attackers Do
Shadow APIs are endpoints that are live and reachable but missing from your documentation, gateway config or security testing scope: an old /v1 that still routes, a staging API on a forgotten subdomain, a debug route a developer added for one release. To find them, you run API endpoint discovery the way an attacker would, collecting candidate hosts and routes from DNS, certificate transparency logs, JavaScript bundles, mobile apps, web archives and route brute-forcing, then diffing what actually responds against what you think you run. This post walks through that process with commands you can use on domains you own.
Only run these techniques against assets you own or have written authorization to test. Passive sources (certificate logs, archives) are safe anywhere; active probing and brute-forcing are not.
Why shadow APIs matter
OWASP lists this problem as API9:2023 Improper Inventory Management, rated easy to exploit and widespread in prevalence. The reason is simple: old and unofficial endpoints rarely get the same controls as the main API. OWASP's example describes a beta API host that ran the same password-reset functionality as production, but without the rate limiting that sat in front of the production API, so a researcher could brute-force the 6-digit reset token and reset any user's password.
OWASP also notes that "different API versions/deployments are connected to the same database with real data." A forgotten API isn't a forgotten copy of the data. It's often a second door to the same data with fewer locks.
Shadow APIs typically come from:
- Versioning without retirement.
v2ships,v1stays up "for a few clients," and nobody owns turning it off. - Non-production environments on public DNS.
staging-api,dev-api,qa,preview-1234. - Internal endpoints exposed by routing changes. Admin, metrics and health routes that were meant to be internal-only.
- Framework defaults. Spring Boot actuator routes, auto-generated Swagger UIs, GraphQL IDEs.
- Mobile and partner APIs. Built by different teams, often on separate hosts with separate auth.
- Acquisitions and side projects. Entire stacks nobody on the current team built.
Step 1: Enumerate hosts
Every API lives on a host, so start with the host list. Certificate transparency (CT) logs record certificates issued for your domains, which makes them one of the best passive sources for subdomains. You can query them through crt.sh:
curl -s "https://crt.sh/?q=%25.example.com&output=json" \
| jq -r '.[].name_value' | sed 's/\*\.//' | sort -u > hosts.txt
grep -Ei 'api|graphql|gql|staging|dev|beta|internal|admin|v[0-9]' hosts.txt
Combine CT data with DNS records, your cloud provider's DNS zones and load balancer configs. Our Certificate Transparency scanner and Reconnaissance Engine automate this part, and How to Map Your External Attack Surface covers host discovery in more depth. While you're there, check for dangling records; an API subdomain pointing at a deprovisioned service is a subdomain takeover waiting to happen.
Step 2: Mine historical URLs
The Internet Archive's Wayback CDX API returns every captured URL for a domain. API paths from years ago often still resolve.
curl -s "https://web.archive.org/cdx/search/cdx?url=example.com&matchType=domain&fl=original&collapse=urlkey" \
| grep -Ei '/(api|v[0-9]+|graphql|rest|internal|admin)/' \
| sed -E 's/\?.*//' | sort -u > archived_api_paths.txt
matchType=domain includes subdomains, fl=original returns just the URL, and collapse=urlkey removes duplicate captures, all per the CDX server documentation. The Archival Intelligence scanner runs the same kind of historical asset and endpoint discovery for verified domains.
Step 3: Pull routes out of client code
Your frontend and mobile apps are a list of API calls compiled into a file anyone can download. Fetch your production bundles and grep for path-like strings:
# List JS files referenced by the page, then extract API-looking paths
curl -s https://app.example.com/ | grep -oE 'src="[^"]+\.js"' | cut -d'"' -f2 > js_files.txt
while read -r f; do
case "$f" in http*) url="$f" ;; *) url="https://app.example.com$f" ;; esac
curl -s "$url" | grep -oE '"/(api|v[0-9]+|graphql)[A-Za-z0-9_/{}.:-]*"'
done < js_files.txt | sort -u
Look for routes your current UI never calls: feature-flagged screens, admin panels compiled into the main bundle, and hardcoded hostnames for other environments. Source maps (.js.map) are worth checking too; if they're public, they expose original source paths. Bundles also leak keys, which we cover in Scan Your JavaScript Bundles for Leaked API Keys and automate with the JS Secrets Scanner. For mobile apps, the Android Binary Analysis and iOS App Audit scanners inspect the app packages.
Step 4: Probe for specs, docs and framework routes
Check each API host for exposed specs and default routes. A short, low-volume list catches a lot:
for h in $(cat api_hosts.txt); do
for p in /swagger.json /openapi.json /v2/api-docs /v3/api-docs /swagger-ui.html \
/api-docs /graphql /actuator /actuator/mappings /actuator/env /.well-known/openapi.json; do
code=$(curl -s -o /dev/null -w "%{http_code}" "https://$h$p")
[ "$code" != "404" ] && echo "$code https://$h$p"
done
done
An exposed OpenAPI file is both a finding and a gift: it lists every route the developers defined, which you can diff against your official docs. Spring Boot actuator routes deserve special attention. Per the Spring Boot docs, mappings lists every @RequestMapping path (a ready-made route inventory), env exposes environment properties, and heapdump returns a JVM heap dump. Spring warns that endpoints "may contain sensitive information," so any of these answering publicly is a finding worth fixing on its own.
Step 5: Brute-force API routes (carefully)
Traditional directory brute-forcing works poorly on APIs, because an API route often only responds to the right method, headers and body. Kiterunner was built for this: it uses a dataset compiled from Swagger specifications to send requests with the correct HTTP method, headers, paths and parameters. From its README:
kr scan targets.txt -A=apiroutes-210228:20000 -x 10 --ignore-length=34
Keep concurrency low on production, run it from an IP you've told your team about, and only against hosts in scope. Also try version siblings by hand: if /api/v3/users exists, request /api/v1/users and /api/v2/users and compare auth behavior. For general hidden files and directories, the Asset Fuzzer covers that side.
Step 6: Diff against your inventory and triage
Now combine everything into one list and compare it with what you expected. A spreadsheet is fine:
| Host / route | Source | Documented? | Owner | Auth required? | Data it touches | Action |
|---|---|---|---|---|---|---|
api.example.com/v3/* | Spec | Yes | Platform | Yes | Prod | Keep, test |
api.example.com/v1/users | Archive + probe | No | Unknown | No | Prod | Fix now |
staging-api.example.com | CT logs | No | Platform | Yes | Prod copy | Restrict or remove |
app.example.com/actuator/env | Probe | No | Backend | No | Config | Block now |
partner.example.com/graphql | JS bundle | Partial | Integrations | Yes | Prod | Test |
Prioritize anything that is unauthenticated, touches production data, or runs older code than the current API. For each shadow API you find, either bring it into scope (document it, put it behind the gateway, test it) or shut it down. OWASP's API9 guidance recommends inventorying environment, network audience and version for every host, generating documentation in CI/CD, keeping production data out of non-production APIs, and protecting every exposed version, not just the current one.
Make discovery continuous
A one-time sweep goes stale quickly, because every deploy can add a route or a host. Practical options:
- Generate OpenAPI specs from code in CI and fail builds when undocumented routes appear.
- Alert on new certificates issued for your domains.
- Re-run discovery on a schedule and diff the results against last time.
- Add newly found endpoints to your API security testing scope automatically.
SecurityInfinity's API Endpoint Discovery scanner enumerates REST and GraphQL endpoints and hidden routes on domains you've verified (DNS TXT record or matching work email), using read-only checks. The Pro plan ($9/month, see pricing) adds continuous monitoring and re-scans across all agents, so new exposures show up without a manual sweep. If you find a GraphQL endpoint along the way, follow up with our GraphQL security testing guide. Start a scan on your main domain and see what's answering that you didn't know about.
Frequently asked questions
What is a shadow API?
A shadow API is an API endpoint that is running and reachable but isn't tracked in your official inventory, documentation or security testing. Common examples are deprecated versions that were never shut down, staging or dev APIs on public DNS, and debug or framework routes left enabled. OWASP covers this risk as API9:2023 Improper Inventory Management.
What is the difference between a shadow API and a zombie API?
The terms are used loosely, but a shadow API usually means one that was never documented or approved, while a zombie API is one that was deprecated but never actually turned off. Both are outside your normal controls, and both are found with the same discovery techniques.
How do attackers find undocumented API endpoints?
They combine passive sources such as certificate transparency logs, DNS records and web archives with active techniques: reading JavaScript bundles and mobile apps for route strings, requesting common spec and debug paths, and brute-forcing routes with API-aware tools such as Kiterunner. OWASP notes that simple Google dorking and DNS enumeration are often enough to find exposed API hosts.
Can an API gateway find shadow APIs?
Only partially. A gateway sees traffic for the APIs routed through it, so endpoints that bypass it, such as a staging host, an old load balancer or a service exposed directly from a container platform, won't show up. External discovery from the attacker's point of view is needed to catch those.
How often should API endpoint discovery run?
Ideally continuously or on every deploy, since new routes and hosts appear with each release. At minimum, re-run discovery before every penetration test so the test scope matches what's actually exposed. See How Often Should You Run a Penetration Test? for how testing cadence fits in.