Use JavaScript to detect if accessing SI over Tor2Web #6303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Status
Ready for review
Description of Changes
For people who are accidentally accessing SecureDrop over Tor2Web (e.g.
by finding it in a search engine), it's probable that they are using a
normal browser and still have JavaScript installed. So we use
location.href
to detect the URL they accessed the SecureDrop instanceover and redirect to the
/tor2web-warning
endpoint if the URL'shostname doesn't end in
.onion
(with an exception for localhost).This is intended to be a best-effort measure, as there's nothing
stopping the Tor2Web proxy from intercepting/modifying our JavaScript.
Fixes #6294.
Testing
make dev
, access the SI over localhost, should not be redirected.make dev-tor
, access the SI over the intended .onion address, should not be redirected.make dev-tor
, access the SI over a tor2web proxy likeonion.ly
, should be redirected to tor2web warning.You can also repeat the test plan with the changes in #6300, it should be fully compatible.
Deployment
Any special considerations for deployment? No.
Checklist