Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Introduce "reporting endpoint" to COEP #8

Merged
merged 15 commits into from
Feb 19, 2020

Conversation

yutakahirano
Copy link
Collaborator

This change introduces "reporting endpoint" concept which will be used as an
reporting endpoint for potential COEP violations.

Reporting behavior will be specified in future changes.

Discussed at whatwg/html#5100.

This change introduces "reporting endpoint" concept which will be used as an
reporting endpoint for potential COEP violations.

Reporting behavior will be specified in future changes.

Discussed at whatwg/html#5100.
@zcorpan
Copy link
Contributor

zcorpan commented Jan 23, 2020

This should probably follow the convention in #2

@yutakahirano
Copy link
Collaborator Author

I'll do that after that change lands.

Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this patch! I have a few questions:

  1. Do we need a report-only mode? ( @arturjanc )
  2. We could do this in one header rather than two (or four, if report-only is a thing). Wouldn't a param be simpler?

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@yutakahirano
Copy link
Collaborator Author

Thank you!

  1. Do we need a report-only mode? ( @arturjanc )

What do you mean by report-only mode here? I'm planning to introduce the following behaviors:

  1. If COEP is "none" and the reporting endpoint is null: do nothing
  2. If COEP is "require-corp" and the reporting endpoint is null: COEP is effective without reporting
  3. If COEP is "none" and the reporting endpoint is set: Do not block things but report "would-be" violations to the server.
  4. If COEP is "require-corp" and the reporting endpoint is set: COEP is effective, and report violations to the server.

I thought the third settings would be the "report-only" mode.

  1. We could do this in one header rather than two (or four, if report-only is a thing). Wouldn't a param be simpler?

I'm fine with this.

@mikewest
Copy link
Member

I thought the third settings would be the "report-only" mode.

Got it. I'm fine with that. It's a little distinct from CSP, but that's not necessarily a bad thing.

If we go that route, the single-header variant I've suggested above would require introducing a new token. Perhaps none, or something more explicit (like report-corp-violations)?

@yutakahirano
Copy link
Collaborator Author

I fixed the header parsing part (I haven't changed the properties on context objects yet). Mike, can you take a look at that part?

@yutakahirano
Copy link
Collaborator Author

Now I think I addressed your comment. PTAL.

Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty reasonable to me. I'd like @annevk's opinion as well, as I think he disagrees about the header syntax, and we should probably chat about it rather than just landing this. :)

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
@arturjanc
Copy link

  1. Do we need a report-only mode? ( @arturjanc )

I think you've settled this already, but just mentioning that the approach above looks good to me (the 4 behaviors mentioned by @yutakahirano, possibly updated if we decide to go with the single-header variant).

In general, I'd posit that there are a lot of benefits to having a report-only mode for everything :)

@annevk
Copy link
Contributor

annevk commented Feb 3, 2020

Does anyone have some examples to evaluate? I find the diff a little hard to read.

yutakahirano and others added 4 commits February 4, 2020 14:28
Accept mikewset's suggestion

Co-Authored-By: Mike West <mike@mikewest.org>
Accept mikewest's suggestion

Co-Authored-By: Mike West <mike@mikewest.org>
@yutakahirano
Copy link
Collaborator Author

yutakahirano commented Feb 4, 2020

This change:

  • introduces "unsafe-none" as a value of the COEP header.
  • introduces "report-to" parameter to the COEP header
  • introduces the embedder policy concept which consists of COEP value and the reporting endpoint.

COEP headers now look like:

  • unsafe-none : Do nothing.
  • unsafe-none; report-to=endpoint Do not block things, but report would-be violations using "endpoint" reporting endpoint.
  • require-corp: COEP is effective without reporting
  • require-corp; report-to=endpoint: COEP is effective and report violations using "endpoint" reporting endpoint.

This change does NOT include how the reporting endpoint is used. I'm going to publish another PR for that part.

@annevk, does this summary help?

@yutakahirano
Copy link
Collaborator Author

yutakahirano commented Feb 5, 2020

I would like the syntax to be aligned with COOP reporting. @camillelamy, are you fine with the proposal?

@annevk
Copy link
Contributor

annevk commented Feb 5, 2020

The summary is great, thanks again!

After discussion on IRC I think I'm okay with this approach, as we'll likely keep COOP and COEP scoped to a simple enumerated value. If anyone foresees them using more complex values, now would be the time to bring that up. (If the value can be more complex, I think you want more headers eventually, as explained in https://github.com/w3c/webappsec-feature-policy/issues/362#issuecomment-582302307.)

@zcorpan
Copy link
Contributor

zcorpan commented Feb 5, 2020

@yutakahirano the : is supposed to be ; , correct?

@yutakahirano
Copy link
Collaborator Author

@zcorpan Yes, thanks. Fixed.

index.bs Outdated Show resolved Hide resolved
Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this % the discussion of parameter types. If @camillelamy and team are happy too, I'll pull it in.

index.bs Outdated Show resolved Hide resolved
@camillelamy
Copy link

Our proposal for COOP does not have the same syntax. Currently we're looking at 3 headers:

  • Cross-Origin-Opener-Policy: the policy to enforce
  • Cross-Origin-Opener-Policy-Report-Only: allows to specify a policy which is not enforced and for which we only provide reports
  • Cross-Origin-Opener-Policy-Report-Endpoint: where to send the reports (which would be generated for both the COOP enforced and the COOP report-only mode).

We could move to a model closer to the one you propose. but we'd still have two headers:

  • Cross-Origin-Opener-Policy : value; report-to=endpoint
  • Cross-Origin-Opener-Policy-Report-Only : value; report-to=endpoint

This is because COOP has 3 values, so we cannot make the assumption that unsafe-none + an endpoint means we want a report only mode for same-origin (it could be same-origin-allow-popups).

The problem I see with the current approach for COEP is that if we want to add another value to the header, the report-only mode doesn't work anymore (like it wouldn't with COOP). If we foresee the need to eventually add another value, we should allow the developer to specify explicitly which policy they want report-only mode for instead of making this deduction.

