[CSP] Add url-hash support to script-src [chromium/src : main]

0 views
Skip to first unread message

Mustafa Emre Acer (Gerrit)

unread,
Jun 13, 2025, 10:11:46 AM6/13/25
to Camille Lamy, Carlos IL, Chromium LUCI CQ, chromium...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, mkwst+w...@chromium.org, network-ser...@chromium.org
Attention needed from Camille Lamy and Carlos IL

Mustafa Emre Acer added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Mustafa Emre Acer . resolved

Hi Camille and Carlos, could you PTAL at this as well? It's not fully ready, I'll need to fix the unit tests and add more of them, but if you could take a preliminary look that would be great. I split this mostly from crrev.com/c/6496953. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Camille Lamy
  • Carlos IL
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I8a538c892ed8b36e061041a6c326a0646315252d
Gerrit-Change-Number: 6641778
Gerrit-PatchSet: 2
Gerrit-Owner: Mustafa Emre Acer <mea...@chromium.org>
Gerrit-Reviewer: Camille Lamy <cl...@chromium.org>
Gerrit-Reviewer: Carlos IL <carl...@chromium.org>
Gerrit-Reviewer: Mustafa Emre Acer <mea...@chromium.org>
Gerrit-Attention: Camille Lamy <cl...@chromium.org>
Gerrit-Attention: Carlos IL <carl...@chromium.org>
Gerrit-Comment-Date: Fri, 13 Jun 2025 14:10:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Carlos IL (Gerrit)

unread,
Jun 13, 2025, 11:36:46 PM6/13/25
to Mustafa Emre Acer, Camille Lamy, Chromium LUCI CQ, chromium...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, mkwst+w...@chromium.org, network-ser...@chromium.org
Attention needed from Camille Lamy and Mustafa Emre Acer

Carlos IL added 2 comments

Patchset-level comments
Carlos IL . resolved

Thanks! For the most part the approach LGTM mod using the separate flag (where I left the comment and also in content_security_policy.cc when parsing).

