Skip to content

Commit f76f389

Browse files
committed
fix(appsec): cap number of file contents sent to WAF at 25
Without a bound, uploading N files would pass up to N × 4096 bytes to the WAF in a single call. MAX_FILES_TO_INSPECT = 25 limits total content to at most 100 KB, consistent with the per-file MAX_CONTENT_BYTES cap.
1 parent 2076c7b commit f76f389

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

dd-java-agent/instrumentation/commons-fileupload-1.5/src/main/java/datadog/trace/instrumentation/commons/fileupload/CommonsFileUploadAppSecModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ static void after(
109109
}
110110
List<String> filesContent = new ArrayList<>();
111111
for (FileItem fileItem : fileItems) {
112+
if (filesContent.size() >= FileItemContentReader.MAX_FILES_TO_INSPECT) {
113+
break;
114+
}
112115
if (fileItem.isFormField()) {
113116
continue;
114117
}

dd-java-agent/instrumentation/commons-fileupload-1.5/src/main/java/datadog/trace/instrumentation/commons/fileupload/FileItemContentReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/** Helper class injected into the application classloader by the AppSec instrumentation. */
99
public final class FileItemContentReader {
1010
public static final int MAX_CONTENT_BYTES = 4096;
11+
public static final int MAX_FILES_TO_INSPECT = 25;
1112

1213
public static String readContent(FileItem fileItem) {
1314
try (InputStream is = fileItem.getInputStream()) {

0 commit comments

Comments
 (0)