-
Notifications
You must be signed in to change notification settings - Fork 389
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
feat(gnoweb): add secure headers by default & timeout configuration #3619
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
🛠 PR Checks Summary🔴 Must not contain the "don't merge" label Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Overall LGTM 👍 I just asked a question bellow about your strict mode
// cross-site scripting (XSS) and other code injection attacks. | ||
// - 'self' allows resources from the same origin. | ||
// - 'data:' allows inline images (e.g., base64-encoded images). | ||
w.Header().Set("Content-Security-Policy", "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'") |
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.
So I haven't tested it locally yet, but is there a way to host images (for example) on Gnoweb? Because if we restrict access to "img-src" to "self" and there are no tricks for hosting them on Gnoweb, it will force user to hardcode base64 in their markdown.
And I have a feeling that hardcoding binary data into source code is not a great idea. We might need an equivalent to git-lfs. Or a way to host photos on the gno.land domain that relies on simple object storage and is not tied to the blockchain.
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.
That's a really good point. Discussing a bit with @moul, the plan is to have a whitelist of authorized hosts for images. We can keep allowing any external source for now (for images only) until we implement this whitelist system. I think we also want to deny any embed data:
to prevent people from storing raw images on gnoland, but I'm unsure of applying this in this PR.
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.
Okay, got it. Looks good 👍
Co-authored-by: Antoine Eddi <5222525+aeddi@users.noreply.github.com>
Can a user upload a .js file as part of their realm and use this to bypass CSP projection due to |
This is a good resource for security headers: Notwithstanding my above query, the other headers set look good. Another header we might want to consider:
Once this is deployed somewhere we should double check headers with https://securityheaders.com/ |
This PR adds the following secure headers by default
strict=true
to gnoweb:I've also enforced a timeout on read/write/idle (default to 1 minute).
cc @kristovatlas