[Java]Fix flakiness in Test_Lfi_BodyUrlEncoded.test_lfi_post_urlencoded for vertx4#6386
Draft
[Java]Fix flakiness in Test_Lfi_BodyUrlEncoded.test_lfi_post_urlencoded for vertx4#6386
Conversation
Contributor
|
|
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.
Motivation
https://datadoghq.atlassian.net/browse/APPSEC-61455
The catch-all RASP route handlers in RaspRouteProvider.java (vertx4) were reading the attack parameter with rc.request().getParam(name) for all non-XML, non-JSON requests:
router.route().path("/rasp/lfi").blockingHandler(rc -> executeLfi(rc, rc.request().getParam(FILE)));
In Vert.x 4, getParam() reads query string parameters. It falls back to form attributes only if isExpectMultipart() is true on the underlying request, which requires the BodyHandler to have called setExpectMultipart(true) before any body data arrives. For small payloads (e.g. file=../etc/passwd) that fit in a single TCP packet, this setup can race against the data arrival under certain conditions (GC pauses, CI scheduler load, JVM JIT state), causing getParam() to return null.
For lfi, shi, sqli, and cmdi, a null parameter causes either a NullPointerException (in new File(null) or String.split()) or silently corrupts the sink input, preventing RASP from evaluating the attack. The result is a non-deterministic 500 Internal Server Error instead of the expected 403.
The flakiness was only observable as a test failure on lfi because executeSql has a broad catch (Throwable) that masks the crash — but all four handlers shared the same underlying bug.
Changes
Added an explicit application/x-www-form-urlencoded route for each affected endpoint this mirrors the existing pattern for application/xml and application/json routes and makes the parameter source explicit and deterministic for each content type. The catch-all with getParam() is preserved for GET requests using query parameters.
Workflow
🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
Reviewer checklist
tests/ormanifests/is modified ? I have the approval from R&P teambuild-XXX-imagelabel is present