Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default-src takes priority over script-src if it's parsed first #48

Closed
jdm opened this issue Dec 16, 2024 · 1 comment · Fixed by #49
Closed

default-src takes priority over script-src if it's parsed first #48

jdm opened this issue Dec 16, 2024 · 1 comment · Fixed by #49

Comments

@jdm
Copy link
Contributor

jdm commented Dec 16, 2024

The following unit test fails:

#[test]
fn default_is_fallback() {
    let csp_list = CspList::parse("default-src self; script-src self 'unsafe-eval'", PolicySource::Header, PolicyDisposition::Enforce);
    let check_result = csp_list.is_js_evaluation_allowed();
    assert_eq!(check_result, CheckResult::Allowed);
}

default-src is only supposed to take effect if there's no more specific directive, as I understand it.

@jdm
Copy link
Contributor Author

jdm commented Dec 16, 2024

Yeah, step 5.2 of https://www.w3.org/TR/CSP/#can-compile-strings calls out checking for script-src, then looking at default-src if there is none.

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 a pull request may close this issue.

1 participant