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

Use JavaScript to detect if accessing SI over Tor2Web #6303

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Feb 23, 2022

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 instance
over and redirect to the /tor2web-warning endpoint if the URL's
hostname 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

  • Run make dev, access the SI over localhost, should not be redirected.
  • Run make dev-tor, access the SI over the intended .onion address, should not be redirected.
  • Run make dev-tor, access the SI over a tor2web proxy like onion.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

  • I have written a test plan and validated it for this PR
  • These changes do not require documentation

@legoktm legoktm requested a review from a team as a code owner February 23, 2022 06:18
@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2022

Codecov Report

Merging #6303 (71cc99b) into develop (ecd6b2b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #6303   +/-   ##
========================================
  Coverage    84.07%   84.07%           
========================================
  Files           60       60           
  Lines         4208     4208           
  Branches       508      508           
========================================
  Hits          3538     3538           
  Misses         549      549           
  Partials       121      121           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecd6b2b...71cc99b. Read the comment docs.

Copy link
Contributor

@zenmonkeykstop zenmonkeykstop left a comment

Choose a reason for hiding this comment

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

  • Run make dev, access the SI over localhost, should not be redirected. **failed initially, worked via 127.0.0.1
  • Run make dev-tor, access the SI over the intended .onion address, should not be redirected.
  • Run make dev-tor, access the SI over a tor2web proxy like onion.ly, should be redirected to tor2web warning.

@zenmonkeykstop zenmonkeykstop added this to the 2.3.0 milestone Feb 23, 2022
@legoktm legoktm force-pushed the 6294-javascript-tor2web branch from 71cc99b to a5f1178 Compare February 23, 2022 19:29
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 instance
over and redirect to the `/tor2web-warning` endpoint if the URL's
hostname 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.
@legoktm legoktm force-pushed the 6294-javascript-tor2web branch from a5f1178 to 8a37577 Compare February 23, 2022 19:31
@zenmonkeykstop zenmonkeykstop merged commit 0b3ad4c into develop Feb 24, 2022
@legoktm legoktm deleted the 6294-javascript-tor2web branch February 25, 2022 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add Javascript code to SI index page to detect tor2web usage in non TBB browsers.
3 participants