Route Normalization Guard
Check that slugs, encodings, dot segments and duplicate separators all resolve consistently, so admin routes stay admin routes after every rewrite
Use when: the API mixes route matching across gateways, services and frameworks, where each library normalizes URLs slightly differently
Avoid when: a single framework handles all routing and its documented matcher behavior covers the whole request path
Procedure
- Sketch the route chain from edge to handler, noting which layer your privileged checks run in and which normalize paths.
- Build a variant list: encoded slashes, percent-encoded characters, dot segments, cases, trailing slashes and duplicated paths.
- Send your protected list through every variant with your own lower-privileged credential and record the result.
- Watch specifically for variants that add or drop characters from the logged or judged selection, which desyncs layers.
- Repeat the tour with absolute URIs and non-fixed host headers, which some proxy setups treat differently.
- Record the matrix of variants by outcome so a normalizer mismatch is visible at a glance.
Signals
- One variant of the same admin path returns 200 through a less privileged role, proving layers disagree.
- Percent-decoding happens later than authorization, so encoded slugs reach a handler that was judged on another path.
- A prefix rule protects a name exactly, so only literal matches take effect while suffixes with extra traversal slip.
- Trailing-slash handling directs some requests to a separate handler that skips the middleware registration entirely.
Patterns
1. Variant set
/api/admin /api/admin/ /API/Admin \/api%2fadmin \/api/admin%2f \/api//admin \/api/./admin \/api/../admin
2. Layer desync
gateway authorizes /api/admin, handler matches \/api/[a-z]*/admin -> variant variants matching rule differ
3. Result row
path=/api/admin variants=9 admin-authorized-yes=6 allowed-through=3 sample=%2fslash-case
Pitfalls
- Testing variants only against your own endpoints and never against privileged ones where the mismatch actually pays.
- Assuming HTTP-tool behavior equals proxy behavior, then publishing findings the real frontend rejects.
- Reporting the mismatch without characterizing the two layers' normalization, which makes the finding unreproducible.
Done when
- Each string in the variant set is classified by both ends as the same resource or different resources, and the mismatch is recorded.
- Every mismatch is reproduced cleanly once with the exact path, host and headers required to observe it.