fix(csp): flag wildcard object-src as a security risk#59
Open
dmchaledev wants to merge 1 commit into
Open
Conversation
object-src was missing from the wildcard-directive check. An explicit `object-src *` allowed plugins (Flash, Java applets) to load from any origin, bypassing even a strict script-src, because plugin content is not subject to CSP script controls. Adds object-src to the checked directive list and two covering tests. https://claude.ai/code/session_012BC1VP4X5zcbRhbqd8SyRB
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.
Problem
object-srcwas missing from the wildcard-directive check incheckCSP. This meant a policy like:received no penalty despite the wildcard, earning the same score as a policy with no wildcard at all.
This matters because
object-srccontrols plugin content (Flash, Java applets,<object>/<embed>elements). A wildcard there lets attackers load malicious plugins from any origin — completely bypassing a strictscript-src— since plugin execution is not subject to CSP script controls. Google's CSP guide and OWASP both recommendobject-src 'none'explicitly.Fix
Add
object-srcto thewildcardDirectivesarray incheckCSP(src/rules.tsline 116). The existing wildcard-detection logic already handles everything else; this is a one-line addition to the directive list.Tests
Two new test cases in
test/analyzer.test.ts:detects wildcard in object-src— confirmsobject-src *is flagged and reduces scoredoes not flag a restrictive object-src— confirmsobject-src 'none'earns no penaltyAll 84 tests pass.
Test plan
npm test— all 84 tests pass, including the 2 new onesobject-src *triggers the "Wildcard (*) source in object-src" findingobject-src 'none'is not flaggedhttps://claude.ai/code/session_012BC1VP4X5zcbRhbqd8SyRB
Generated by Claude Code