Reject oversized request parameters at authorization endpoint with HTTP 414#322
Reject oversized request parameters at authorization endpoint with HTTP 414#322
Conversation
Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
… and remove reflection from tests Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
|
@copilot The validation must also take place for a POST authorization request. Change the |
…both GET and POST requests Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
Updated the validation to check the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…cation Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
|
@copilot What is your opinion on making the following change? |
Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
... Good suggestion! Using URL-encoded size is more accurate since it matches the actual byte size when parameters are transmitted in URLs or included in response headers (which is what caused the original The URL encoding accounts for special characters that expand (e.g., space → Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…rge parameters Co-authored-by: oharsta <530657+oharsta@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #322 +/- ##
============================================
+ Coverage 89.93% 90.00% +0.07%
- Complexity 665 673 +8
============================================
Files 86 87 +1
Lines 2424 2442 +18
Branches 276 277 +1
============================================
+ Hits 2180 2198 +18
Misses 129 129
Partials 115 115 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Production incident: authorization requests with malformed parameters (e.g.,
scope=openid+openid+openid...repeated 1000+ times) proceeded through authentication but failed post-auth withHeadersTooLargeExceptiondue to response headers exceeding buffer limits.Changes
UriTooLongExceptionreturns HTTP 414 statusmax-query-param-sizeproperty inapplication.ymlImplementation
Validation occurs at the start of
AuthorizationEndpoint.authorize(), rejecting malformed requests before SAML authentication. The implementation validates the@RequestParam MultiValueMap<String, String> parametersdirectly, ensuring both GET and POST authorization requests are protected. The URL-encoded size calculation ensures accurate measurement of the actual transmitted size, including expansion of special characters (e.g., space →%20), which is what causes theHeadersTooLargeExceptionin production. The incremental calculation with early exit optimization prevents heap issues from the validation itself.Original prompt
This section details on the original issue you should resolve
<issue_title>Check parameter size to avoid heap problems</issue_title>
<issue_description>In production, we saw the following authn request: