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

Set Cross-Origin-Opener-Policy: same-origin on all pages #5442

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alikabeel-spooner
Copy link

Hello Team,

This PR fixes HackerOne Report 2681420. In the previous fix #4910, @segiddins add the header to all standard pages (not errors). However, the fix did not cover the cases of non-existing paths (errors). This PR fixes the issue by ensuring all pages, even errors, have the header correctly set. I tested this locally, and it should work fine on all paths. Can you kindly review and merge this PR and then close the H1 report so that I can claim the bounty?

Best,
Ali

@alikabeel-spooner
Copy link
Author

cc @segiddins @duckinator since you are working on the report.

@alikabeel-spooner
Copy link
Author

cc @segiddins @duckinator gentle ping on this one.

@simi
Copy link
Member

simi commented Feb 17, 2025

@alikabeel-spooner people will check once they will find some time, no need to keep pinging

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 6.54%. Comparing base (8ed4d35) to head (c34b345).
Report is 41 commits behind head on master.

Files with missing lines Patch % Lines
...emcutter/middleware/security_headers_middleware.rb 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #5442       +/-   ##
==========================================
- Coverage   97.06%   6.54%   -90.52%     
==========================================
  Files         451     452        +1     
  Lines        9391   13171     +3780     
==========================================
- Hits         9115     862     -8253     
- Misses        276   12309    +12033     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -84,10 +88,6 @@ class Application < Rails::Application
config.active_support.cache_format_version = 7.1

config.action_dispatch.rescue_responses["Rack::Multipart::EmptyContentError"] = :bad_request

config.action_dispatch.default_headers.merge!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead upstream this to rails so the default headers also apply on error pages?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not an expert in rails. So, if you think it would work, we can surely try it. I was just trying to create something that works and fixes the issue but need your kind help to get this done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to ask the same. 💪 This seems good default for new apps.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally good to me! If you can do that or guide me on what to do, it would be great.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out Rails as a bug bounty program where I can report this issue to see if they are interested in fixing. Since this can take time, I am not sure if in the meanwhile we want to merge this temporary patch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm affraid this patch is not worth any bug bounty program.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simi actually the COOP header protects against a class of XS-Leaks using Cross Window Navigation. It is usually accepted as a low/medium issue in BBPs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe https://github.com/sinatra/sinatra/tree/main/rack-protection could be good target to contribute

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into that as well. Thanks! How do you prefer to tackle this PR until i figure out whether it is rails or sinatra?

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

Successfully merging this pull request may close these issues.

3 participants