Граф коммитов

273 Коммитов

Автор SHA1 Сообщение Дата
Nika Layzell 1fdee2314c Bug 1839920 - Rename Get{ASCII,UTF}Origin to GetWebExposedOriginSerialization, r=smaug,necko-reviewers,anti-tracking-reviewers,bvandersloot,jesup
This should make uses of the type more clearly indicating where the
origin came from, and should help avoid potential confusion between this
origin and nsIPrincipal::origin in new code.

This new name is long, but explicit. The string returned from this
function corresponds to the "serialization of an origin" from the WHATWG
html spec:
https://html.spec.whatwg.org/multipage/browsers.html#ascii-serialisation-of-an-origin

Differential Revision: https://phabricator.services.mozilla.com/D181794
2023-06-27 19:59:15 +00:00
Tom Ritter 502de3fe32 Bug 1830070: Correctly apply RFP Checks to about: documents and deal with pop-ups r=smaug,necko-reviewers,emilio
This patch has three parts to it:

1) Use NS_IsContentAccessibleAboutURI to ensure that only safe
   about: documents get exempted.

   With this change, we will no longer allow about:blank or
   about:srcdoc to be exempted base on URI.  If they are to be
   exempted, it will need to be base on other information.

2) In Document::RecomputeResistFingerprinting we previously
   deferred to a Parent Document if we had one, and either the
   principals matched or we were a null principal.

   We will do the same thing, except we will also defer to our
   opener as well as the parent document.  Now about:blank
   documents can be exempted.

   However, this deferral only works if the opener is
   same-process. For cross-process openers, we make the decision
   ourselves.

We can make the wrong decision though. CookieJarSettings is
inherited through iframes but it is _not_ inherited through popups.
(Yet. There's some discussion there, but it's not implemented.)

Conceptually; however, we do want CJS to inherit, and we do want
RFP to inherit as well.  Because a popup can collude with its
opener to bypass RFP and Storage restrictions, we should propagate
the CJS information.

This does lead to an unusual situation: if you have exempted
b.com, and a.com (which is not exempted) creates a popup for b.com
then that popup will not be exempted.  But an open tab for b.com
would be.  And it might be hard to tell those two apart, or why
they behave differently.

The third part of the patch:

3) In LoadInfo we want to populate information down from the
   opener to the popup.  This is needed because otherwise a
   cross-origin popup will not defer to its opener (because in
   Fission they're in different processes) and will decide if
   it should be exempted itself. It's the CookieJarSettings
   object that prevents the cross-origin document from thinking
   it should be exempted - CJS tells it 'No, you're a child
   (either a subdocument or a popup) and if I say you don't get
   an exemption, you don't.'


Finally, there is one more caveat: we can only defer to a parent
document or opener if it still exists.  A popup may outlive its
opener. If that happens, and something induces a call to
RecomputeResistFingerprinting, then (e.g.) an about:blank popup
may lose an RFP exemption that it had received from its parent.
This isn't expected to happen in practice -
RecomputeResistFingerprinting is only called on document creation
and pref changes I believe.

It is not possible for a popup to _gain_ an exemption though,
because even if the parent document is gone, the CJS lives on and
restricts it.

Differential Revision: https://phabricator.services.mozilla.com/D178866
2023-06-27 03:31:02 +00:00
Butkovits Atila fdecfc4373 Backed out 9 changesets (bug 1830070) for causing failures at browser_hwconcurrency_popups_blob_noopener.js. CLOSED TREE
Backed out changeset 62f439f5b2ad (bug 1830070)
Backed out changeset 92b5f8af326f (bug 1830070)
Backed out changeset ae685d3825b7 (bug 1830070)
Backed out changeset 4800b1312e99 (bug 1830070)
Backed out changeset 7ea9676f22ae (bug 1830070)
Backed out changeset 7a86f85ae0e8 (bug 1830070)
Backed out changeset 0a2d5f339e41 (bug 1830070)
Backed out changeset 7e5b72c73304 (bug 1830070)
Backed out changeset e4490bf3d040 (bug 1830070)
2023-06-27 00:12:07 +03:00
Tom Ritter 78fae782d0 Bug 1830070: Correctly apply RFP Checks to about: documents and deal with pop-ups r=smaug,necko-reviewers,emilio
This patch has three parts to it:

1) Use NS_IsContentAccessibleAboutURI to ensure that only safe
   about: documents get exempted.

   With this change, we will no longer allow about:blank or
   about:srcdoc to be exempted base on URI.  If they are to be
   exempted, it will need to be base on other information.

