WW-5636 Harden redirect URL escaping in non-302 response body#1737
Conversation
Escape HTML in the final location before writing to the response.
|
JIRA ticket: https://issues.apache.org/jira/browse/WW-5636 |
|
Thanks for the patch and for filing WW-5636. Reviewed and verified against current main. The change is correct. The non-302 branch of A couple of notes for the record:
Neither note is blocking. Happy to merge once the title is adjusted. And a general reminder for the future: suspected security issues are best sent to security@struts.apache.org first rather than opened as a public PR, so we can triage severity before anything lands in the open. In this case the impact is operator-owned, so no harm done. |
|
Thanks for the thorough review. Updated the title to match the hardening framing. Noted on reporting suspected security issues to security@struts.apache.org first — will follow that process going forward. |
Summary
ServletRedirectResult.sendRedirect() writes the redirect target URL
directly to the response body for any statusCode != 302 (e.g. 301, 303,
307, 308, or misconfigured 200), without HTML encoding. Since the servlet
container defaults Content-Type to text/html, this is a reflected XSS
sink when user-controlled content reaches finalLocation via OGNL
expression evaluation (parse=true, the default).
PostbackResult.java (line 108) in the same package already uses
StringEscapeUtils.escapeHtml4() for the identical pattern — this aligns
ServletRedirectResult with the existing convention.
Changes
References