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

Connections fails if using tls-auth, tls-crypt, and tls-crypt-v2 and server has a IPv6 privacy (RFC 4941) address #304

Closed
Caligatio opened this issue Apr 2, 2023 · 5 comments

Comments

@Caligatio
Copy link

Caligatio commented Apr 2, 2023

Describe the bug
IPv6 clients cannot connect to a IPv6 server using tls-auth, tls-crypt, or tls-crypt-v2 if the server has a IPv6 privacy (RFC 4941) address present/allocated; even if the client is connecting to the "base" address. Here is the log snippet if the server has a IPv6 privacy address (client address is slightly redacted):

Apr  2 11:48:30 vpn ovpn-sitename[1451]: Control Channel: using tls-crypt-v2 key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:30 vpn ovpn-sitename[1451]: Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face tls-crypt-v2 server key: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face tls-crypt-v2 server key: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face TLS: Initial packet from [AF_INET6]2001:db8:215:5489:fa07:d3e1:dead:face:48742, sid=25ae1488 29fcbd6e
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Control Channel: using tls-crypt-v2 key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:30 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Control Channel: using tls-crypt-v2 key
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face tls-crypt unwrap error: bad packet ID (may be a replay): [ #1 / time = (1680436110) 2023-04-02 11:48:30 ] -- see the man page entry for --no-replay and --replay-window for more info or silence this warning with --mute-replay-warnings
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face tls-crypt unwrap error: packet replay
Apr  2 11:48:31 vpn ovpn-sitename[1451]: 2001:db8:215:5489:fa07:d3e1:dead:face TLS Error: tls-crypt unwrapping failed from [AF_INET6]2001:db8:215:5489:fa07:d3e1:dead:face:48742

After a significant number of failures, it eventually tries IPv4 and is successful.

Here is the log if I disable the IPv6 privacy address on the server (DNS is the same, nothing else changes, etc) which is successful:

Apr  2 11:53:15 vpn ovpn-sitename[1601]: Control Channel: using tls-crypt-v2 key
Apr  2 11:53:15 vpn ovpn-sitename[1601]: Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:15 vpn ovpn-sitename[1601]: Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:15 vpn ovpn-sitename[1601]: Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:15 vpn ovpn-sitename[1601]: Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:15 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:15 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:15 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:15 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:15 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face tls-crypt-v2 server key: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:15 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face tls-crypt-v2 server key: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face TLS: Initial packet from [AF_INET6]2001:db8:215:5489:fa07:d3e1:dead:face:42230, sid=c02ee07c 5571116e
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Control Channel: using tls-crypt-v2 key
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face VERIFY OK: depth=1, CN=REDACTED CA
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face VERIFY OK: depth=0, CN=REDACTED Client
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_VER=3.git::d3f8b18b:Release
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_PLAT=android
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_NCP=2
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_TCPNL=1
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_PROTO=30
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_CIPHERS=AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305:AES-256-CBC
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_LZO_STUB=1
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_COMP_STUB=1
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_COMP_STUBv2=1
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_AUTO_SESS=1
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_GUI_VER=net.openvpn.connect.android_3.3.1-9079
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face peer info: IV_SSO=webauth,openurl
Apr  2 11:53:16 vpn ovpn-sitename[1601]: 2001:db8:215:5489:fa07:d3e1:dead:face Control Channel: TLSv1.3, cipher TLSv1.3 TLS_AES_256_GCM_SHA384, peer certificate: 4096 bit RSA, signature: RSA-SHA512

To Reproduce

  1. Host OpenVPN on an IPv6 server that has a IPv6 privacy (RFC 4941) address which uses tls-auth, tls-crypt, or tls-crypt-v2
  2. Attempt to connect to the server over IPv6 to the base (non-privacy) address
  3. FAILURE
  4. Disable the IPv6 privacy address and restart OpenVPN
  5. Attempt to connect to the server over IPv6 to same address as before
  6. SUCCESS

Expected behavior
Connection to be successful

Version information (please complete the following information):

  • Server OS: Ubuntu 22.04.2 (this also failed on 20.04.6)
  • Server OpenVPN version: 2.5.5 (also failed on 2.4.7)
  • Client OS: Android 13
  • Client OpenVPN version: OpenVPN Connect 3.3.1

Additional context
This post tipped me off: https://forums.openvpn.net/viewtopic.php?t=35101

@schwabe
Copy link
Contributor

schwabe commented Apr 3, 2023

Please provide also client logs and logs. You probably need the multihome option on the server or float on the client since the server will otherwise reply with whatever operating system thinks is appropiate and not with the same address.

@Caligatio
Copy link
Author

I can confirm that multihome fixes the problem! Given that privacy addresses are widely recommended, I feel like this potentially needs a better solution as machines can get many IPv6 addresses.

I already posted the server logs, it's literally those few lines repeated infinite times.

The client log just says:

Connecting to [hostname]:1194 (IPv6 address) via UDPv6
Server poll timeout, trying next remote entry...

@cron2
Copy link
Contributor

cron2 commented Apr 4, 2023 via email

@Caligatio
Copy link
Author

Fair enough, thank you for the pointer to multihome!

I am not a expert in IPv6 by any means but I believe that Windows since XP SP1, macOS since (Mac OS X) 10.7, Android since 4.0, and iOS since version 4.3 all use privacy addresses by default (per Wikipedia). It may be less common on servers but it's definitely prevalent on the client side.

@cron2
Copy link
Contributor

cron2 commented Apr 4, 2023 via email

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

No branches or pull requests

3 participants