Add server.request.body.filenames AppSec address for Vert.x 3.4, 4.0 and 5.0#11268
Open
jandro996 wants to merge 13 commits into
Open
Add server.request.body.filenames AppSec address for Vert.x 3.4, 4.0 and 5.0#11268jandro996 wants to merge 13 commits into
jandro996 wants to merge 13 commits into
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.
Member
Author
|
@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
Contributor
|
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.
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.
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.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.