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

IPsec Pre-shared key stored as plain text #188

Open
0791HnoeL opened this issue May 29, 2022 · 7 comments
Open

IPsec Pre-shared key stored as plain text #188

0791HnoeL opened this issue May 29, 2022 · 7 comments
Assignees

Comments

@0791HnoeL
Copy link

Your version 1.20.0 release note says:

Store PSK as a VPN secret, ...

This doesn't work with GNU/Linux distributions like

  • Debian 10.9.0 "Buster" (network-manager-l2tp 1.20.2)
  • Ubuntu 22.04 "Focal Fossa" (network-manager-l2tp 1.20.0)
  • Linux Mint 20.3 "Una" (network-manager-l2tp 1.20.4)

There is a "Store the password only for this user" option for both VPN user password and IPsec settings pre-shared key, but only the user password gets stored in keyring. IPsec PSK could still be found as plain text in network manager configuration file.

@dkosovic dkosovic self-assigned this May 30, 2022
@sh3bang
Copy link

sh3bang commented Jun 30, 2024

same problem here, IPSEC PSK is still stored within configuration file (arch linux, networkmanager-l2tp 1.20.16-1). VPN connection was created with nm-connection-editor 1.36.0-1

@dkosovic dkosovic reopened this Jun 30, 2024
@dkosovic
Copy link
Member

dkosovic commented Jul 3, 2024

@sh3bang

When the "Store the password only for this user" option is selected for either the user password or the PSK, they shouldn't be stored in the corresponding .nmconnection config file.

When the "Store the password for all users" is selected, then NetworkManager stores the user password or the PSK under the [vpn-secrets] section of the .nmconnection config file.

The above Store options are available by clicking on the person/people icon in the right of the password or PSK text boxes.

NetworkManager-l2tp used to to do its own thing and store the PSK under the [vpn] section of the .nmconnection config file, newer versions let NetworkManager do the handling of the PSK the same way as the user password is handled.

NetworkManager does the same thing with WiFi passwords and "Store the password for all users" option.

Are you using the "Store the password only for this user" option? If you are, its definitely a bug, unfortunately I'm not able to reproduce it on the Linux distros I've just tested with, but didn't test with Arch Linux.

@sh3bang
Copy link

sh3bang commented Jul 4, 2024

@dkosovic
I have double checked that case (Linux Mint and Manjaro Linux):

"Store the password for all users" is unckecked and "Store the password only for this user" is checked (Option next to the PSK input field). The PSK is still stored in vpn-secret section of /etc/NetworkManager/system-connections/.nmconnection

Only the user password will saved to users keyring.

PS: PSK of WiFi will saved to gnome keyring, no problems!

@dkosovic
Copy link
Member

@sh3bang

I updated my Arch Linux VM to the latest and wasn't able to reproduce the issue. I suspect we are using different secret service agents (e.g. KeypassXC, KSecretsService , GNOME Keyring, etc) so might be seeing different behaviours especially when ipsec-psk-flags=0 isn't getting recorded under the [vpn] section when "Store the password only for this user" is selected, (ipsec-psk-flags=1 is correctly getting recorded when "Store the password for all users" is selected).

So, I think fixing the code so that ipsec-psk-flags=0 gets recorded in the [vpn] section, i.e. the vpn.data field is a good starting point to fix the issue. So, at least it'll be consistent with password-flags=0 which is getting recorded.

I wasn't the author of the code that migrated ipsec-psk from the [vpn] section to the [vpn-secrets] section:

But was responsible for the commit that originally closed this issue and had the following code :

if (pw_flags != NM_SETTING_SECRET_FLAG_NONE) {
    g_hash_table_insert(hash,
                        g_strdup(NM_L2TP_KEY_IPSEC_PSK "-flags"),
                        g_strdup_printf("%d", pw_flags));
}

I suspect there shouldn't be a if (pw_flags != NM_SETTING_SECRET_FLAG_NONE) { conditional so that ipsec-psk-flags is always getting recorded in the [vpn] section.

I just want to do a bit more testing before comiting the code.

@sh3bang
Copy link

sh3bang commented Jul 11, 2024

@sh3bang i have double checked again (Linux Mint and Manjaro Linux).

On Manjaro the PSK can suddenly stored correctly in gnome-keyring and removed from .nmconnection config file (while ipsec-psk-flags=1 is added to .nmconnection config file) when choosing option to save PSK just for the current user. But i did nothing! (installed package nm-connection-editor 1.36.0-1; maybe updated!?)

On Linux-Mint nothing changed, PSK will resist in config file (installed package network-manager-gnome 1.24.0+mint2+vanessa). Flag ipsec-psk-flags will always removed from config file

@dkosovic
Copy link
Member

Ahh, that behavior is starting to make more sense to me.

nm-connection-editor and nm-applet use the GTK3 plug-in from this repository. Newer GNOME Control Center versions use the GTK4 plug-in from this repository. Both the GTK3 and GTK4 L2TP plug-ins know about the ipsec-psk-flags option. I'm using GNOME Desktop which uses GNOME Control Center.

Other L2TP plug-ins from elsewhere like the Qt plug-in from plasma-nm don't know about ipsec-psk-flags, so any unknown options get dropped from the config file as soon as you try to establish a VPN connection.

Sorry I have no idea which L2TP plug-in the Linux Mint Cinamon Control Center uses. I would think either the GTK3 or GTK4 plug-in.

I'm also not sure if Linux Mint is like Ubuntu 24.04 which switched to Netplan, NetworkManager connection profiles are now Netplan YAML. But that shouldn't matter.

@dkosovic
Copy link
Member

dkosovic commented Jul 14, 2024

Recently posted #229 is similar to the latter issue of this one, i.e. if nm-cli or nm-connection-editor are used to edit the L2TP connection, options will get dropped if the Desktop Environment isn't using the GTK3 or GTK4 L2TP GUI plugin from this repository to establish the L2TP VPN connection.

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