GithubHelp home page GithubHelp logo

w3c / webappsec-referrer-policy Goto Github PK

View Code? Open in Web Editor NEW
24.0 61.0 35.0 982 KB

WebAppSec Referrer Policy

Home Page: https://w3c.github.io/webappsec-referrer-policy/

License: Other

Makefile 0.12% HTML 96.83% CSS 3.04%

webappsec-referrer-policy's Introduction

Specification 'webappsec-referrer-policy'

This is the repository for webappsec-referrer-policy. You're welcome to contribute! Let's make the Web rock our socks off!

webappsec-referrer-policy's People

Contributors

annevk avatar antosart avatar chirlu avatar davidvancleve avatar domenic avatar domfarolino avatar ericlaw1979 avatar estark37 avatar foolip avatar hillbrad avatar jeisinger avatar jyasskin avatar kristijanburnik avatar malvoz avatar mikewest avatar plehegar avatar sc0ttbeardsley avatar sideshowbarker avatar tidoust avatar tomrittervg avatar wseltzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webappsec-referrer-policy's Issues

null -> "the empty string"

Would it be possible to make the default referrer policy (i.e., the lack of one) represented by the empty string value? That is how it's represented in Fetch https://fetch.spec.whatwg.org/#referrerpolicy. E.g., when a Request arrives in a service worker. It seems simpler if all policies are part of an enum, as there doesn't seem to be a need to vary on types here unless I'm missing something.

See whatwg/fetch#226 for context.

Please clarify if header value should be enclosed in quotes or not

In point 4.1 is used ABNF, which says that values enclosed in quotation marks are considered as case insensitive and quotes are ignored. Other parts of documents suggests that header value should be enclosed in double quotes (headlines are enclosed in quotes except The empty string).

Currently it is not clear for me if header value should be in quotes or not because of overused quotes inside other parts of documentation. Same with case sensitivity because of Enum.

For greater confusion Mozilla uses double quotes in its reference.

Where does a "block" come from in the sheet-with-null-location case?

Still reviewing #83

The new text says:

Otherwise, a CSS style sheet with a null location is responsible for the request: set the referrer to its owner node’s node document’s URL, and the referrer policy to the block’s owner node’s node document’s referrer policy.

What is "the block" here?

Define referrerPolicy IDL attribute

It seems only the content attribute is defined. We should also define the corresponding IDL attribute (and the elements that implement it). It should be limited to known values and it should have an uppercase "P" to remain consistent with HTML naming conventions.

HTML integration plan

