Gouri Sankar A created WW-5878:
----------------------------------

             Summary: File upload rejection logs forge lines from unnormalized 
request-derived values
                 Key: WW-5878
                 URL: https://issues.apache.org/jira/browse/WW-5878
             Project: Struts 2
          Issue Type: Bug
          Components: Core Interceptors
    Affects Versions: 7.5.1, 7.5.0, 7.4.0, 7.3.0, 7.2.1, 7.1.1, 7.0.0, 6.13.0, 
6.12.0
            Reporter: Gouri Sankar A


AbstractFileUploadInterceptor.acceptFile() logs its rejection messages (missing 
file, unresolved policy, oversized file, disallowed content type, disallowed 
extension) with the request-supplied field name, original filename and content 
type interpolated unchanged. ActionFileUploadInterceptor's own "no file 
uploaded for this field" message and 
AbstractMultiPartRequest.createTemporaryFile()'s debug log do the same with the 
field name and original filename respectively. A decoded line break in any of 
these values produces a forged line in the application log.

The rest of the upload code already normalizes equivalent values: 
JakartaMultiPartRequest and JakartaStreamMultiPartRequest wrap every 
attacker-controlled name in StringUtils.normalizeSpace(...) before logging it, 
and AbstractMultiPartRequest itself does the same at its other log call sites. 
These are the only remaining unnormalized sites in the upload path.

Proposal: apply StringUtils.normalizeSpace(...) at the same seven call sites, 
matching WW-5752's fix for the other request-derived log messages. 
UploadedFile.getName() (the generated temp file name) is left as is; it is 
never request-derived.

Tests: regression tests for a line break in the field name, original filename 
and content type, each proven to fail without the fix (LogCapture, the same 
test helper WW-5752 added).

Full core suite: 3813 run, 0 failures, 0 errors, 2 skipped. RAT: no issues.

Affected Version/s: 6.12.0, 6.13.0, 7.0.0, 7.1.1, 7.2.1, 7.3.0, 7.4.0, 7.5.0, 
7.5.1 for the acceptFile()/ActionFileUploadInterceptor sites (confirmed present 
unchanged on STRUTS_6_12_0, STRUTS_6_13_0, STRUTS_7_4_0 and STRUTS_7_5_1). The 
AbstractMultiPartRequest.createTemporaryFile() site is 7.x only, first present 
in 7.1.1 (not present on 7.0.0/7.0.3, where the shared method did not yet 
exist); still present, unnormalized, on 7.5.1 and main. This one log line was 
missed when WW-5501 normalized every neighbouring log call on the branch that 
became Struts 7 in December 2024, and was simply carried forward unnormalized 
when 824e7121b (July 2025) centralized it into AbstractMultiPartRequest.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to