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

Consider CSP's built-in fallback mechanism #57

Merged
merged 1 commit into from
Jan 4, 2016

Conversation

sandstrom
Copy link
Collaborator

CSP has a built-in fallback mechanism. If, say, connect-src is not defined it will fall back to default-src. This can cause issues when the addon appends to an empty directive.

An example:

Developer has has defined the following policy:
`default-src: 'self' example.com;`

An xhr to example.com (the connect-src directive) will be allowed. 
Since no connect-src directive is defined it will fallback to default-src.

Then an addon appends the connect-src entry live-reload.local, and the result is:
`default-src: 'self' example.com; connect-src: live-reload.local;`

After the addons change an xhr to example.com (which was previously permitted, 
via fallback to default-src) is now rejected since it doesn't match 'live-reload.local'.

This PR fixes this by copying from default-src before appending to an empty entry.

@sandstrom
Copy link
Collaborator Author

@rwjblue eager to hear your thoughts on this!

It'll make the addon more pleasant to use. It avoids a scenario when CSP-adjustments (for live-reload, and in the future other addons) will cause unexpected behaviour.

@rwjblue
Copy link
Owner

rwjblue commented Jan 4, 2016

Thanks for explaining this in more detail over in slack. This looks good to me.

rwjblue added a commit that referenced this pull request Jan 4, 2016
Consider CSP's built-in fallback mechanism
@rwjblue rwjblue merged commit d7a6e4a into rwjblue:master Jan 4, 2016
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.

None yet

2 participants