2) In Document::RecomputeResistFingerprinting we previously
   deferred to a Parent Document if we had one, and either the
   principals matched or we were a null principal.

   We will do the same thing, except we will also defer to our
   opener as well as the parent document.  Now about:blank
   documents can be exempted.

   However, this deferral only works if the opener is
   same-process. For cross-process openers, we make the decision
   ourselves.

We can make the wrong decision though. CookieJarSettings is
inherited through iframes but it is _not_ inherited through popups.
(Yet. There's some discussion there, but it's not implemented.)

Conceptually; however, we do want CJS to inherit, and we do want
RFP to inherit as well.  Because a popup can collude with its
opener to bypass RFP and Storage restrictions, we should propagate
the CJS information.

This does lead to an unusual situation: if you have exempted
b.com, and a.com (which is not exempted) creates a popup for b.com
then that popup will not be exempted.  But an open tab for b.com
would be.  And it might be hard to tell those two apart, or why
they behave differently.

The third part of the patch:

3) In LoadInfo we want to populate information down from the
   opener to the popup.  This is needed because otherwise a
   cross-origin popup will not defer to its opener (because in
   Fission they're in different processes) and will decide if
   it should be exempted itself. It's the CookieJarSettings
   object that prevents the cross-origin document from thinking
   it should be exempted - CJS tells it 'No, you're a child
   (either a subdocument or a popup) and if I say you don't get
   an exemption, you don't.'


Finally, there is one more caveat: we can only defer to a parent
document or opener if it still exists.  A popup may outlive its
opener. If that happens, and something induces a call to
RecomputeResistFingerprinting, then (e.g.) an about:blank popup
may lose an RFP exemption that it had received from its parent.
This isn't expected to happen in practice -
RecomputeResistFingerprinting is only called on document creation
and pref changes I believe.

It is not possible for a popup to _gain_ an exemption though,
because even if the parent document is gone, the CJS lives on and
restricts it.

Differential Revision: https://phabricator.services.mozilla.com/D178866
2023-06-26 17:04:40 +00:00
Natalia Csoregi 37db79aab5 Backed out 8 changesets (bug 1830070) for causing assertion failures on nsAboutProtocolUtils.h. CLOSED TREE
Backed out changeset 05c4b06857fb (bug 1830070)
Backed out changeset f264c5b9c200 (bug 1830070)
Backed out changeset 45032e474c29 (bug 1830070)
Backed out changeset fa89c51ef6fc (bug 1830070)
Backed out changeset f0f70e7c8250 (bug 1830070)
Backed out changeset 785e1775c13d (bug 1830070)
Backed out changeset 582e28b83b50 (bug 1830070)
Backed out changeset de379bee27d0 (bug 1830070)
2023-06-19 23:51:04 +03:00
Tom Ritter bc2e6a72ad Bug 1830070: Correctly apply RFP Checks to about: documents and deal with pop-ups r=smaug,necko-reviewers,emilio
This patch has three parts to it:

1) Use NS_IsContentAccessibleAboutURI to ensure that only safe
   about: documents get exempted.

   With this change, we will no longer allow about:blank or
   about:srcdoc to be exempted base on URI.  If they are to be
   exempted, it will need to be base on other information.

2) In Document::RecomputeResistFingerprinting we previously
   deferred to a Parent Document if we had one, and either the
   principals matched or we were a null principal.

   We will do the same thing, except we will also defer to our
   opener as well as the parent document.  Now about:blank
   documents can be exempted.

   However, this deferral only works if the opener is
   same-process. For cross-process openers, we make the decision
   ourselves.

