cloudflared/proxy/proxy.go
Miguel da Costa Martins Marcelino 3106f9499d VULN-170057: Don't bypass access with matrix parameters
Adding ingress parsing to cover matrix-path parameters. That is, paths that are delimited by semicolons. As an example, with the current normalization logic a path like /public/.;x/../admin would be normalized to /public/admin, which matches the non-Access /public rule. The new parsing logic prevents this from happening by always matching the access /admin path.

Rule matching now receives the request's URL so it can use the escaped path when normalization is enabled. URL.Path is already percent-decoded, so it cannot distinguish literal separators from encoded separators inside parameter values. For example, /admin;x=%2f..%2fpublic becomes /admin;x=/../public. Stripping parameters from that decoded path and then cleaning it incorrectly produces /public. Using URL.EscapedPath() lets us strip the parameter value first, producing /admin. When normalization is disabled, matching continues to use URL.Path.

Because path normalization now involves several steps, I refactored the code into a "pipeline" that applies transformations sequentially. This should clarify the purpose of each step.

The included tests should cover all scenarios: backslashes, trailing dots, repeated slashes, and semicolons.
2026-11-04 17:21:49 +00:00

456 lines
14 KiB