fix: preserve semicolon-separated query parameters in proxy requests #1255
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.
Problem
Oathkeeper drops query parameters that use semicolon separators
(e.g., ?param1=value1;param2=value2)when proxying requests to upstream services. This occurs because Go'shttputil.ReverseProxycalls `cleanQueryParams(), which removes semicolon separators as they are considered invalid per RFC 3986.This breaks compatibility with:
Root Cause
The issue originates in Go's standard library net/http/httputil.ReverseProxy.cleanQueryParams() function, which intentionally removes semicolon separators to enforce RFC 3986 compliance. While technically correct, this breaks transparent proxy behavior expected from an identity proxy like Oathkeeper.
Solution
Preserve the original query string by setting `r.Out.URL.RawQuery = r.In.URL.RawQuery after Go's URL processing but before forwarding the request. This follows the pattern documented in Go's httputil.ReverseProxy.Rewrite function documentation for transparent proxies.
Security Considerations
As noted in Go's httputil.ReverseProxy documentation, preserving RawQuery "can lead to security issues if the proxy's interpretation of query parameters does not match that of the downstream server."
Potential risks:
Mitigation:
Backend services should implement proper query parameter validation and sanitization
Operators should monitor for unusual query parameter patterns
Consider implementing additional query parameter filtering if required by your security policy
I believe this is is an inherent trade-off when operating as a transparent proxy: RFC compliance vs. real-world compatibility. The fix prioritizes transparency while requiring operators to ensure backend security.
Related issue(s)
#1248
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
security@ory.sh) from the maintainers to push
the changes.
works.
Further Comments