// HackTricks · Network Services

Go net/http path handling with CONNECT

Go net/http path handling with CONNECT

Historical ServeMux behavior

In the referenced version of Go’s net/http package, ServeMux.Handler canonicalizes the URL path for ordinary HTTP methods. It calls cleanPath and redirects the client when the clean result differs from the supplied path. This removes . and .. segments and repeated slashes.[1]

For example, ordinary requests for /flag/, /../flag, or /flag/. can be redirected to the canonical /flag path, depending on the registered handler and trailing-slash behavior.[1]

The historical implementation treats CONNECT specially and does not run its path through this canonicalization branch. Consequently, middleware or routing logic that assumes every request has already received a cleaned path may interpret a CONNECT target differently from another method. Whether this produces a security bypass depends on the Go version, handler registrations, proxies, and authorization checks in the application.[1]

Use curl’s --path-as-is option to prevent curl from normalizing the target before sending it.[2] For example:

curl --path-as-is -X CONNECT http://gofs.web.jctf.pro/../flag

Compare the response with requests using a normal method and a canonical path. A different response is only an indicator; confirm that the discrepancy crosses an authorization boundary before reporting it.

References

☧ CPTS · ordered posts

Locked

Unlock with your Main_Key through local GPG.

Start the local GPG helper

In your cheatsheet checkout, run:

npm run unlock:helper

Open the link it prints, or paste its pairing code below. Keep the terminal open until GPG finishes.

Import an index you already decrypted

Download the encrypted index, then decrypt with GPG:

gpg --output report-index.json --decrypt report-index.gpg

Your private key stays in GPG. The decrypted index is saved in this browser so you can reopen it after navigation, refreshes and restarts. Lock this browser or clear this site's browser data to remove the saved index. Nothing is uploaded.