Skip to content

fix(csp): flag wildcard and bare-scheme sources in object-src#84

Open
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-rpphbo
Open

fix(csp): flag wildcard and bare-scheme sources in object-src#84
dmchaledev wants to merge 1 commit into
mainfrom
claude/nice-mendel-rpphbo

Conversation

@dmchaledev

Copy link
Copy Markdown
Contributor

Problem

checkCSP checked six directives for wildcard (*) and bare-scheme (e.g. https:) sources:

const wildcardDirectives = ['default-src', 'script-src', 'connect-src', 'form-action', 'frame-src', 'worker-src'];

object-src was absent. That means a policy like:

Content-Security-Policy: default-src 'self'; object-src *

would pass the analyzer's wildcard check cleanly, even though object-src * allows loading plugins (Flash, Java applets, PDF viewers) from any origin — a well-documented attack vector historically exploited for arbitrary code execution.

Fix

Add object-src to the wildcardDirectives array. The existing isPermissiveSource helper correctly flags * and bare schemes, so no other logic changes are needed.

- const wildcardDirectives = ['default-src', 'script-src', 'connect-src', 'form-action', 'frame-src', 'worker-src'];
+ const wildcardDirectives = ['default-src', 'script-src', 'connect-src', 'form-action', 'frame-src', 'worker-src', 'object-src'];

Tests added

Three new cases in test/analyzer.test.ts:

Case Expected
object-src * flagged as wildcard
object-src https: flagged as bare scheme
object-src 'none' not flagged (restrictive)

All 88 tests pass.

Why this matters

The security community broadly recommends object-src 'none' as a baseline CSP hardening step (Google CSP evaluator, OWASP CSP cheat sheet). Without this check, the analyzer gives a false sense of security to sites that restrict default-src but leave object-src open.

🤖 Generated with Claude Code

https://claude.ai/code/session_015FdvhyE9g4Z7mtnoWxaziR


Generated by Claude Code

object-src was missing from the list of sensitive fetch directives that
are checked for wildcard (*) and bare-scheme (e.g. https:) sources.
A policy like `default-src 'self'; object-src *` would silently pass the
wildcard check while allowing plugins to be loaded from any origin — a
known attack vector for Flash/Java-based exploits.

Adds three test cases: wildcard in object-src, bare scheme in object-src,
and a negative case confirming object-src 'none' is not flagged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FdvhyE9g4Z7mtnoWxaziR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants