fix(nginx,h2o): reject unknown HTTP methods with 405#99
Merged
Conversation
Contributor
|
@BennyFranciscus fix the validation for nginx-openresty, have the same problem. |
Both nginx module and h2o were accepting any HTTP method (GETT, FOOBAR, etc.) and returning 200, failing the validate.sh bad method check. nginx changes: - Add method guard at top of handler: only GET/HEAD/POST allowed, else 405 - Change fallthrough from NGX_DECLINED to 404 so unknown paths don't leak to nginx's default handler h2o changes: - Add reject_bad_method() helper checking for GET/HEAD/POST - Guard all route handlers (pipeline, baseline11, baseline2, json, static, compression, db) — upload already checks for POST Both now return 405 Method Not Allowed for unknown methods. Fixes validate.sh bad method test for nginx and h2o.
6c56663 to
e7b5a19
Compare
Collaborator
Author
|
Good catch @joanhey — pushed a fix for nginx-openresty too. Added an |
MDA2AV
approved these changes
Mar 25, 2026
BennyFranciscus
added a commit
to BennyFranciscus/HttpArena
that referenced
this pull request
Mar 25, 2026
…nknown paths Same fix pattern as PR MDA2AV#99 (nginx/h2o/openresty): - Add rejectBadMethod() helper: only GET/HEAD/POST allowed, else 405 - Unknown paths now return 404 instead of falling through to next handler
This was referenced Mar 25, 2026
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.
As requested in #98 — fixes the
bad methodvalidation failure for both nginx and h2o.Problem
Both the nginx module and h2o accept any HTTP method (
GETT,FOOBAR, etc.) and return 200, failing thevalidate.shbad method check:Changes
nginx (
ngx_http_httparena_module.c)GET/HEAD/POSTare allowed, everything else gets405 Method Not AllowedNGX_DECLINED(which passed to nginx default → 200) to a proper404 Not Foundfor unknown pathsh2o (
src/main.c)reject_bad_method()helper that checks forGET/HEAD/POSTBoth return
405for unknown methods, which satisfies the validate.sh4xxcheck.