I got started on HTML integration in whatwg/html#1153 and #42, but there is still much to do. Here are the issues I see:

  • HTML's definition of "environment settings object" should explicitly get a "referrer policy" field, instead of having it be patched in in "Core concepts" (whatwg/html#1205)
  • The monkeypatch in "Integration with HTML", regarding creating Documents or WorkerGlobalScopes, should be integrated into HTML (whatwg/html#1205)
  • The monkeypatches in "Implicit delivery" should be integrated into HTML (whatwg/html#1205)
  • HTML has removed "API referrer source" in the course of Fetch integration. @annevk, how should this be changed?
  • All places where the referrerpolicy content attribute applies should explicitly pass along the referrer policy when making the appropriate fetch (#40), similar to what is done with the crossorigin content attribute today.

`Referrer-Policy` header syntax is incompatible with JSON.

In the conversation on #14, it seemed like there was agreement (or at least, no objection) to the notion of retaining forward-compatibility with a more robust structure based on JSON. The current syntax doesn't. Was that an intentional decision?

That is, Referrer-Policy: bareword would make a JSON parser sad, whereas Referrer-Policy: "quoted-keyword" would not. I think the quoted version makes more sense, given the direction we seem to be going with header parsing. WDYT, @estark37?

/cc @fmarier @annevk

What is the motivation for "legacy keywords" in the header?

Why does the Referrer-Policy header allow "never", "default", and "always"?

I was under the impression it was because there were shipping implementations that allowed them. However, https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/Umj9iVRJM70 indicates that nobody has implemented the header yet, with Blink being the first.

At this point my best guess is that a few user agents have already shipped <meta name="referrer">, which allows the legacy keywords, and that the desire is that the Referrer-Policy header be consistent with the <meta> element?

I don't think that's a very strong argument. Mainly because we're using <meta name="referrer">, not <meta http-equiv="Referrer-Policy">, so there is no reason to say that the meta element should be consistent with the HTTP header.

As such, it seems better to me to say that the HTTP header matches the referrerpolicy="" content attribute in disallowing the legacy values, instead of saying it must match <meta> in allowing them.

redact location.ancestorOrigins according to Referrer Policy

@bzbarsky @dakami and I had a hallway discussion at the end of TPAC about the possibility of adding location.ancestorOrigins to Firefox. bz has had longstanding concerns about the information this leaks to iframes. We arrived at a local consensus that any leakage is roughly equivalent to what happens already with referrer, so it would make sense to redact ancestorOrigins according to referrer policy. (and this could resolve that objection to a Mozilla implementation of ancestorOrigins)

Referrer policy of referencing in SVG?

I am implementing Referrer policy for CSS for FireFox and I can think of SVG resource documents referenced by CSS properties, e.g. filter:url(...)
It seems like the spec is short here
https://w3c.github.io/webappsec-referrer-policy/#integration-with-css seems work to some cases CSS of SVG element inside an HTML page.
But I think there're cases that we fetch resources in SVG. Should we explain something in the spec, given the complexity of referencing in SVG?
@jeisinger, @estark37 what do you think?

Dynamically inserted \<meta name="referrer"\> may slow down speculative loadings

The speculative resource loading of Blink conflicts to a dynamically inserted .
Blink scans HTML source to collect URLs for speculative loading as soon as the HTML arrived. In this phase, it skips all <script>.
However, since the <script> may insert to override the referrer policy, and the UA has to respect it, the UA cannot start loading the collected URLs until the script execution completes.

I.e, the UA can't start loading "foo.png" below speculatively until the preceding <script> ran.
<!doctype html>

<script>document.write('')</script>

@yutakahirano, @nyaxt.

Examples table

Can the policy examples be converted to tables, so they confirm every scenario.

Originally suggested at: w3c/webappsec#414

And please check the referrer values in these tables, I'm not sure they are correct (hence why I'd like to have examples).


no-referrer

Source Destination Referrer
https://example.com/page.html https://example.com/ NULL
https://example.com/page.html http://example.com/ NULL
https://example.com/page.html https://example**.net**/ NULL
https://example.com/page.html http://example**.net**/ NULL
http://example.com/page.html https://example.com/ NULL
http://example.com/page.html http://example.com/ NULL
http://example.com/page.html https://example**.net**/ NULL
http://example.com/page.html http://example**.net**/ NULL

no-referrer-when-downgrade

Source Destination Referrer
https://example.com/page.html https://example.com/ https://example.com/page.html
https://example.com/page.html http://example.com/ NULL
https://example.com/page.html https://example**.net**/ https://example.com/page.html ?
https://example.com/page.html http://example**.net**/ NULL
http://example.com/page.html https://example.com/ http://example.com/page.html ?
http://example.com/page.html http://example.com/ http://example.com/page.html ?
http://example.com/page.html https://example**.net**/ http://example.com/page.html ?
http://example.com/page.html http://example**.net**/ http://example.com/page.html ?

same-origin

Source Destination Referrer
https://example.com/page.html https://example.com/ https://example.com/page.html
https://example.com/page.html http://example.com/ https://example.com/page.html ?
https://example.com/page.html https://example**.net**/ NULL
https://example.com/page.html http://example**.net**/ NULL
http://example.com/page.html https://example.com/ http://example.com/page.html
http://example.com/page.html http://example.com/ http://example.com/page.html
http://example.com/page.html https://example**.net**/ NULL
http://example.com/page.html http://example**.net**/ NULL

origin

Source Destination Referrer
https://example.com/page.html https://example.com/ https://example.com/
https://example.com/page.html http://example.com/ https://example.com/
https://example.com/page.html https://example**.net**/ https://example.com/
https://example.com/page.html http://example**.net**/ https://example.com/
http://example.com/page.html https://example.com/ http://example.com/
http://example.com/page.html http://example.com/ http://example.com/
http://example.com/page.html https://example**.net**/ http://example.com/
http://example.com/page.html http://example**.net**/ http://example.com/

origin-when-cross-origin

Source Destination Referrer
https://example.com/page.html https://example.com/ https://example.com/page.html
https://example.com/page.html http://example.com/ https://example.com/ ?
https://example.com/page.html https://example**.net**/ https://example.com/
https://example.com/page.html http://example**.net**/ https://example.com/
http://example.com/page.html https://example.com/ http://example.com/ ?
http://example.com/page.html http://example.com/ http://example.com/page.html
http://example.com/page.html https://example**.net**/ http://example.com/
http://example.com/page.html http://example**.net**/ http://example.com/

unsafe-url

Source Destination Referrer
https://example.com/page.html https://example.com/ https://example.com/page.html
https://example.com/page.html http://example.com/ https://example.com/page.html
https://example.com/page.html https://example**.net**/ https://example.com/page.html
https://example.com/page.html http://example**.net**/ https://example.com/page.html
http://example.com/page.html https://example.com/ http://example.com/page.html
http://example.com/page.html http://example.com/ http://example.com/page.html
http://example.com/page.html https://example**.net**/ http://example.com/page.html
http://example.com/page.html http://example**.net**/ http://example.com/page.html

Update web-platform-tests

web-platform-tests needs to be updated for:

  • The Referrer-Policy header, and the removal of the CSP 'referrer' directive. (Already done in web-platform-tests/wpt#3118!)
  • Remove tests for the old CSP 'referrer' directive
  • The new policy states same-origin, strict-origin, and strict-origin-when-cross-origin (#50)
  • Need test coverage for iframe srcdoc behavior

Verbiage about creating nested browsing contexts for particular URLs does not make sense

When nested browsing contexts are created the URL is not known (all browsing contexts are created with an about:blank document in them), and in fact can change over the lifetime of the browsing context.

For example, you can have an <iframe srcdoc> that then has the srcdoc attribute removed and hence loads its src. Or you can have an iframe that loads some http page and then later loads a blob URL. This does NOT create a new nested browsing context.

What you probably need is to do is do the current inheritance unconditionally on nested browsing context creation (so that initial about:blank inherits the referrer policy, but note that there's the open question of whether it should inherit a snapshot or an alias) and then do things for srcdoc and in fetch that inherit referrer policy the way origin is inherited... possibly including the aliasing origin does.

"determine request's referrer" algorithm should consult request's referrer policy

Currently the spec says:

If request was initiated by an element with a referrerpolicy content attribute, let policy be the attribute’s value. Otherwise, let policy be the value of environment’s referrer policy.

That should be something like

If request has a non-empty referrer policy, let policy be that referrer policy. Otherwise, let policy be the value of environment’s referrer policy.

because request's referrer policy can be set via the Request constructor.

and other elements should set the request referrer policy to its content attribute when fetching (for example, navigating).

Reference WHATWG URL

Afaik W3C URL is not maintained. Doesn't seem helpful to folks reading this document to reference it.

Clarify that "Unknown Policy Values" applies to Document policies

http://w3c.github.io/webappsec-referrer-policy/#unknown-policy-values describes why unknown policy values are ignored and gives an example of how this can be used to deploy new policy values. This should be clarified that it only applies to Document policies delivered via HTTP header or meta tag, not to referrerpolicy attributes (which can only have one token). Authors can use feature detection to deploy new policy values in referrerpolicy attributes.

(see discussion on whatwg/html#1153)

Srcdoc referrer policies don't interact well with <meta referrer>

The way the spec is written right now, a srcdoc iframe snapshots its owner document's referrer policy at the point when it creates its browsing context. If that parent document's referrer policy then changes due to a <meta referrer>, the srcdoc's referrer policy will NOT change. Is that the desired behavior?

The CSS declaration block bit in the draft doesn't make sense

I finally got a chance to read over the things from #83

This bit:

If a CSS declaration block is responsible for the request

is wrong. Consider this stylesheet:

div { background: url(foo); }

That's a declaration block, and it's responsible for the request. But that's not what the spec means by "declaration block". It wants to restrict this case to inline style. What you probably want to do is examine the .parentRule of the declaration block or something.

Feature request: Disown window.opener

This is to re-raise this issue in the context of the new Referrer-Policy spec with it's own header.

w3c/webappsec#139

It would be nice to have a no-window-opener or similar flag for Referrer-Policy. It does change the spec quite a bit to allow multiple tokens as we probably don't want to add another value to the policy enum for every current policy to imply this.

Is it better that this stay as a CSP directive?

Clarify priority of Referrer Policy Delivery

Specs said "when multiple sources specify a referrer policy, the value of the latest one will be used. This makes it possible to deploy new policy values" in [1] but I am confusing about priority of that.
There's a case for example:

(a) What if the document ships a referrer Policy and the worker (called from doc) ships with/without a new referrer policy?

If we have multiple sources define referrer policy, anyway do we know which one is latest one?
I don't know if this should be considered an issue or question. Do we have question channel of this specs?
Could you advise? @annevk @jeisinger
Thanks so much.
[1] https://w3c.github.io/webappsec-referrer-policy/#unknown-policy-values

Use of "active document" in determining the referrer looks wrong

https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer step 3 substep 3 subsubstep 1 says:

Let document be the Document object of the active document of the browsing context of environment’s responsible browsing context.

What this means is that if a load happens in a document that's not active, the referrer will be set to whatever document is active in the same browsing context, which has nothing whatsoever to do with where the load is happening. I'm not sure what this bit is trying to do by using "active document", but this doesn't seem right.

Should JavaScript module imports respect referrer policy, and if so, how?

In whatwg/html#1150 some folks decided that given

<!-- x.html -->
<script type="module" src="a.js">
// a.js
import "./b.js";

the referrer when fetching b.js should be a.js, not x.html. This apparently follows CSS, which is nice.

However, we didn't think about referrer policies. It seems like if we were to follow CSS as specified in Referrer Policy, we should be checking for a Referrer-Policy header on a.js, and then falling back to x.html's referrer policy if no such header were present. Does that sound reasonable?

Why no referrerpolicy="" on <script>?

It seems a bit strange that you can get it indirectly using <link rel="preload" referrerpolicy="..." href="..."> plus a later <script src="...">, but can't just do <script src="..." referrerpolicy="..."> directly.

8.4 Minor wording inconsistency

The first sentence in 8.4 says "must" ("Certain portions of URLs MUST not be included") whereas the second sentence uses "should" ("a URLs fragment, username, and password components should be stripped") to refer to the same thing. Afaiu, the "should" in the second sentence should be replaced by "must".

Add appropriate [CEReactions] annotation

After whatwg/html#1069 lands, all referrerPolicy attributes will need to be updated with [CEReactions].

Also, while I'm here: why not define these in a single mixin, and then do HTMLWhateverElement implements ReferrerPolicyUtils 5 times?


Alternately we're happy to upstream the HTML-ey parts of this to HTML, assuming it has cross-vendor interest. I think it's OK either way though.

Add referrer policy `origin-when-downgrade`

I think there is a gap in the specification.

The browser's default is no-referrer-when-downgrade.
After moving to https I found that this default policy kills referrer of our partner's sites that were still on http protocol. So I have changed the policy to origin-when-cross-origin. This works ok, because the partner sites on http gets the origin referrer.

But unfortunately this option sends origin referrer even to https pages, too. This has serious consequences for functionality of some pages on different origin (domain), that are relying on the full referrer.

In the specification is missing option, which allows sending the full referrer to https cross origin sites (like the no-referrer-when-downgrade does) and sends origin referrer to http sites (for security reasons).
The name of this policy can be origin-when-downgrade.

Referrer policy of child css?

It does not say explicitly about fetching resources from child css. Should we fall back to parent's referrer policy or document's policy if there's undefined poilcy of child (no Referer-Policy header)?
Per definition of empty string policy and referrer policy can be defined "Implicitly, via inheritance", we choose parent's, don't we?
I am not sure if that is an issue, but I would like to consult author of the specs before I could go through the implementation of Firefox. @jeisinger do you have any advice? Should we say a bit more in the specs?
Thank you very much

Allow referrerpolicy attribute on <link>

If I'm reading current draft correctly, referrerpolicy is restricted to a, area, img, and iframe? Can we extend it to <link> as well? This would enable developers to control the policy of prefetch/preload/prerender resources (also, stylesheets and other types fetched via link).

<link rel=prefetch as=image href=example.com/thing.jpg referrerpolicy=origin>

/cc @mikewest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.