fix: escape CRLF in multipart/form-data serialization - #605
Merged
Merged
Conversation
… type The multipart/form-data serializer interpolated the field name, filename and blob `type` into the request body without escaping. Because isBlob() is duck-typed and accepts any blob-like object with a string `type`, a value containing CR/LF could inject additional part headers or forged form fields into the multipart body (same class as undici GHSA-m8rv-5g2x-5cg5). Escape `\r`, `\n` and `"` in the field name and filename per the WHATWG multipart/form-data serialization algorithm, and strip CR/LF from the per-part Content-Type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 6, 2026
## [4.3.1](v4.3.0...v4.3.1) (2026-08-06) ### Bug Fixes * escape CRLF in multipart/form-data field name, filename and blob type ([#605](#605)) ([b6571db](b6571db))
|
🎉 This PR is included in version 4.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
Prompted by an audit checking whether this library is affected by the undici v6.28.0 security fixes. It is not —
@adobe/fetchdoes not use undici at runtime, andguessContentTypenever reflects a Blob.typeinto a header. The audit did, however, surface one spot matching the same CRLF-injection pattern, fixed here.The
multipart/form-dataserializer (src/common/formData.js) interpolated the field name, filename and blobtypeinto the request body without escaping. BecauseisBlob()is duck-typed (accepts any blob-like object with a stringtype), a value containing CR/LF could inject additional part headers or forged form fields into the multipart body — the same class as undici GHSA-m8rv-5g2x-5cg5, though lower severity here (multipart body-structure injection, not HTTP header injection — actual request headers remain guarded by Node'shttp.validateHeaderValue).Changes
escapeName()— percent-encodes\r→%0D,\n→%0A,"→%22in the field name and filename, per the WHATWG multipart/form-data serialization algorithm.sanitizeContentType()— strips CR/LF from the per-partContent-Type(a specBlobnormalizes itstype, but the duck-typed check does not).\r\n-prefixed injection reaches the body, values are escaped/stripped, declared length still matches, and no rogue boundary appears.Testing
npx mocha test/common/formData.test.js— 3 passingnpx eslinton changed files — clean🤖 Generated with Claude Code