You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resteasy: exclude filename-bearing parts from the body-map cap
A part declaring Content-Type: text/plain but also carrying a
filename attribute was still treated as a form field by
collectBodyMap(), so an attacker could pad the body-map cap with
disposable text/plain file parts and push a genuine field out of
server.request.body. Exclude any part with a filename attribute
(present, even empty) regardless of its declared media type, matching
the file/field distinction collectFilesContent() already uses.
Addresses a P1 finding from the Codex review on PR #12085.
Copy file name to clipboardExpand all lines: dd-java-agent/instrumentation/resteasy/resteasy-appsec-3.0/src/main/java/datadog/trace/instrumentation/resteasy/MultipartHelper.java
+40-15Lines changed: 40 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -42,20 +42,24 @@ private MultipartHelper() {}
42
42
/**
43
43
* Builds the {@code server.request.body} map out of the multipart parts.
44
44
*
45
-
* <p>Only text/plain parts are collected, matching the Jersey reference: file parts are reported
46
-
* separately via {@link #collectFilenames} / {@link #collectFilesContent} and must not also
47
-
* consume the body-map budget. The number of collected values is capped by {@link
48
-
* #MAX_FILES_TO_INSPECT}. The cap counts the total accumulated values across all field names, not
49
-
* the distinct keys: {@code getFormDataMap()} already groups parts by field name, so a per-key
50
-
* cap would be trivially bypassed by repeating the same field name on every part.
45
+
* <p>Only text/plain parts with no {@code filename} attribute are collected, matching the intent
46
+
* of the Jersey reference: file parts (including a file declared with a {@code text/plain}
47
+
* content-type) are reported separately via {@link #collectFilenames} / {@link
48
+
* #collectFilesContent} and must not also consume the body-map budget, or a request could pad out
49
+
* the cap with disposable text-file parts and push a real form field out of the map. The number
50
+
* of collected values is capped by {@link #MAX_FILES_TO_INSPECT}. The cap counts the total
51
+
* accumulated values across all field names, not the distinct keys: {@code getFormDataMap()}
52
+
* already groups parts by field name, so a per-key cap would be trivially bypassed by repeating
0 commit comments