Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Tor browser context #473

Merged
merged 36 commits into from
Jul 18, 2018
Merged

Tor browser context #473

merged 36 commits into from
Jul 18, 2018

Commits on Jul 6, 2018

  1. Tor Browser Context

    1. context creating options: "isolated_storage", "tor_proxy"
    2. setTorNewIdentity API
    3. automatically launch tor when tor browser context created and tear it
    down when tor browser context destroyed
    
    fix #468
    fix #464
    fix #509
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    3c49f14 View commit details
    Browse the repository at this point in the history
  2. Get tor path from browser-laptop

    jumde authored and darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    3c4b47b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    207975d View commit details
    Browse the repository at this point in the history
  4. Make sure tor process is launched before finishing browser context

    construciton.
    
    There will be a utility process responsible for launching tor and
    monitor it by mojo tor launcher service
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    f4b2b29 View commit details
    Browse the repository at this point in the history
  5. Use pipe hack to notify browser process that tor process has terminated

    When browser process receives notification, it will relaunch tor process
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    3a37921 View commit details
    Browse the repository at this point in the history
  6. Only handle child core dump or be terminated by signal or exit.

    Also set read pipe socket to blocking mode
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    06873bb View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    4ca20e9 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    a9dec23 View commit details
    Browse the repository at this point in the history
  9. Windows Fix

    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    a06ff8d View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    6e5096f View commit details
    Browse the repository at this point in the history
  11. C66 rebase

    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    ed092ca View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    a0c005f View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    80a8283 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    bb6efb2 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    579d7d2 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    9b7ab85 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    b79be43 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    ee12072 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    92cc9e2 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    3a07530 View commit details
    Browse the repository at this point in the history
  21. Enable tor daemon control port.

    riastradh-brave authored and darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    bc12974 View commit details
    Browse the repository at this point in the history
  22. Put the control auth cookie in the watch directory too.

    This is necessary because there is an unfortunate ordering issue with
    tor startup: it writes the control port first, and then the auth
    cookie, but we need both in order to connect to the control port.
    And it doesn't delete the auth cookie, so it can get stale.  Hence we
    need to monitor writes to the auth cookie too.
    riastradh-brave authored and darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    bef8c90 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    1d26b72 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    1588b13 View commit details
    Browse the repository at this point in the history
  25. Propagate off-the-recordness to URL request context.

    This is necessary because we use `persist:tor' since for hysterical
    raisins there's only one normal `private' partition with in_memory_ =
    true.  We use the virtual method IsOffTheRecord() to discriminate
    instead.
    
    Fixes #608.
    Fixes brave/browser-laptop#14392.
    
    Auditors: @darkdh
    riastradh-brave authored and darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    756c3ca View commit details
    Browse the repository at this point in the history
  26. C67 rebase

    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    982d067 View commit details
    Browse the repository at this point in the history
  27. Export Session.relaunchTor API which will terminate current tor process

    and launch new one with same arguments
    
    Auditors: @riastradh-brave, @diracdeltas
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    86b4d81 View commit details
    Browse the repository at this point in the history
  28. Export Session.setTorLauncherCallback((result, pid) =>{...}) and Sess…

    …ion.getTorPid()
    
    NOTE:
    Use setTorLauncherCallback right after Session.fromPartition for tor browser context
    if you want to get pid after launch
    
    Auditors: @riastradh-brave, @diracdeltas
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    53efe51 View commit details
    Browse the repository at this point in the history
  29. Retire tor circuit isolation key only when it is about to be used

    because we don't want to spend extra cycles to keep track of expired
    keys
    
    fix #611
    
    Auditors: @riastradh-brave
    darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    5657527 View commit details
    Browse the repository at this point in the history
  30. Use a priority queue to expire all >10min-old tor circuit records.

    Don't just expire any old entries for the site we're browsing -- that
    may leave lots of other ones around in memory.
    riastradh-brave authored and darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    fbf2a29 View commit details
    Browse the repository at this point in the history
  31. Use a timer to expire circuits promptly.

    The timer is scheduled to run ten minutes after the last circuit that
    was created.  This way, the last ten minutes of circuits are not
    guaranteed to stick around in memory indefinitely.
    
    Caveat: This doesn't _zero_ the memory, so it may still appear in
    `strings /proc/N/mem`.  But it does make the memory available to be
    recycled, so it's not _guaranteed_ to still appear in `strings
    /proc/N/mem`.
    
    Also, timestamp the map entries.  If we explicitly create a new map
    entry for a site by requesting a new identity, the old expiry queue
    entry will not delete it, but a new expiry queue entry will delete
    it.  This way, circuits created by requesting a new identity are not
    shorter-lived than other circuits.
    
    We leave the old entries in the priority queue because there's no
    convenient way to delete them with std::priority_queue.  In
    principle, this might leak space if you repeatedly request a new
    identity, but it can only leak as much space as you use by repeatedly
    requesting a new identity for a maximum of ten minutes.
    
    fix #611 real good this time
    
    Auditors: @darkdh
    
    Test Plan:
    1. Search DDG for `what is my ip address'.
    2. Record the IP address it reports.
    3. Reload.
    4. Confirm it's the same IP address.
    5. Full-reload.
    6. Confirm it's a different IP address.  Record the new IP address.
    7. Wait >10min.
    8. Reload.
    9. Confirm it's a different IP address again.
    riastradh-brave authored and darkdh committed Jul 6, 2018
    Configuration menu
    Copy the full SHA
    c59eec1 View commit details
    Browse the repository at this point in the history

