fix: discovery no longer mistakes 404 error pages for real endpoints#78
Merged
GovindarajanL merged 1 commit intoJul 25, 2026
Merged
Conversation
exploreApiRoots() and testCommonResourcePatterns() treated any non-empty HTTP response body as evidence of a real endpoint, without checking the status code. Since most servers return a non-empty body on a 404 (an error page), every generic path guess against a reachable server was misread as "found something here". Reproduced against OWASP crAPI: auto-discovery reported "Discovered 8 unique endpoints" -- every single one was a 404 page from crAPI's nginx gateway for a generic guessed path (/api, /api/v1, /rest, ...), none of which are real crAPI routes. The scan then ran with 0 real coverage while logging as if discovery had succeeded. Both methods now gate on the response status code (2xx) via getWithStatus(), not just body non-emptiness. Also strengthens the "nothing discovered" warning to explicitly recommend --endpoints-file instead of silently falling back to a generic hardcoded list. Fixes OWASP#73 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #73
Summary
exploreApiRoots()andtestCommonResourcePatterns()treated any non-empty HTTP response body as evidence of a real endpoint, without checking the status code. Since most servers return a non-empty body on a 404 (an error page), every generic path guess against a reachable server was misread as "found something here".Reproduction
Scanned OWASP crAPI (local docker-compose stack, no self-published OpenAPI spec). Auto-discovery reported:
Every single one was a 404 page from crAPI's nginx gateway for a generic guessed path — none are real crAPI routes (which live under
/identity/api/...,/community/api/...,/workshop/api/...). The scan then ran with 0 real coverage while logging as if discovery had succeeded, indistinguishable from "target is secure".Fix
Both methods now gate on the response status code (2xx) via
getWithStatus(), not just body non-emptiness. Also strengthens the "nothing discovered" warning to explicitly name--endpoints-file/--configas the fix, instead of silently falling back to a generic hardcoded endpoint list with no indication that coverage will be poor.Verification
Test plan
mvn testpasses