Closed Bug 1895770 Opened 1 year ago Closed 11 months ago

about: page CSP Asserts aren't effective

Categories

(Core :: DOM: Security, defect, P3)

defect

Tracking

()

RESOLVED FIXED
136 Branch
Tracking Status
firefox136 --- fixed

People

(Reporter: tjr, Assigned: tschuster)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [domsecurity-backlog])

Attachments

(1 file)

It was pointed out that the checks against a website running script are not that effective:

  // preferences and downloads allow legacy inline scripts through hash src.
  MOZ_ASSERT(!foundScriptSrc ||
                 StringBeginsWith(aboutSpec, "about:preferences"_ns) ||
                 StringBeginsWith(aboutSpec, "about:settings"_ns) ||
                 StringBeginsWith(aboutSpec, "about:downloads"_ns) ||
                 StringBeginsWith(aboutSpec, "about:fingerprinting"_ns) ||
                 StringBeginsWith(aboutSpec, "about:asrouter"_ns) ||
                 StringBeginsWith(aboutSpec, "about:newtab"_ns) ||
                 StringBeginsWith(aboutSpec, "about:logins"_ns) ||
                 StringBeginsWith(aboutSpec, "about:compat"_ns) ||
                 StringBeginsWith(aboutSpec, "about:welcome"_ns) ||
                 StringBeginsWith(aboutSpec, "about:profiling"_ns) ||
                 StringBeginsWith(aboutSpec, "about:studies"_ns) ||
                 StringBeginsWith(aboutSpec, "about:home"_ns),
             "about: page must not contain a CSP including script-src");

Because a page is required to have default-src; asserting that a page doesn't have script-src (unless it is allowlisted) doesn't really do much, when all the non-allowlisted pages can run script as long as its allowed via default-src.

I think we can just remove this assertion...

Curious on Freddy's thoughts here and if we can enforce something more meaningful here? E.g. script-src not including unsafe bits nor http/https/data or whatever?

Flags: needinfo?(fbraun)

(In reply to Tom Ritter [:tjr] from comment #2)

(In reply to :Gijs (he/him) from comment #1)

script-src not including unsafe bits

https://searchfox.org/mozilla-central/rev/dbd654fa899a56a6a2e92f325c4608020e80afae/dom/security/nsContentSecurityUtils.cpp#1410-1441

nor http/https/data or whatever?

https://searchfox.org/mozilla-central/rev/dbd654fa899a56a6a2e92f325c4608020e80afae/dom/security/nsContentSecurityUtils.cpp#1384-1400

We've got those checks at least :)

Oh, phew. Sorry for not reading more carefully.

Might be useful if we could do the web scheme one for default-src and script-src without any exceptions (which I think should work today?). But yeah, otherwise I guess as comment 0 suggests maybe we just drop the foundScriptSrc one.

It would also be less error prone to actually use the parsed representation of the CSP policy for finding directives, instead of doing string matching on a serialized string.

Severity: -- → S3
Priority: -- → P3
Whiteboard: [domsecurity-backlog]

+1 to what Tom Schuster said. We should check the parsed CSP rather than string matching.
Something useful to do for our backlog, I could see us exposing a utility function in our CSP code that answers whether a policy satisfies our internal requirements.

Flags: needinfo?(fbraun)

I am going to investigate this, because I want to do something similar for other windows/dialogs.

Assignee: nobody → tschuster
Depends on: 1942022
Depends on: 1942025
Attachment #9459869 - Attachment description: WIP: Bug 1895770 - Improve the verification of the CSP in about: pages. → Bug 1895770 - Improve the verification of the CSP in about: pages. r?tjr!,freddyb!
Blocks: 1940273
Pushed by tschuster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/459a5df99cd5 Improve the verification of the CSP in about: pages. r=tjr,freddyb,search-reviewers
Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
Blocks: 1990175
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: