bugger.
All challenges/Pythonmediumheaders-on-the-move-v1
THE INVESTIGATION

Headers on the move

Redirect filtering works in one client and leaks credentials in another.

HTTPSecurityNormalization

What’s going wrong

A redirect sanitizer removes configured sensitive headers when a request changes origin. It succeeds for the example used during development, yet equivalent requests from another client can retain credentials.

Input is JSON with `cross_origin` (boolean), `headers` (ordered `[name, value]` pairs), and `remove` (header names). HTTP header names are ASCII and case-insensitive. On a cross-origin redirect, remove every matching pair. Otherwise preserve every pair. Keep the exact spelling, values, duplicates, and order of surviving headers. Print the resulting array as compact JSON.

Origin detection is supplied; the bug is in the sanitizing step.

Expected behavior

Cross-origin redirects remove configured names regardless of capitalization. Same-origin requests and nonmatching names are preserved.

Reproduction

01 Different client spelling
{"cross_origin":true,"headers":[["authorization","secret"],["Accept","text/plain"]],"remove":["Authorization"]}
[["Accept","text/plain"]]
02 Same origin
{"cross_origin":false,"headers":[["Authorization","secret"]],"remove":["Authorization"]}
[["Authorization","secret"]]

Before you begin

  • Lists and comprehensions
  • Strings
  • HTTP header semantics (stated in report)

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.