File third_party/blink/renderer/core/frame/csp/csp_directive_list.cc
Line 933, Patchset 2 (Latest): if (base::FeatureList::IsEnabled(network::features::kCSPScriptSrcV2) &&
Carlos IL . unresolved

I'm cheating since I reviewed this after sending my CL out, but I think we should use the V1 flag here to keep them separate

Open in Gerrit

Related details

Attention is currently required from:
  • Camille Lamy
  • Mustafa Emre Acer
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8a538c892ed8b36e061041a6c326a0646315252d
    Gerrit-Change-Number: 6641778
    Gerrit-PatchSet: 2
    Gerrit-Owner: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Reviewer: Camille Lamy <cl...@chromium.org>
    Gerrit-Reviewer: Carlos IL <carl...@chromium.org>
    Gerrit-Reviewer: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Attention: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Attention: Camille Lamy <cl...@chromium.org>
    Gerrit-Comment-Date: Sat, 14 Jun 2025 03:36:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Camille Lamy (Gerrit)

    unread,
    Jun 17, 2025, 10:06:52 AM6/17/25
    to Mustafa Emre Acer, Carlos IL, Chromium LUCI CQ, chromium...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, mkwst+w...@chromium.org, network-ser...@chromium.org
    Attention needed from Mustafa Emre Acer

    Camille Lamy added 3 comments

    Patchset-level comments
    File-level comment, Patchset 3 (Latest):
    Camille Lamy . resolved

    Thanks! Overall this looks good.

    File services/network/public/cpp/content_security_policy/content_security_policy.cc
    Line 790, Patchset 3 (Latest): if (ParseURLHash(expression, url_hash.get())) {
    Camille Lamy . unresolved

    I think there is also a CSP parser inside blink, should it be updated?

    File third_party/blink/web_tests/external/wpt/content-security-policy/script-src/tentative/script-url-allowed-by-hash.https.html
    Line 27, Patchset 3 (Latest): frame.src = `support/iframe.html?pipe=header(Content-Security-Policy,${policy})`
    Camille Lamy . unresolved

    It would also be good to add tests for CSP in Meta Tags (similar to here). For a meta tag test, it would also be good to check that it cannot relax a CSP set in the header. This can be done in a follow up CL.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mustafa Emre Acer
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8a538c892ed8b36e061041a6c326a0646315252d
    Gerrit-Change-Number: 6641778
    Gerrit-PatchSet: 3
    Gerrit-Owner: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Reviewer: Camille Lamy <cl...@chromium.org>
    Gerrit-Reviewer: Carlos IL <carl...@chromium.org>
    Gerrit-Reviewer: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Attention: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Comment-Date: Tue, 17 Jun 2025 14:06:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mustafa Emre Acer (Gerrit)

    unread,
    Jun 17, 2025, 7:22:34 PM6/17/25
    to Camille Lamy, Carlos IL, Chromium LUCI CQ, chromium...@chromium.org, antoniosarto...@chromium.org, arthursonzog...@chromium.org, blink-revi...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, mkwst+w...@chromium.org, network-ser...@chromium.org
    Attention needed from Camille Lamy and Carlos IL

    Mustafa Emre Acer added 4 comments

    Mustafa Emre Acer . resolved

    PTAL? This doesn't have the hash reporting implemented for url hashes yet. I'll do it in a followup using crrev.com/c/6633943 as the starting point

    File services/network/public/cpp/content_security_policy/content_security_policy.cc
    Line 790, Patchset 3: if (ParseURLHash(expression, url_hash.get())) {
    Camille Lamy . unresolved

    I think there is also a CSP parser inside blink, should it be updated?

    Mustafa Emre Acer

    It seems blink calls into this via mojo: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/network/http_parsers.cc;l=1067;drc=ab5261de6f730d1378a27c400f8640440f662303

    Searching for some of the keywords didn't bring up any other place: https://source.chromium.org/search?q=%22wasm-unsafe-eval%22%20-out%2F%20-web_tests%2F&ss=chromium&start=21

    Also, the new WPTs work as-is, so I think this is the only policy parsing code.

    File third_party/blink/renderer/core/frame/csp/csp_directive_list.cc
    Line 933, Patchset 2: if (base::FeatureList::IsEnabled(network::features::kCSPScriptSrcV2) &&
    Carlos IL . resolved

    I'm cheating since I reviewed this after sending my CL out, but I think we should use the V1 flag here to keep them separate

    Mustafa Emre Acer

    Done. I extracted the feature flag for now and there's some overlap with the VirtualTestSuites file, but I'll eventually rebase this on top of your CL.

    File third_party/blink/web_tests/external/wpt/content-security-policy/script-src/tentative/script-url-allowed-by-hash.https.html
    Line 27, Patchset 3: frame.src = `support/iframe.html?pipe=header(Content-Security-Policy,${policy})`
    Camille Lamy . resolved

    It would also be good to add tests for CSP in Meta Tags (similar to here). For a meta tag test, it would also be good to check that it cannot relax a CSP set in the header. This can be done in a follow up CL.

    Mustafa Emre Acer

    Done.

    Modified script-url-allowed-by-hash.https to add the same set of tests using a meta tag.

    Added url-hash-in-header-and-meta.https to check that we use the most strict policy.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Camille Lamy
    • Carlos IL
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I8a538c892ed8b36e061041a6c326a0646315252d
    Gerrit-Change-Number: 6641778
    Gerrit-PatchSet: 4
    Gerrit-Owner: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Reviewer: Camille Lamy <cl...@chromium.org>
    Gerrit-Reviewer: Carlos IL <carl...@chromium.org>
    Gerrit-Reviewer: Mustafa Emre Acer <mea...@chromium.org>
    Gerrit-Attention: Camille Lamy <cl...@chromium.org>
    Gerrit-Attention: Carlos IL <carl...@chromium.org>
    Gerrit-Comment-Date: Tue, 17 Jun 2025 23:22:24 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Camille Lamy <cl...@chromium.org>
    Comment-In-Reply-To: Carlos IL <carl...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages