Repository navigation
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



CRLF and quote injection into multipart/form-data part headers
HttpWebConnectionbuilds multipart bodies with ApacheMultipartEntityBuilderin lax (BROWSER_COMPATIBLE) mode, which writes each part's field name and file name straight into theContent-Dispositionheader. A carriage return, line feed or double quote in a name is passed through unescaped, so a script that controls aFormDatafield name or aBlob/Filename can break out of the header and inject extra part headers or whole parts.multipart/form-datais a CORS-safelisted content type, so this travels on a cross-origin POST without a preflight.Minimal trigger,
fd.append('upload', new Blob(['x']), 'a\r\nX-Injected-Part: evil\r\n\r\n...')plusfd.append('na\r\nme', 'val'), produced a body on master with the injected header on its own line and the field name split across two lines. Browsers escape the three bytes in both the field name and the file name (%0D,%0A,%22) per the HTML multipart/form-data encoding algorithm; the fix does the same inescapeMimeFieldbefore the names reach the builder. A legitimate name without those characters serializes exactly as before.HttpWebConnectionTest.buildFilePartEscapesNameAndFilenamefails on master and passes with the change; the HttpWebConnection, HtmlFileInput and CodeStyle tests pass and checkstyle and pmd are clean. I also added a changes.xml entry.