feat(java): detect content-security-policy response header set to an empty value on a served entrypoint (CWE-693/79) - #156
Open
ai-anant wants to merge 3 commits into
Conversation
…xecution JSON payload (CWE-94)
…permission argument (CWE-862)
…ty on a served entrypoint (CWE-693/79)
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.
Adds a Java/Jenkins rule that flags an HTTP response handler (Stapler
setHeader/setContentSecurityPolicy) which assigns an empty string to the Content-Security-Policy response header while serving an active document (HTML/JS/SVG entrypoint).Why it matters
When a server serves active content whose body embeds data outside the developer's direct control (report/artifact output, user-uploaded content), omitting an effective CSP lets any script in that content execute with full application-origin privileges. The robust pattern is to set a strict
sandbox ...; script-src ...policy (or serve from an isolated origin) on the entrypoint, never an empty value.Rule
java/jenkins/xss/empty-csp-response-entrypoint.yamlsetHeader("Content-Security-Policy", ""),setHeader(<content-security header var>, ""),setContentSecurityPolicy("")Validated with
semgrep --validateand manually tested against a positive repro (empty CSP set then active document served — fires) and a sanitized negative (non-empty sandbox CSP — does not fire).Closest existing open rules differ:
rule/html-missing-csp-meta(PR #133) targets static HTML files missing a CSP meta tag; this rule targets the Java server-side response-header sink that empties an otherwise-effective policy.