@annevk
Copy link
Contributor

annevk commented Feb 6, 2020

Thanks Camille! @yutakahirano had an idea for that problem when COEP gets to it, but now you contrast it with COOP I think we ought to solve it now so we can have a consistent reporting story across these two features.

@yutakahirano
Copy link
Collaborator Author

Thank you, Camille.

Does the following work?

cross-origin-opener-policy: policy; reporting_as=another policy; reporting_to=endpoint

I'm also fine with the two-headers version. The three-headers version seems too verbose to me.

@camillelamy
Copy link

I think the two headers version matches what CSP is doing, right? If I'm not mistaken, CSP has two headers: Content-Security-Policy and Content-Security-Policy-Report-Only. It might be easier for developers to have the same model for COOP and COEP?

@yutakahirano
Copy link
Collaborator Author

Fixed. Now we have two headers: "Cross-Origin-Embedder-Policy" (COEP) and "Cross-Origin-Embedder-Policy-Report-Only" (COEP-Report-Only). I removed "unsafe-none" value from the header(s).

Cross-Origin-Embedder-Policy-Report-Only is ignored if there is (valid) Cross-Origin-Embedder-Policy attached; Hence there are four modes:

  • COEP: require-corp: CORP-Report-Only is ignored. COEP is effective. Violations are not reported.
  • COEP: require-corp; report-to="endpoint": CORP-Report-Only is ignored. COEP is effective. Violations are reported to "endpoint".
  • (COEP: missing,) COEP-Report-Only: require-corp: No effect
  • (COEP: missing,) COEP-Report-Only: require-corp; report-to="endpoint": Do not block things. Potential violations are reported to "endpoint".
  • (COEP: missing, COEP-Report-Only: missing): No effect

The "embedder policy" concept consists of value (either "require-corp" and "unsafe-none"), and reporting endpoint. Unlike the pair of headers above, this concept covers all modes by itself.

  • {value: "require-corp", reporting endpoint: null}: COEP is effective. Violations are not reported.
  • {value: "require-corp", reporting endpoint: "endpoint"}: COEP is effective. Violations are reported to "endpoint".
  • {value: "unsafe-none", reporting endpoint: null}: No effect
  • {value: "unsafe-none", reporting endpoint: "endpoint"}: Do not block things. Potential violations are reported to "endpoint".

The embedder policy concept is not exposed to HTTP, so if the syntax grows we can change the concept without breaking things.

@mikewest @annevk @camillelamy Are you fine with the latest change?

@camillelamy
Copy link

Thanks! I am happy with the latest version.

@yutakahirano
Copy link
Collaborator Author

@annevk @mikewest can you take a look at the latest change? Thanks!

Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % one comment.

index.bs Outdated

1. Set |header| to the result of [=isomorphic decoding=] |header|.
2. Return a new [=/embedder policy=] whose [=embedder policy/value] is |parsed item|'s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that COEPRO is ignored in the presence of COEP. This is probably fine for the moment, since there's only one value, but would make it difficult to support enforcement of one value and reporting on another if we have multiple values in the future.

Perhaps add a note to that effect? I'm not sure it's worth adding complexity until we need it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say COEPRO is ignored if its value is equal to or weaker than the COEP value. That rule is natural, and we'll want to keep the rule even when we introduce more values. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. That's not the way CSP works.
  2. What do we do with COEP: require-corp\nCOEPRO: require-corp; report-to=whatever? Should that not send reports?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... so you prefer having two values and endpoints. I'll try to modify the logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need to have two values and endpoints to support both enforce and report-only at the same time. I don't think that's actually relevant to any developer's life until we have multiple values (I have require-cors in the back of my head (because a value with a one-character difference to create radical behavioral differences is a great spelling option)), so I wouldn't mind explicitly punting on it. But doing it now certainly wouldn't be wasted effort.

Copy link
Collaborator Author

@yutakahirano yutakahirano Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Now the embedder policy concept has four members.

  • value
  • reporting endpoint
  • report only value
  • report only reporting endpoint

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reporting endpoint / report only reporting endpoint is not set if value / report only value is not "require-corp" but it doesn't affect the behavior because we'll have nothing to report for "unsafe-none".

@yutakahirano
Copy link
Collaborator Author

ping?

Copy link
Member

@mikewest mikewest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's land this and continue iterating. :)

@mikewest mikewest merged commit 31591be into WICG:master Feb 19, 2020
@yutakahirano
Copy link
Collaborator Author

Thank you!

blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this pull request Feb 26, 2020
Being proposed as WICG/cross-origin-embedder-policy#8.

This CL introduces a new mojo struct,
CrossOriginEmbedderPolicyWithReporting to group related values. It has
(virtually trivial) type mapping, because mojo::[Inlined]StructPtr is
initialized as null while we don't want to allow null for
CrossOriginEmbedderPolicyWithReporting.


Bug: 1052764
Change-Id: I1985f24386c9dd3f76bfd2bab395b9103d14a4ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2060090
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744490}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants