Closed Bug 1773667 Opened 4 years ago Closed 4 years ago

Check non-JavaScript script loading from file:// later

Categories

(Core :: DOM: Security, task)

task

Tracking

()

RESOLVED FIXED
103 Branch
Tracking Status
firefox101 --- wontfix
firefox102 --- fixed
firefox103 --- fixed

People

(Reporter: tschuster, Assigned: tschuster)

References

Details

Attachments

(2 external files)

Currently we check the MIME-type of scripts loaded from file:// too early. That means we actually preempt the checks that disallow loading file: from normal webpages loaded via https: etc. This is probably skewing our telemetry.

While investigating this I also realized another issue or at least unexpected behavior. I thought GetTypeFromURI would also check the OS for the file-extension, but that doesn't seem to work, presumably because of the content-process sandbox for file URIs?

Assignee: nobody → tschuster
Status: NEW → ASSIGNED
Component: DOM: Core & HTML → DOM: Security

(In reply to Tom Schuster (MoCo) from comment #0)

Currently we check the MIME-type of scripts loaded from file:// too early. That means we actually preempt the checks that disallow loading file: from normal webpages loaded via https: etc. This is probably skewing our telemetry.

While investigating this I also realized another issue or at least unexpected behavior. I thought GetTypeFromURI would also check the OS for the file-extension, but that doesn't seem to work, presumably because of the content-process sandbox for file URIs?

I think it's meant to be forwarded via IPC. Does that not happen?

Flags: needinfo?(tschuster)

I think it's meant to be forwarded via IPC. Does that not happen?

Seems like that specific case is broken:

  • nsExternalHelperAppService::GetMIMETypeFromOSForExtension calls GetMIMEInfoFromOS with an empty-string MIME type.
  • nsOSHelperAppServiceChild::GetMIMEInfoFromOS creates a nsChildProcessMIMEInfo with the passed in empty MIME type.
  • It then calls ContentHandlerService::GetMIMEInfoFromOS, which modifies some of the passed in nsIHandlerInfo data. type however is readonly.

Frankly the whole design here seems problematic.

Flags: needinfo?(tschuster)

(In reply to Tom Schuster (MoCo) from comment #4)

I think it's meant to be forwarded via IPC. Does that not happen?

Seems like that specific case is broken:

  • nsExternalHelperAppService::GetMIMETypeFromOSForExtension calls GetMIMEInfoFromOS with an empty-string MIME type.
  • nsOSHelperAppServiceChild::GetMIMEInfoFromOS creates a nsChildProcessMIMEInfo with the passed in empty MIME type.
  • It then calls ContentHandlerService::GetMIMEInfoFromOS, which modifies some of the passed in nsIHandlerInfo data. type however is readonly.

Frankly the whole design here seems problematic.

I don't know much about the IPC implementation apart from (a) it exists and (b) I would like it not to (exist). So I don't have any trouble believing it's problematic and would be happy to see it removed or, failing that, improved.

For scripts I would expect us to short-circuit anyway because we have a hardcoded list... if that would be sufficient to fix the issue here, perhaps that could be a short-term fix to improve the telemetry?

For scripts I would expect us to short-circuit anyway because we have a hardcoded list... if that would be sufficient to fix the issue here, perhaps that could be a short-term fix to improve the telemetry?

Thanks to the hardcoded list nsExternalHelperAppService we already support all the normal extensions like .js, .mjs etc. I don't think we need to fix anything right now.

Pushed by tschuster@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0e68d8f8c151 Perform file URI script check after other checks. r=freddyb https://hg.mozilla.org/integration/autoland/rev/168fed291e9c Add console logging for file:// script loads. r=freddyb
See Also: → 1773947

Comment on attachment 9280647 [details]
Bug 1773667 - Perform file URI script check after other checks. r?freddyb

Beta/Release Uplift Approval Request

  • User impact if declined: We want to monitor potential problems with a new security enforcement mechanism that is shipping in 102. Without this patch the telemetry we collect is misleading.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Existing code is only changed in a very small way to mirrors other existing code.
  • String changes made/needed:
  • Is Android affected?: Yes
Attachment #9280647 - Flags: approval-mozilla-beta?
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch

Fred, the uplift request was done for only one of the patches that landed on mozilla-central, is that wanted?

Flags: needinfo?(fbraun)

Adding a NI to Tom as well.

Flags: needinfo?(tschuster)

I believe the console logging change isn't that necessary for the telemetry, which is the main interesting thing we wanted uplifted here.

Flags: needinfo?(fbraun)

Comment on attachment 9280647 [details]
Bug 1773667 - Perform file URI script check after other checks. r?freddyb

Approved for 102 beta 9, thanks.

Attachment #9280647 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Correct. The second patch is nice too have, but contains string changes so I didn't really bother with it.

Flags: needinfo?(tschuster)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: