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

Remediate TunnelVision, TunnelCrack and fix "Exclude Local Networks" #3460

Merged
merged 29 commits into from
Nov 11, 2024

Conversation

diegoreymendez
Copy link
Contributor

@diegoreymendez diegoreymendez commented Oct 20, 2024

Task/Issue URL: https://app.asana.com/0/1206580121312550/1208686409805161/f
Tech Design URL: https://app.asana.com/0/481882893211075/1208643192597095/f

macOS PR: duckduckgo/macos-browser#3422
BSK PR: duckduckgo/BrowserServicesKit#1039

Description

Remediate TunnelVision, TunnelCrack and fix "Exclude Local Networks".

Testing

Test 1: External Users aren't affected

Prerequisites:

  • Make sure you're an external user.

Steps:

  1. The easiest way to test is by disabling Settings > All debug options > Network Protection > "Enforce routes", because when enforceRoutes is OFF, you'll be able to access your local network devices, but when it's ON you won't be able to access those devices.
  2. Star the VPN.
  3. Make sure you can access the internet and all local devices.

Test 2: Internal Users get new routing

Prerequisites:

  • Make sure you're an internal user.
  • Make sure the enforceRoutes remote feature flag is ON.

Steps:
2. Star the VPN (the first time you start the VPN as an internal user, "Enforce routes" should be enabled).
3. Make sure you can access the internet.
4. Make sure you cannot access local devices.

Test 3: Internal Users can override enforce routes.

Prerequisites:

  • This should be run after test 2, as it shows that enforce routes won't be force-enabled more than once.
  • Make sure you're an internal user.

Steps:

  1. If the VPN is ON, turn it OFF.
  2. Disable Settings > All debug options > Network Protection > "Enforce routes".
  3. Start the VPN
  4. Make sure you can access local network devices.

Test 4: TunnelVision fixed when enforceRoutes is ON.

Prerequisites:

  • Make sure you're an internal user.
  • Make sure enforceRoutes is ON.
  • Prepare TunnelVision against ifconfig.me

Steps:

  1. Start the VPN.
  2. Check against an IP address site (not ifconfig.me) that the right tunnel address is shown.
  3. Connect to a WiFi exploiting TunnelVision against site ifconfig.me.
  4. Load site ifconfig.me and ensure it shows the VPN tunnel IP.

Test 5: TunnelCrack blocks all VPN traffic.

Prerequisites:

  • Make sure you're an internal user.
  • Make sure enforceRoutes is ON.
  • Prepare the TunnelCrack local network exploit.

Steps:

  1. Start the VPN.
  2. See that no traffic gets out of the VPN, and the connection is blocked.

Please note: I'm suggesting we show a warning here, but this will be tackled as a follow-up task.


Internal references:

Software Engineering Expectations
Technical Design Template

@diegoreymendez diegoreymendez changed the title Fixes TunnelVision using enforceRoutes Remediate TunnelVision, TunnelCrack and fix "Exclude Local Networks" Nov 6, 2024
@diegoreymendez diegoreymendez marked this pull request as ready for review November 6, 2024 11:13
Comment on lines 135 to 139
if !settings.enforceRoutesForceEnabledOnce {
settings.enforceRoutesForceEnabledOnce = true
settings.excludeLocalNetworks = true
settings.enforceRoutes = true
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first time the VPN is started with the feature flag ON, we'll enable enforce routes. But the setting can be overridden by internal users in case there's trouble.

Comment on lines -53 to -55
.onTapGesture {
viewModel.toggleExcludeLocalNetworks()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not really working at all, and adding to the overall problems.

Comment on lines 24 to 31
func restartAdapter() async throws {
guard let activeSession = await AppDependencyProvider.shared.networkProtectionTunnelController.activeSession(),
activeSession.status == .connected else {

return
}

try? await activeSession.sendProviderRequest(.command(.restartAdapter))
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about instead putting this in NetworkProtectionTunnelController? (I wonder whether the tunnel controller should have a function like sendProviderRequest that abstracts the fetching of the session etc., since we have similar logic in a few places.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I was avoiding it because this forces the change on macOS (as I need to modify the TunnelController protocol) which requires some thinking.

That said, I think it makes sense so I pushed the change.

Copy link
Contributor

@not-a-rootkit not-a-rootkit left a comment

Choose a reason for hiding this comment

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

It's a bit harder to test the exploit on iOS but I've validated it's remediated and couldn't find any issues with it. Code looks clear too. ✅

diegoreymendez added a commit to duckduckgo/BrowserServicesKit that referenced this pull request Nov 11, 2024
…1039)

Task/Issue URL:
https://app.asana.com/0/1206580121312550/1208686409805161/f
Tech Design URL:
https://app.asana.com/0/481882893211075/1208643192597095/f

iOS PR: duckduckgo/iOS#3460
macOS PR: duckduckgo/macos-browser#3422
What kind of version bump will this require?: Major

## Description

Remediate TunnelVision, TunnelCrack and fix "Exclude Local Networks".
diegoreymendez added a commit to duckduckgo/macos-browser that referenced this pull request Nov 11, 2024
@diegoreymendez diegoreymendez merged commit f8fc6c5 into main Nov 11, 2024
13 checks passed
@diegoreymendez diegoreymendez deleted the diego/fix-tunnelvision-2 branch November 11, 2024 21:16
samsymons added a commit that referenced this pull request Nov 12, 2024
# By Daniel Bernal (1) and others
# Via Federico Cappelli (1) and GitHub (1)
* main:
  Remediate TunnelVision, TunnelCrack and fix "Exclude Local Networks" (#3460)
  Sync: Send pixels for account removal + decoding issues (#3557)
  Release 7.145.0-0 (#3560)
  [DuckPlayer] Base Overlay Pixel Implementation (#3545)
  Refresh toast updates (#3552)
  point to BSK branch (#3559)
  Remove ATB from attribution pixel (#3550)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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.

3 participants