Commits on Jul 12, 2018

  1. patch cleanup

    Auditor: @bridiver
    darkdh committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    1ee6a7f View commit details
    Browse the repository at this point in the history
  2. Prevent SuicideOnChannelErrorFilter to be added to tor_launcher uti…

    …lity process
    
    fix brave/browser-laptop#14636
    
    SuicideOnChannelErrorFilter calls exit in OnChannelError() this will
    cause other endpoints listener can't finish their cleanup when pipe error
    happens(browser process crashed or be killed) and
    SuicideOnChannelErrorFilter::OnChannelError happens to be called before others.
    This should be fine for most of the cases but not tor_launcher service.
    `TorLauncher` requires StrongBinding::OnConnectionError to delete itself
    so that `~TorLauncher` will get called and terminate tor process.
    
    This should only happens on MacOS, SuicideOnChannelErrorFilter is
    guarded by OS_POSIX and Linux has `prctl(PR_SET_PDEATHSIG, SIGKILL)`
    so tor process will receive SIGKILL when tor_launcher utility process terminates
    prematurely
    
    Auditors: @riastradh-brave, @bridiver, @bbondy
    darkdh committed Jul 12, 2018
    Configuration menu
    Copy the full SHA
    24d5346 View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2018

  1. Use new site instance for SessionStorageNamespaceImpl clone when open…

    …er_suppressed(noopener) specified
    
    because WebContentsImpl::CreateNewWindow will use target_url as new site instance
    
    The problem was cloning original site instance cause the inconsistency
    between original partition and target partition because tor browser
    context enforce isolation storage so every different site has its own storage partition
    
    fix brave/browser-laptop#14392
    
    Test Plan:
    1. Open tor tab
    2. Visit site contains rel="noopener" href (https://jsfiddle.net/dqokhmsg/)
    3. Click the link
    4. Brave shouldn't crash
    
    Auditors: @bridiver, @bbondy
    darkdh committed Jul 14, 2018
    Configuration menu
    Copy the full SHA
    65872a4 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2018

  1. Merge pull request #631 from brave/tor_cleanup

    Prevent `SuicideOnChannelErrorFilter` to be added to tor_launcher utility process
    darkdh authored Jul 17, 2018
    Configuration menu
    Copy the full SHA
    fb9327a View commit details
    Browse the repository at this point in the history

Commits on Jul 18, 2018

  1. Merge pull request #632 from brave/noopener_check

    Use new site instance for SessionStorageNamespaceImpl clone when opener_suppressed(noopener) specified
    darkdh authored Jul 18, 2018
    Configuration menu
    Copy the full SHA
    0ef0d3c View commit details
    Browse the repository at this point in the history