Skip to content

Move cors.X_FRAME_OPTIONS to security.X_FRAME_OPTIONS and add false option #30256

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

silverwind
Copy link
Member

@silverwind silverwind commented Apr 2, 2024

The value of X-Frame-Options was previously in the cors section but it's in fact entirely unrelated to CORS but a separate security-related option which should be in the security section.

Additionally I've added a special value false, that if set will not add the header at all, e.g. the "insecure" variant.

I don't expect much breakage from this because the only other valid value is DENY and people who wanted to remove the header would have likely done so at load-balancer level because gitea previously did not allow to unset the header at all.

⚠️ BREAKING ⚠️

The cors.X_FRAME_OPTIONS setting has been moved to security.X_FRAME_OPTIONS. If you had customized this setting, please move it to the security section.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 2, 2024
@silverwind silverwind added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Apr 2, 2024
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/docs labels Apr 2, 2024
@silverwind silverwind added the type/enhancement An improvement of existing functionality label Apr 2, 2024
@silverwind silverwind changed the title Move cors.X_FRAME_OPTIONS to security.X_FRAME_OPTIONS and add falseoption Move cors.X_FRAME_OPTIONS to security.X_FRAME_OPTIONS and add false option Apr 2, 2024
@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 2, 2024
@silverwind
Copy link
Member Author

silverwind commented Apr 3, 2024

BTW, the reason I investigated this is to set a default CSP header. CSP does include a frame-ancestors directive that obsoletes X-Frame-Options, so I guess we could avoid double breaking changes by moving the option to CSP in this PR with a option like security.CSP_FRAME_ANCHESTORS.

@silverwind
Copy link
Member Author

I guess it's alright to merge this as-is. If we introduce CSP later, we can change the default of this value to false. CSP is a bigger topic that I want to do in a separate PR.

@lunny
Copy link
Member

lunny commented Apr 3, 2024

Maybe we should have a warning if we detect the old value and have some warning on the admin panel.

@silverwind
Copy link
Member Author

Maybe we should have a warning if we detect the old value and have some warning on the admin panel.

Should be possible. Any pointers where this warning code is?

@lunny
Copy link
Member

lunny commented Apr 3, 2024

You can use deprecatedSetting function, you can search the code and find some examples.

@silverwind silverwind marked this pull request as draft April 4, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/docs modifies/go Pull requests that update Go code pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants