Skip to content

Explicitly specify requireAmpResponseSourceOrigin=false if missing#6724

Merged
lannka merged 2 commits intoampproject:masterfrom
lannka:deprecate-amp-response-source-origin
Dec 20, 2016
Merged

Explicitly specify requireAmpResponseSourceOrigin=false if missing#6724
lannka merged 2 commits intoampproject:masterfrom
lannka:deprecate-amp-response-source-origin

Conversation

@lannka
Copy link
Copy Markdown
Contributor

@lannka lannka commented Dec 17, 2016

For #6716

This is the 1st step to deprecate field requireAmpResponseSourceOrigin.
To make sure no version skew between runtime and extensions, we do

  1. make all calls explicitly specify requireAmpResponseSourceOrigin.
  2. Once change 1) is in production, we can default requireAmpResponseSourceOrigin to true.

/cc @keithwrightbos

@lannka lannka added WIP and removed WIP labels Dec 17, 2016
@lannka lannka requested a review from cramforce December 19, 2016 18:37
'requireAmpResponseSourceOrigin is deprecated, use ampCors instead');
}

if (init.requireAmpResponseSourceOrigin === undefined) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For backward compat during version skew, you will need to make this change first and then make the extension changes one release later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Aren't all extensions rolling out together with runtime?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But they may be cached at different times on the reader's computer when browsing a pub's site.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If that's a concern, then any changes on runtime and extension can have problem.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, you must be conscious about it. But renaming APIs in core definitely causes such issues.

We try to avoid skew in as many places as we can, but it can absolutely happen.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK. I've reverted my 2nd commit. Now this PR simply make all the calls explicit about the requireAmpResponseSourceOrigin param. Once this get in prod, we can then have another PR to default it to true.

PTAL.

@lannka lannka force-pushed the deprecate-amp-response-source-origin branch from c61e141 to 756db35 Compare December 19, 2016 21:53
@lannka lannka changed the title Deprecate requireAmpResponseSourceOrigin field in XHR Explicitly specify requireAmpResponseSourceOrigin=false if missing Dec 19, 2016
Copy link
Copy Markdown
Member

@cramforce cramforce left a comment

Choose a reason for hiding this comment

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

One comment.

if (!(fullUrl in ampCustomadXhrPromises)) {
// Here is a promise that will return the data for this URL
ampCustomadXhrPromises[fullUrl] = xhrFor(this.win).fetchJson(fullUrl);
ampCustomadXhrPromises[fullUrl] = xhrFor(this.win).fetchJson(fullUrl, {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is young enough. We must require this here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changing it directly might potentially break @xgretsch . I'll do it separately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, please discuss with them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm on leave and can't check it on my development system. But just looking at things: if I've understood this correctly, this simply enforces that this call is NOT requiring the special AMP-Access-Control-Allow-Source-Origin header. Since there's no damage to us if someone else shows our ads, I don't have a problem with this. If you let me know when this is going into canary, I'll check it then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@xgretsch this does not change everything. requireAmpResponseSourceOrigin defaults to false, this PR just made it explicit.

For security reason, we do have plan to change it to true though, which will need a change at your server side.

I'll open a separate issue to track that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me know when you've put in a separate issue. In the mean time, I've added the following header to the source code of my ad server:
AMP-Access-Control-Allow-Source-Origin: *

What I would really like to know is this: do you have any documents explaining the kind of attack that this feature is designed to protect against? Because in this case, where the response from the server is never interpreted as a script, I can't immediately think of one...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@xgretsch check this if you haven't. Because AMP can be cached, all pages from different publisher are served on the same CDN domain. So AMP CORS is an important mechanism to differentiate different publishers on CDN.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lannka Thanks for the reference. Everything in there makes complete sense for a state-changing request, where it's a great idea to discourage requests from the wrong place. For a request which is not state-changing, like a set of ad fetches, I still cannot for the life of me see why one would bother.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see your point. But overall we're building a platform for anyone to use, not for a single use case. So being cautious and make a high bar starting from the beginning is not a bad idea.

@lannka lannka merged commit efc2648 into ampproject:master Dec 20, 2016
@lannka lannka deleted the deprecate-amp-response-source-origin branch December 20, 2016 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants