Repository navigation
[SVLS-10205] fix(appsec): replace unmaintained multipart with multer - #1542
Open
litianningdatadog wants to merge 1 commit into
Open
litianningdatadog wants to merge 1 commit into
litianningdatadog wants to merge 1 commit into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
litianningdatadog
marked this pull request as draft
November 25, 2026 16:43
multipart 0.18 is unmaintained (RUSTSEC-2023-0050). Parse AppSec multipart/form-data bodies with multer 3.1 instead and drop the advisory ignore from deny.toml. A truncated final field is still analyzed in part, as before. multer discards its data, so it is taken from the raw body. Fields with an invalid Content-Type, unnamed fields, quoted names containing ';', boundary text inside a value, and transport padding are now handled where multipart stopped or cut the data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
litianningdatadog
force-pushed
the
tianning.li/SVLS-10205
branch
from
November 25, 2026 16:50
d7f693c to
b48ed8f
Compare
Contributor
Author
|
@codex review |
litianningdatadog
marked this pull request as ready for review
November 25, 2026 16:52
|
This comment will be updated automatically if new data arrives. 🔗 Commit SHA: b48ed8f | Docs | View more details | Give us feedback! |
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.
Problem
AppSec parses
multipart/form-datarequest bodies withmultipart0.18. That crate is unmaintained (RUSTSEC-2023-0050), anddeny.tomlignored the advisory with no replacement planned.Cause
multiparthas had no release since 2021. It also pulls inbuf_redux,mime_guess,quick-error,safemem,twowayandunicase.This PR
multipartwithmulter3.1 and removes the RUSTSEC-2023-0050 ignore fromdeny.toml.multeronly has an async API.read_multipart_fieldsputs the in-memory body into a single-chunk stream and drives it withfutures::executor::block_on. The stream is always ready, so the call never waits.read_multipart_fields, andblock_oncannot be nested.executorfeature offutures.futures-executorwas already in the dependency tree.multipartdid.multerreturnsIncompleteFieldDataand discards the buffered bytes, sotruncated_field_datatakes the data after that part's headers from the raw body. Truncation is still logged at WARN, as before.Behavior changes:
nameinContent-Dispositionis skipped, and parsing continues.multipartstopped at that field and dropped every field after it.Content-Typeis parsed astext/plain.multipartstopped at that field.;(for examplename="a;b") is kept whole.multipartcut it at the;.x--Bywith boundaryB) is kept whole.multipartcut the value there and stopped.multipartrejected the body.A differential run of both crates on 26 bodies found these as the only differences. Fields, content types and values matched for duplicate names, file uploads, preamble and epilogue, lowercase headers, unquoted and UTF-8 names, and empty values.
Testing
Test 1: unit tests
Steps
cargo test --lib try_parse_bodyResult
9 tests pass. The 7 new tests cover a nested multipart body, a truncated body whose final field is still analyzed in part, unnamed fields being skipped, boundary transport padding, an invalid field
Content-Type, a quoted name containing;, and boundary text inside a value.Test 2: attack detection through the WAF
Steps
cargo test --test appsec_processor_testResult
test_processor_detects_attack_in_multipart_fieldsends an API Gateway HTTP event with a<script>payload in the multipart fieldcomment, using the default ruleset. The span getsappsec.event: trueand aserver.request.bodymatch with key path["comment"]. With the content type changed totext/plain, the test fails, because the WAF still matches but without the field key path.Test 3: clippy
Steps
cargo clippy --workspace --all-targets --features default, onmainand on this branch.Result
Same error count on both, so this change adds no new warnings. The errors come from the local rustc 1.99 toolchain.
Test 4: deployed function
Steps
DD_SERVERLESS_APPSEC_ENABLED=true,AWS_LAMBDA_EXEC_WRAPPER=/opt/datadog_wrapperandDD_LOG_LEVEL=debug.multipart/form-datarequests, each with a<script>payload in the fieldcomment:ok.comment.aap:lines in CloudWatch.Result
multipart)multer){comment}{comment}{comment, ok}{}failed to read multipart body entry comment: field "comment" received with incomplete data, and the truncated field still reaches the WAF.expected additional data after Content-Disposition type: form-dataand analyzes no fields. On this branch the unnamed field is skipped andcommentis analyzed.🤖 Generated with Claude Code