-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add security related headers for static resources #24272
base: master
Are you sure you want to change the base?
Conversation
Add the following security headers to static resources, including `html`, `js`, and `css` files. - Add `X-Content-Type-Options` header and assign the value to 'nosniff' - Add `Content-Security-Policy` header and proper values - default-src: 'self' - style-src: 'self' 'unsafe-inline' https://fonts.googleapis.com - font-src: self fonts.gstatic.com - frame-ancestors: self Signed-off-by: Yihong Wang <yh.wang@ibm.com>
I also added the |
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | ||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
<script src="vendor/html5shiv/html5shiv.min.js"></script> | ||
<script src="vendor/respond/respond.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yhwang , thanks for the work. Just wondering why did we vendor these, instead of getting from CDN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question and the answer is Cross-Domain JavaScript Source File Inclusion
.
We already include most of the 3rd party libs except these two. So I directly included them as well. Besides, the script-src
attribute of the CSP header has self
as the value. I don't want to add oss.maxcdn.com just for these two libs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying, it seems you are trying to follow the standard here. May be some one more expert can comment on the right path here.
Description
Add the following security headers to static resources, including
html
,js
, andcss
files.X-Content-Type-Options
header and assign the value to 'nosniff'Content-Security-Policy
header and proper valuesMotivation and Context
fix: #24271
Impact
N/A
Test Plan
Check the response headers for the static resources
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.