Closed Bug 1790236 Opened 2 years ago Closed 1 year ago

Remove CSP_ALLOW_LOCALHOST and the special case for http:-localhost from the MV2 base CSP

Categories

(WebExtensions :: General, task, P3)

task

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: robwu, Unassigned)

References

Details

In bug 1789751 I dropped support for the localhost exception in the MV3 CSP.

Out of caution I did not remove localhost from the MV2 base CSP. However, we should probably remove it, because it is probably not needed. It is not documented, and any MV2 extensions that try to load a localhost script have alternatives available (such as 'unsafe-eval').

The uses of CSP_ALLOW_LOCALHOST (Ci.nsIAddonContentPolicy.CSP_ALLOW_LOCALHOST) across the codebase should also be removed.

The bitfield that is freed up by it can be re-purposed for bug 1685123.

As noted in bug 1789751, the removal of localhost from our base CSP can allow us to block unexpected script sources in the extension process. Even if it is http to start with.

With that, we can also reject http(s) script loads in extensions, even at the process level (e.g. like what CheckAllowLoadInSystemPrivilegedContext does for the system principal).

127.0.0.1 and localhost are already explicitly documented to be unsupported in the BCD, so it should be safe to remove them them from the implementation.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_security_policy#browser_compatibility

Severity: -- → N/A
Priority: -- → P3

Hi, would this change prevent use of a localhost dev server (e.g. Vite) when developing a MV2 extension? If so, I would consider that a very bad idea in terms of DX.

See Also: → 1864284

We have decided to be in favor of allowing localhost/127.0.0.1 script loads in temporarily loaded add-ons, see https://bugzilla.mozilla.org/show_bug.cgi?id=1864284#c3

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.