Add server.request.body.filenames AppSec address for Vert.x 3.4, 4.0 and 5.0#11268
Conversation
…and 5.0 Instruments RoutingContextImpl.fileUploads() in vertx-web-3.4, vertx-web-4.0 and vertx-web-5.0 to fire EVENTS.requestFilesFilenames() with the list of uploaded filenames, enabling WAF-level blocking on malicious file names.
This comment has been minimized.
This comment has been minimized.
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…mp dirs - Replace em dash with hyphen in UnsupportedOperationException catch comment - Add .gitignore for file-uploads/ in vertx-web-3.4, 4.0, and 5.0 modules to suppress the temporary upload directories created by BodyHandler.create() during test execution
…vertx' into alejandro.gonzalez/APPSEC-61873-vertx
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
The circuit breaker test server uses the legacy expectMultipart+endHandler pattern and never calls fileUploads(), so the filenames tag is never emitted. Opt out explicitly to avoid inheriting the true override from VertxHttpServerForkedTest.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master resultsStartup Time
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What Does This Do
Instruments
RoutingContextImpl.fileUploads()in the Vert.x Web 3.4, 4.0 and 5.0 modules to fire theserver.request.body.filenamesAppSec IG event, enabling WAF-level detection and blocking on uploaded file names.New callsites
vertx-web-3.4: newRoutingContextFilenamesAdvice(returnsSet<FileUpload>), wired inRoutingContextImplInstrumentationvertx-web-4.0: newRoutingContextFilenamesAdvice(returnsCollection<FileUpload>to cover bothSetin 4.0.x andListin 4.5.x+), wired inRoutingContextImplInstrumentationvertx-web-5.0: newRoutingContextFilenamesAdvice(returnsList<FileUpload>) + newRoutingContextImplInstrumentationAll three advice classes use
FileUpload.classas theCallDepthThreadLocalMapkey (public interface, avoidsIllegalAccessErrorwhen ByteBuddy inlines the advice intoRoutingContextImpl).Test server fixes
All four
VertxTestServervariants (3.4, 4.0/test, 4.0/latestDep, 5.0) had a brokenBODY_MULTIPARThandler that usedsetExpectMultipart(true)+ an asyncendHandler, bypassingBodyHandler. This preventedfileUploads()from ever being populated. Replaced with:BodyHandler.create()registered as a prior handler on the same routectx.fileUploads()beforeconvertFormAttributes(ctx)testBodyMultipart()continues to pass becauseBodyHandleralso populatesformAttributes().Added
.gitignorefiles in each module root to suppress thefile-uploads/temporary directories thatBodyHandler.create()creates on disk during test execution.NettyMultipartHelperfixVert.x's internal
NettyFileUploadthrowsUnsupportedOperationExceptionfromgetHttpDataType(). Added a try-catch to skip such items silently - they are handled by Vert.x's own instrumentation. Without the fix, the exception was swallowed by ByteBuddy'ssuppress = Throwable.classbut incrementedINSTRUMENTATION_ERROR_COUNT, causing the Vert.x 5.0 integration tests to fail with "1 instrumentation error". Coverage is provided by the Vert.x 5.0 forked tests in this PR.vertx-rx-3.5fixVertxRxCircuitBreakerHttpServerForkedTestextendsVertxHttpServerForkedTest(vertx-web-3.4) and inherited the newtestBodyFilenames() { true }override. Its internal test server (VertxRxCircuitBreakerWebTestServer) uses the legacyexpectMultipart + endHandlerpattern withoutBodyHandlerorfileUploads(), so the filename tag is never emitted. Added an explicittestBodyFilenames() { false }override, consistent with the existingtestBodyJson(),testRequestBody(), andtestSessionId()overrides in the same class.Motivation
solves APPSEC-61873 (partial - Vert.x coverage)
Additional Notes
Double-instrumentation in 5.0 tests: the
vertx-web-5.0test module includesvertx-web-4.0astestImplementation, so bothRoutingContextImplInstrumentationclasses are applied in the same test run. UsingCollection<FileUpload>in the 4.0 advice (instead ofSet<FileUpload>) was necessary to avoid a ByteBuddy type-mismatch error when Vert.x 4.5.x+ changed the return type offileUploads()fromSettoList. Once the type error was gone, both advices coexist correctly via the sharedCallDepthThreadLocalMapkey.Static reflection pattern:
FILE_UPLOAD_REFis defined as astatic final Referencein eachRoutingContextImplInstrumentation(not aVertxVersionMatcherconstant) because it is only needed by that single class. The 5.0 instrumentation usesHTTP_HEADERS_INTERNAL(io.vertx.core.internal.http.HttpHeadersInternal, absent in 4.x) as the version discriminator to prevent the 5.0 advice from applying to Vert.x 4.x classloaders.JVM constraint: vertx-web-3.4 and vertx-web-4.0 default test set
maxJavaVersion = VERSION_15; tests must be run with-PtestJvm=11viaforkedTest(nottest).Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: APPSEC-61873
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.