Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amp-script in sandboxed mode still asks for CSP hash if src url is cross origin #36614

Closed
zshnr opened this issue Oct 27, 2021 · 1 comment · Fixed by #36618
Closed

Amp-script in sandboxed mode still asks for CSP hash if src url is cross origin #36614

zshnr opened this issue Oct 27, 2021 · 1 comment · Fixed by #36618

Comments

@zshnr
Copy link
Contributor

zshnr commented Oct 27, 2021

Description

Based on the I2I #30193, the sandboxed mode was introduced in as part of PR #33643. The idea behind sandboxed mode was putting the 3p script behind a sufficient enough security boundary and not requiring CSP hashes. This is important to us because our SDK updates in a similar manner to AMP. I.e. new builds replace old ones at the same URL.

However, while this works fine for scripts referenced from the filesystem or inline scripts, it does not seem to work for cross origin scripts.

The reason for this is a missing this.sandboxed_ check inside the fetchAuthorScript_ inside amp-script.js where we skip the CSP hash check for this.development_.

I wonder if this has been mistakenly omitted. If so, I am happy to create a PR for this.

Tagging @samouri who originally worked on PR #33643

Reproduction Steps

I'm not sure why I can't see the CSP hash error in console in AMP Playground

But essentially, if you were to add this to an AMP page:

<amp-script sandboxed src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.24.0/axios.min.js"></amp-script>

You will see the CSP error. However, if you download and include the file from the filesystem. For e.g.

<amp-script sandboxed src="axios.min.js"></amp-script>

It will be fine without the CSP hash.

Please note that the axios script is not important, this is just an example of a publicly available script that I had at hand.

Relevant Logs

No response

Browser(s) Affected

Chrome, Edge

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

2110082201001

@zshnr
Copy link
Contributor Author

zshnr commented Oct 27, 2021

After talking with @samouri, I'll create a PR for this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant