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

Fix VPN rekeying #716

Merged
merged 2 commits into from
Mar 12, 2024
Merged

Fix VPN rekeying #716

merged 2 commits into from
Mar 12, 2024

Conversation

diegoreymendez
Copy link
Contributor

@diegoreymendez diegoreymendez commented Mar 12, 2024

Required

Task/Issue URL:

iOS PR: duckduckgo/iOS#2577
macOS PR: duckduckgo/macos-browser#2369
What kind of version bump will this require?: Patch

Description

Fixes the following:

  • Several users seem to be no longer rekeying in the latest releases.
  • Some users seem to have trouble connecting due to these rekeying issues.

Testing

See the platform-specific instructions for testing.

The pixels should show:

23:12:51.370517+0100	584: 0x35f0	com.duckduckgo.mobile.ios.NetworkExtension	default	PacketTunnelProvider	DDG General	Pixel fired m_mac_netp_rekey_attempt_c [:]
23:12:51.370672+0100	584: 0x35f0	com.duckduckgo.mobile.ios.NetworkExtension	default	PacketTunnelProvider	DDG General	Pixel fired m_netp_tunnel_update_attempt_c [:]
23:12:51.883486+0100	584: 0x35f0	com.duckduckgo.mobile.ios.NetworkExtension	default	PacketTunnelProvider	DDG General	Pixel fired m_netp_tunnel_update_success_c [:]
23:12:51.884248+0100	584: 0x35f0	com.duckduckgo.mobile.ios.NetworkExtension	default	PacketTunnelProvider	DDG General	Pixel fired m_netp_rekey_completed_c [:]

Internal references:

Software Engineering Expectations
Technical Design Template

@@ -238,9 +240,7 @@ public actor NetworkProtectionDeviceManager: NetworkProtectionDeviceManagement {
}

handle(clientError: error)

let cachedServer = try cachedServer(registeredWith: keyPair)
Copy link
Contributor Author

@diegoreymendez diegoreymendez Mar 12, 2024

Choose a reason for hiding this comment

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

This will need more cleanup as this code isn't used anymore, but not in this hotfix.

I'm removing this because:

  1. If the auth token is bad this code doesn't help.
  2. This code hides the actual backend issue from pixels.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good find, the try in the cachedServer call does indeed mask the real issue.

@@ -595,7 +595,7 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
serverSelectionMethod: currentServerSelectionMethod,
includedRoutes: includedRoutes ?? [],
excludedRoutes: settings.excludedRanges,
regenerateKey: false)
regenerateKey: 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.

Always use a new key when starting up the tunnel. Why not?

Copy link
Contributor

Choose a reason for hiding this comment

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

One downside here is that it'll make the NetP connection speed overall feel slower since it has to do extra work to get started.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure... after all we're not saving a call to register right now.

// This way we respect the client-set expiration date, unless the server has set an earlier
// expiration for whatever reason (like if the subscription is known to expire).
//
if let newExpiration, newExpiration < keyPair.expirationDate {
Copy link
Contributor Author

@diegoreymendez diegoreymendez Mar 12, 2024

Choose a reason for hiding this comment

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

Comments are self-explanatory, never extend the local expiration, but always shorten it if the server considers that important.

@diegoreymendez diegoreymendez marked this pull request as ready for review March 12, 2024 22:15
@diegoreymendez diegoreymendez self-assigned this Mar 12, 2024
if let existingKeyPair = keyStore.currentKeyPair(),
existingKeyPair.expirationDate > Date().addingTimeInterval(TimeInterval.day) {

keyPair = keyStore.newKeyPair()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the expiration date is over a day from now, we create a new key pair. This is to fix users with long expiration dates... although this could be a good security measure in case users are manipulating expiration dates.

@diegoreymendez diegoreymendez changed the title Makes some changes so that the tunnel will have less issues becoming … Fix VPN rekeying Mar 12, 2024
@diegoreymendez diegoreymendez merged commit 5922425 into release/121.0.0-1 Mar 12, 2024
7 checks passed
@diegoreymendez diegoreymendez deleted the diego/rekeying-fix branch March 12, 2024 22:57
diegoreymendez added a commit to duckduckgo/macos-browser that referenced this pull request Mar 12, 2024
Task/Issue URL:
https://app.asana.com/0/1199230911884351/1206800069675113/f

iOS: duckduckgo/iOS#2577
BSK: duckduckgo/BrowserServicesKit#716

## Description

Fixes the following:
- Several users seem to be no longer rekeying in the latest releases.
- Some users seem to have trouble connecting due to these rekeying
issues.
diegoreymendez added a commit to duckduckgo/iOS that referenced this pull request Mar 12, 2024
Task/Issue URL: https://app.asana.com/0/1199230911884351/1206800069675113/f

macOS: duckduckgo/macos-browser#2369
BSK: duckduckgo/BrowserServicesKit#716

## Description

Fixes the following:
- Several users seem to be no longer rekeying in the latest releases.
- Some users seem to have trouble connecting due to these rekeying issues.
samsymons added a commit that referenced this pull request Mar 14, 2024
* main:
  Revert "Moves AppLaunching out of BSK as it's macOS only"
  Moves AppLaunching out of BSK as it's macOS only
  rollback #URL macro (#718)
  Fix VPN rekeying (#716)
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.

2 participants