test(security): add path traversal regression tests for WebviewAssetServer#567
Open
laileni-aws wants to merge 1 commit into
Open
test(security): add path traversal regression tests for WebviewAssetServer#567laileni-aws wants to merge 1 commit into
laileni-aws wants to merge 1 commit into
Conversation
…erver Add three security regression tests to WebviewAssetServerTest: - rejectsPathTraversalWithForbidden: verifies that a ../-style traversal request is rejected (400/403) and does not leak file contents from outside the served base directory. - rejectsInvalidPathWithBadRequest: verifies that a percent-encoded null byte (%00) in the path yields a 400 Bad Request response. - servesDeeplyNestedAssetWithoutOverBlocking: positive regression test confirming deeply-nested legitimate assets (js/vendor/lib.js) still serve 200, proving the guard does not over-block. These tests lock in the security invariant from PR aws#562 (commit d38b578) that a path traversal request cannot escape the base directory.
kmmcclai
approved these changes
Jul 16, 2026
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.
Summary
Add three security regression tests to
WebviewAssetServerTestthat lock in the path-traversal guard introduced in PR #562 (commit d38b578).New tests
rejectsPathTraversalWithForbidden../-style traversal request is rejected (400 or 403) and does NOT leak content from outside the base directoryrejectsInvalidPathWithBadRequest%00) in the path yields 400servesDeeplyNestedAssetWithoutOverBlockingjs/vendor/lib.js) still serves 200, proving the guard does not over-blockWhy
The
StaticFileHandlerpath traversal guard is a security-critical invariant. Without a regression test, a future refactor could silently reopen the traversal vector. These tests ensure the invariant is permanently locked in.Testing
All tests follow the existing
@TempDir+HttpClientpattern already used in the file. CI (Maven/Tycho) validates.