Block dangerous extensions in static asset uploads by default - #6
Open
drdavella wants to merge 1 commit into
Open
Block dangerous extensions in static asset uploads by default#6drdavella wants to merge 1 commit into
drdavella wants to merge 1 commit into
Conversation
validateFileExtension previously did nothing when both allowedFileExtensions and disabledFileExtensions were empty (the out-of-the-box configuration), meaning any extension was accepted. Add a hardcoded baseline blocklist of extensions commonly used to smuggle executable content into a static asset store (jsp/jspx/php variants, asp/aspx, exe/bat/cmd/sh/ps1, war/ear/jar/class, svg, htaccess). The blocklist runs before the config-driven allow/deny checks and cannot be disabled, so a misconfigured deployment still gets a baseline of protection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
New Issues (3)Checkmarx found the following issues in this Pull Request
Communicate with Checkmarx by submitting a PR comment with @Checkmarx followed by one of the supported commands. Learn about the supported commands here. |
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
StaticAssetServiceImpl.validateFileExtension.Why
validateFileExtensioncurrently short-circuits to "accept anything" when bothallowedFileExtensionsanddisabledFileExtensionsare empty, which is the out-of-the-box configuration. A misconfigured deployment can therefore accept.jsp,.php,.war,.class,.svg(which can carry inline script), etc., through the admin asset upload endpoints.The new baseline blocklist covers server-side script types (jsp, jspx, jspf, php variants, asp/aspx, cshtml, cer), native executables (exe, com, bat, cmd, sh, ps1), Java archives (war, ear, jar, class), htaccess, and svg. It runs first, so operators who set their own allow/deny lists still get this floor of protection.
Test plan
mvn -pl admin/broadleaf-contentmanagement-module -am compilepayload.jspvia/{sectionKey}/{id}/uploadAssetand confirm it is rejected with the existing "Invalid extension type of file." IOException, even with nodisabled.file.extensionsconfigured.jpgand confirm it still succeedsNotes for reviewers
This tweaks a security control referenced in the repo threat model ("file upload abuse / path handling issues"). The current threat model notes that upload routes "appear to inspect file names/extensions" — this PR upgrades that from "appears to" to "always rejects a hardcoded floor of dangerous types." The mitigations line for that section should be updated.
🤖 Generated with Claude Code