We can make the wrong decision though. CookieJarSettings is
inherited through iframes but it is _not_ inherited through popups.
(Yet. There's some discussion there, but it's not implemented.)

Conceptually; however, we do want CJS to inherit, and we do want
RFP to inherit as well.  Because a popup can collude with its
opener to bypass RFP and Storage restrictions, we should propagate
the CJS information.

This does lead to an unusual situation: if you have exempted
b.com, and a.com (which is not exempted) creates a popup for b.com
then that popup will not be exempted.  But an open tab for b.com
would be.  And it might be hard to tell those two apart, or why
they behave differently.

The third part of the patch:

3) In LoadInfo we want to populate information down from the
   opener to the popup.  This is needed because otherwise a
   cross-origin popup will not defer to its opener (because in
   Fission they're in different processes) and will decide if
   it should be exempted itself. It's the CookieJarSettings
   object that prevents the cross-origin document from thinking
   it should be exempted - CJS tells it 'No, you're a child
   (either a subdocument or a popup) and if I say you don't get
   an exemption, you don't.'


Finally, there is one more caveat: we can only defer to a parent
document or opener if it still exists.  A popup may outlive its
opener. If that happens, and something induces a call to
RecomputeResistFingerprinting, then (e.g.) an about:blank popup
may lose an RFP exemption that it had received from its parent.
This isn't expected to happen in practice -
RecomputeResistFingerprinting is only called on document creation
and pref changes I believe.

It is not possible for a popup to _gain_ an exemption though,
because even if the parent document is gone, the CJS lives on and
restricts it.

Differential Revision: https://phabricator.services.mozilla.com/D178866
2023-06-19 20:03:27 +00:00
june wilde 05c279a3d2 Bug 1776755 - Skip ordering ExpandedPrincipals to speed up creation; r=nika,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D161450
2023-03-13 14:52:04 +00:00
Butkovits Atila 2f6b1a7ad1 Backed out changeset 3cdcc72baa6e (bug 1776755) for causing failures at test_ext_contentscript_triggeringPrincipal.js. 2023-02-14 19:30:16 +02:00
june wilde 9f0c374a0a Bug 1776755 - Skip ordering ExpandedPrincipals to speed up creation; r=nika,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D161450
2023-02-14 15:03:40 +00:00
Peter Van der Beken 46c52d2b18 Bug 1795312 - Optimize serializing enums as JSON string keys for principals. r=farre
Depends on D166953

Differential Revision: https://phabricator.services.mozilla.com/D166954
2023-02-14 10:17:17 +00:00
Andreas Farre b09078e6a7 Bug 1795312 - Don't Base64 encode principals when serializing. r=peterv
Base64 encoding is done to top-level principal and the sub-principals
of expanded principals. Getting rid of the Base64 encoding entirely
also lets us use jsoncpp consider expanded principals to be entirely
serialized as JSON.

Differential Revision: https://phabricator.services.mozilla.com/D166783
2023-02-14 10:17:16 +00:00
Cristina Horotan 4f2132fd1e Backed out 5 changesets (bug 1795312) for causing build bustage at BasePrincipal.h on a CLOSED TREE
Backed out changeset c4f9e74d6164 (bug 1795312)
Backed out changeset 2594a213283c (bug 1795312)
Backed out changeset bc1c5b1c2d85 (bug 1795312)
Backed out changeset 38f9e767cc32 (bug 1795312)
Backed out changeset a732c5bcc392 (bug 1795312)
2023-02-08 19:33:48 +02:00
Peter Van der Beken 40c317a4de Bug 1795312 - Optimize serializing enums as JSON string keys for principals. r=farre
Differential Revision: https://phabricator.services.mozilla.com/D166954
2023-02-08 12:57:10 +00:00
Andreas Farre ff25742a1d Bug 1795312 - Don't Base64 encode principals when serializing. r=peterv
Base64 encoding is done to top-level principal and the sub-principals
of expanded principals. Getting rid of the Base64 encoding entirely
also lets us use jsoncpp consider expanded principals to be entirely
serialized as JSON.

Differential Revision: https://phabricator.services.mozilla.com/D166783
2023-02-08 12:57:09 +00:00
Cristian Tuns 429b1e8615 Backed out changeset 2b1d90490648 (bug 1776755) for causing xpcshells failures CLOSED TREE 2023-02-07 12:53:31 -05:00
june wilde 46711bc1dc Bug 1776755 - Skip ordering ExpandedPrincipals to speed up creation; r=nika,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D161450
2023-02-07 16:47:29 +00:00
Dave Townsend b752598495 Bug 1792138: Show the extension's name in permission prompts for opening external links. r=ckerschb,robwu,fluent-reviewers,pbz,flod
In order to handle the content script case correctly we must expose the
contentScriptAddonPolicy to JavaScript. With that we can always see what
extension is trying to perform an action and use its name rather than internal
ID in the dialog.

Differential Revision: https://phabricator.services.mozilla.com/D161282
2023-01-07 17:53:19 +00:00
Stanca Serban bd29139bde Backed out changeset 514642d76faa (bug 1792138) for causing mochitests failures in test_ext_protocolHandlers.html. CLOSED TREE 2022-12-13 14:53:38 +02:00
Dave Townsend e021cf6a60 Bug 1792138: Show the extension's name in permission prompts for opening external links. r=ckerschb,robwu,fluent-reviewers,pbz,flod
In order to handle the content script case correctly we must expose the
contentScriptAddonPolicy to JavaScript. With that we can always see what
extension is trying to perform an action and use its name rather than internal
ID in the dialog.

Differential Revision: https://phabricator.services.mozilla.com/D161282
2022-12-13 10:43:32 +00:00
Nika Layzell 2869537fdd Bug 1443925 - Part 11: Document thread safety requirements for most principal methods, r=ckerschb
After the previous changes, the majority of methods on nsIPrincipal are now
threadsafe. This patch documents which methods are still bound to the main
thread, and adds thread assertions to them to avoid potential misuse.

Differential Revision: https://phabricator.services.mozilla.com/D163041
2022-12-02 00:53:53 +00:00
Nika Layzell 664e7d8b0e Bug 1443925 - Part 10: Use AddonPolicyCore rather than AddonPolicy for principals, r=ckerschb,extension-reviewers,kmag
This changes out almost all places `AddonPolicy()` is used within nsIPrincipal
implementations, replacing it with the threadsafe `AddonPolicyCore()` method
and `WebExtensionPolicyCore` type.

Differential Revision: https://phabricator.services.mozilla.com/D163040
2022-12-02 00:53:53 +00:00
Nika Layzell c6fde75b19 Bug 1443925 - Part 6: Allow specifying Domain when creating content principals, r=ckerschb,bholley
This is required for deserializing nsIPrincipal instances from PrincipalInfo to
be threadsafe, as setting domain with `SetDomain()` is only safe on the main
thread, due to it enumerating and updating JS wrappers.

Differential Revision: https://phabricator.services.mozilla.com/D163036
2022-12-02 00:53:51 +00:00
Nika Layzell e2f6bee4ab Bug 1443925 - Part 2: Make basic manipulation of nsIPrincipal threadsafe, r=ckerschb
This patch only makes the very basics of nsIPrincipal manipulation threadsafe,
such as reference counting, and some trivial methods. The more complex methods
will be made threadsafe in following parts.

Differential Revision: https://phabricator.services.mozilla.com/D163032
2022-12-02 00:53:50 +00:00
Stanca Serban 3811bf75f5 Backed out changeset 02a9e51358f1 (bug 1792138) for causing mochitests failures on browser_ext_windows_create_url.js. CLOSED TREE 2022-11-17 18:38:00 +02:00
Dave Townsend 1573156d9c Bug 1792138: Show the extension's name in permission prompts for opening external links. r=ckerschb,robwu,fluent-reviewers,pbz,flod
In order to handle the content script case correctly we must expose the
contentScriptAddonPolicy to JavaScript. With that we can always see what
extension is trying to perform an action and use its name rather than internal
ID in the dialog.

Differential Revision: https://phabricator.services.mozilla.com/D161282
2022-11-17 14:44:57 +00:00
Stanca Serban d7154c3939 Backed out changeset e14d08963786 (bug 1792138) for causing mochitest failures on browser_protocol_ask_dialog_permission.js. CLOSED TREE 2022-11-17 14:57:36 +02:00
Dave Townsend 409d66befd Bug 1792138: Show the extension's name in permission prompts for opening external links. r=ckerschb,robwu,fluent-reviewers,pbz,flod
In order to handle the content script case correctly we must expose the
contentScriptAddonPolicy to JavaScript. With that we can always see what
extension is trying to perform an action and use its name rather than internal
ID in the dialog.

Differential Revision: https://phabricator.services.mozilla.com/D161282
2022-11-17 11:08:48 +00:00
nchevobbe ac16015106 Bug 1778959 - Expose nsIPrincipal.isLoopbackHost. r=bholley.
This will be used in SitePermsAddonInstallRequestPrototype to discriminate permission
requests coming from localhost, where we want to fallback to regular permission prompt.

Depends on D151477

Differential Revision: https://phabricator.services.mozilla.com/D157658
2022-09-30 22:07:18 +00:00
Bobby Holley ea24f9bbec Bug 1757796 - Permit midi-sysex on localhost. r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D140417
2022-03-04 22:55:00 +00:00
Emilio Cobos Álvarez 685321b746 Bug 1755947 - Simplify nsIPrincipal.isSameOrigin(). r=bholley
Differential Revision: https://phabricator.services.mozilla.com/D139030
2022-02-17 18:11:58 +00:00
Tim Huang b3594081d0 Bug 1724376 - Part 2: Add a RejectForeignAllowList::Check() for principal. r=dimi,pbz,ckerschb
We need a helper function for checking principal if it's in the foreign
allow list.

In this patch we will add a BasePrincipal::IsURIInList() because this is
needed for RejectForeignAllowList::Check().

Differential Revision: https://phabricator.services.mozilla.com/D123804
2021-10-05 15:16:19 +00:00
Tom Schuster a0128c7638 Bug 1724206 - Use WebExtensionPolicy webidl definition for addonPolicy property on nsIPrincipal. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D121889
2021-08-05 18:16:17 +00:00
Nika Layzell 37b7c93371 Bug 1715167 - Part 5: Add a precursorPrincipal attribute to nsIPrincipal, r=ckerschb,ngogge
This provides a getter which can be used to interact with the precursor
attribute of the null principal.

Depends on D119691

Differential Revision: https://phabricator.services.mozilla.com/D119692
2021-07-15 21:09:15 +00:00
Nika Layzell a8265c4766 Bug 1711078 - Part 2: Mark immutable fields in principal types as const, r=ckerschb
This is a step towards separating the mutable state on principals from const
state which can be made threadsafe. The remaining mutable fields will either
need to be moved off of nsIPrincipal or made threadsafe to destroy (e.g. using
nsMainThreadPtrHandle) and stored behind a mutex.

Serialization is handled for most types using a separate Deserializer class,
like how it was handled with `nsIURI` mutators. SystemPrincipal wasn't changed
as the `Read` method is a no-op for that class.

Differential Revision: https://phabricator.services.mozilla.com/D115092
2021-05-17 20:50:09 +00:00
Christoph Kerschbaumer d6ef7be5e9 Bug 1706593: Update prePath to camel case in nsIPrincipal.idl r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D113927
2021-04-30 11:16:31 +00:00
Simon Giesecke 5db2472bdf Bug 1673931 - Avoid including ReferrerPolicyBinding.h from header files. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D97610
2020-12-10 11:09:29 +00:00
Christoph Kerschbaumer 0f05ea9b88 Bug 1678310: Expose siteOriginNoSuffix on nsIPrincipal r=baku,nika
Differential Revision: https://phabricator.services.mozilla.com/D97605
2020-11-28 07:21:32 +00:00
Csoregi Natalia a810f4e72c Backed out changeset cf796da336c8 (bug 1678310) due to causing memory crashes. CLOSED TREE 2020-11-24 13:00:45 +02:00
Christoph Kerschbaumer a1c2ca7af2 Bug 1678310: Expose siteOriginNoSuffix on nsIPrincipal r=baku
Differential Revision: https://phabricator.services.mozilla.com/D97605
2020-11-24 09:04:56 +00:00
Simon Giesecke 94b0165df6 Bug 1678374 - Avoid including js/RootingAPI.h from header files. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D97616

Depends on D97467
2020-11-23 16:12:12 +00:00
Simon Giesecke 1000a339cf Bug 1673931 - Avoid including ChromeUtils.h from header files.
Differential Revision: https://phabricator.services.mozilla.com/D96553

Depends on D96552
2020-11-23 16:10:16 +00:00
Tim Huang 18853bea78 Bug 1670617 - Part 2: Make the CORS preflight cache partitioned by the originAttributes. r=ckerschb,necko-reviewers
We want to partition the CORS preflight cache by the network state
partitioning. So, we have done two things in the patch. First, we make
the CORS preflight cache to be aware of the OriginAttributes. Second, we
use the originAttributes of the network state partitioning in the CORS
preflight cache. As the result, the CORS preflight cache will be
partitioned by the originAttributes.partitionKey as well as other
originAttributes fields if present.

Differential Revision: https://phabricator.services.mozilla.com/D93683
2020-10-26 13:39:12 +00:00
Sebastian Streich f1c274e657 Bug 1660822 - Add isLocalIpAdress to nsIPrincipal r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D82919
2020-08-24 16:28:26 +00:00
Butkovits Atila a24ad1c55b Backed out changeset 6d39aab86966 (bug 1633710) for failure at test_disabled_hosts.js. CLOSED TREE 2020-08-05 22:19:30 +03:00
Sebastian Streich a7595921ed Bug 1633710 - Move display-(spec/prepath/host) to nsIPrincipal r=geckoview-reviewers,snorp
Differential Revision: https://phabricator.services.mozilla.com/D82913
2020-08-05 16:52:12 +00:00
Sebastian Streich bf58055b03 Bug 1633710 - Move uri.spec calls to nsIPrincipal r=necko-reviewers,geckoview-reviewers,preferences-reviewers,ckerschb,ntim,snorp,valentin
Differential Revision: https://phabricator.services.mozilla.com/D82911
2020-08-04 11:10:41 +00:00
Noemi Erli 5cebe61c77 Backed out changeset 4ed7b13fb7a5 (bug 1633710) for causing failures in browser_amosigned_url.js CLOSED TREE 2020-07-29 22:34:42 +03:00
Sebastian Streich ea482d8e73 Bug 1633710 - Move uri.spec calls to nsIPrincipal r=necko-reviewers,geckoview-reviewers,preferences-reviewers,ckerschb,ntim,snorp,valentin
Differential Revision: https://phabricator.services.mozilla.com/D82911
2020-07-29 17:33:10 +00:00
Andrea Marchesini 7ff3759ac3 Bug 1638358 - Cookie Schemeful Same-Site - part 5 - schemeful comparison, r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D75629
2020-06-02 13:50:12 +00:00
Csoregi Natalia e960b9f449 Backed out 7 changesets (bug 1640405, bug 1638358) for failures on browser_webconsole_network_messages_status_code.js. CLOSED TREE
Backed out changeset ef5f7479ddf8 (bug 1640405)
Backed out changeset 286e0c83eb30 (bug 1638358)
Backed out changeset 89e396b2896e (bug 1638358)
Backed out changeset 33ad5fa05209 (bug 1638358)
Backed out changeset d213264c1379 (bug 1638358)
Backed out changeset 6bc05236afb4 (bug 1638358)
Backed out changeset 87e9d0ed3982 (bug 1638358)
2020-06-02 15:16:42 +03:00