Dear Maintainer,
when configuring this encrypted machine running debian stable with keyscript
"decryt_keyctl", the invocation of "cryptdisks_start data{0,1}_crypt" when
logged in via ssh as normal user and "sudo -i" to root fails with the message:
| [....] Starting crypto disk...data0_crypt (starting)...Caching passphrase for data0_crypt: *********************
| keyctl_set_timeout: Permission denied
| Error setting timeout on key (824927206), removing
| Nothing to read on input.
| Caching passphrase for data0_crypt:
After some searching, I found a link to bug #758788, especially message #45 and #50 [1], which
described seemingly the same bug:
| > On the first invocation (for cont1_crypt), I got this dialog:
| >
| > root@marislae:~# cryptdisks_start cont1_crypt
| > [[....] Starting crypto disk...[info] cont1_crypt (starting)...
| > Caching passphrase for /cont1: ******
| > keyctl_set_timeout: Permission denied
| > Error setting timeout on key (2524288), removing
| > Caching passphrase for /cont1: ******
| > keyctl_set_timeout: Permission denied
| > Error setting timeout on key (612589418), removing
| >
| > [Here I pressed <ctrl-C> to stop the attempts]
| >
| > Caching passphrase for /cont1: Erreur de lecture de la phrase secrète.
| >
| >
| > I was running the commands from root. I initially logged in to the
| > computer from SSH to a regular user, than did "sudo -i" to get root
| > access if this matters. As I suspected this may be a problem, I allowed
| > root direct SSH access and tried again, login directly to root account,
| > this time it worked:
|
| Interesting, never saw these kind of problems before. I'm testing on a
| Laptop with Ubuntu 14.04 installed and use 'sudo -i' a lot. Indeed I
| used it for testing the commands above as well. For me it worked. But
| let's keep that aside. It's another issue and out of scope for this
| bugreport ;)
But I haven't found another link to that aspect of that bug; the mentioned
bug was closed without looking at that facette further.
Another link I stumbled upon was one of Matthew Gerret describing a workaround
with the kernel keyring and sudo [2].
I adapted a copy of decrypt_keyctl to his suggestions and afterwards I could
decrypt the multiple cryptdisks. Here is the patch:
--- 8< --- 8< --- 8< ---
--- decrypt_keyctl 2019-06-10 14:51:15.000000000 +0200
+++ decrypt_keyctl_debug 2019-09-03 23:33:51.311240116 +0200
@@ -43,8 +43,13 @@
keyctl unlink "$KID_" @u
KID_=""
fi
- KID_="$(printf "%s" "$KEY_" | keyctl padd user "$ID_" @u)"
+ KID_="$(printf "%s" "$KEY_" | keyctl padd user "$ID_" @s)"
[ -n "$KID_" ] || die "Error adding passphrase to kernel keyring"
+ if ! ( keyctl setperm "$KID_" 0x3f3f0000 && keyctl link "$KID_" @u && keyctl unlink "$KID_" @s ); then
+ keyctl unlink "$KID_" @u
+ keyctl unlink "$KID_" @s
+ die "Error transferring permissions on key ($KID_), removing"
+ fi
if ! keyctl timeout "$KID_" "$TIMEOUT_"; then
keyctl unlink "$KID_" @u
die "Error setting timeout on key ($KID_), removing"
--- 8< --- 8< --- 8< ---
I don't know whether there are further security implications or something like that,
nor did I do extensive testing. The error handling was also added in a quick way
without testing it further (I also don't know how to provoke that error). I just
wanted to let you know that and how I fixed a problem not only I had.
Regards
Sebastian
[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758788#50
[2]: https://mjg59.dreamwidth.org/37333.html
Hi Sebastian,
Thanks for the detailed report! I was able to reproduce this in a fresh
Buster netinstall, taking SSH sessions and sudo(8)'s ‘-i’ flag out of
the picture. This is what I get right after a reboot:
user@kvm-31992:~$ sudo keyctl show @u
Keyring
99804791 --alswrv 0 65534 keyring: _uid.0
user@kvm-31992:~$ sudo keyctl show @s
Keyring
1021507217 --alswrv 1000 1000 keyring: _ses
872133423 ---lswrv 1000 65534 \_ keyring: _uid.1000
user@kvm-31992:~$ sudo keyctl show @us
Keyring
133933438 --alswrv 0 65534 keyring: _uid_ses.0
99804791 --alswrv 0 65534 \_ keyring: _uid.0
Keys attached to root's user-keyring(7) can't be read.
user@kvm-31992:~$ sudo keyctl add user "foo" "bar" @u
875128385
user@kvm-31992:~$ sudo keyctl show @us
Keyring
133933438 --alswrv 0 65534 keyring: _uid_ses.0
99804791 --alswrv 0 65534 \_ keyring: _uid.0
875128385 --alswrv 0 0 \_ user: foo
user@kvm-31992:~$ sudo keyctl print 875128385
keyctl_read_alloc: Permission denied
So LUKS2 volumes can't be open using token keyrings:
user@kvm-31992:~$ sudo dd if=/dev/zero of=/tmp/disk.img bs=1M count=64 status=none
user@kvm-31992:~$ sudo cryptsetup luksFormat -q \
--pbkdf-force-iterations 4 --pbkdf-memory 32 /tmp/disk.img <<<bar
user@kvm-31992:~$ sudo cryptsetup token add --key-description foo -S 0 /tmp/disk.img
user@kvm-31992:~$ sudo cryptsetup luksOpen --test-passphrase --debug \
--token-only /tmp/disk.img
[…]
# keyring_get_passphrase failed (error -126)
# Token 0 (luks2-keyring) open failed with -22.
And indeed decrypt_keyctl chokes as well:
user@kvm-31992:~$ sudo CRYPTTAB_NAME=foo CRYPTTAB_KEY=bar CRYPTTAB_TRIED=0 \
/lib/cryptsetup/scripts/decrypt_keyctl
Caching passphrase for foo: ***
keyctl_set_timeout: Permission denied
Error setting timeout on key (163348240), removing
AFAICT this is because the caller doesn't possess %user:foo, cf.
https://manpages.debian.org/buster/manpages/keyrings.7.en.html#Possession
A workaround is to do these operations in a new session-keyring(7), and
link root's user-keyring(7) to it.
user@kvm-31992:~$ sudo keyctl session
Joined session keyring: 777897511
root@kvm-31992:/home/user# keyctl link @u @s
root@kvm-31992:/home/user# keyctl show
Session Keyring
777897511 --alswrv 0 0 keyring: _ses
99804791 --alswrv 0 65534 \_ keyring: _uid.0
875128385 --alswrv 0 0 \_ user: foo
root@kvm-31992:/home/user# keyctl print 875128385
bar
root@kvm-31992:/home/user# cryptsetup luksOpen --test-passphrase -v \
--token-only /tmp/disk.img
Key slot 0 unlocked.
Command successful.
root@kvm-31992:/home/user# CRYPTTAB_NAME=foo CRYPTTAB_KEY=bar CRYPTTAB_TRIED=0 \
/lib/cryptsetup/scripts/decrypt_keyctl >/dev/null
Caching passphrase for foo: ***
root@kvm-31992:/home/user# exit
I suppose /etc/pam.d/sudo could use pam_keyinit(8) to initialize a new
session instead of doing the above dance. Anyway cryptsetup calls
request_key("user",,NULL,0) at the moment, so unlocking LUKS2 devices
via keyring tokens will only works in sessions where the user-keyring(7)
is linked to the session-keyring(7).
AFAICT blindly using session-keyring(7) as it might open a window during
which any program in the user session is able to read the payload:
user@kvm-31992:~$ sudo keyctl add user "foo" "foo" @s
137160032
user@kvm-31992:~$ keyctl show @s
Keyring
461059914 --alswrv 1000 1000 keyring: _ses
641525861 --alswrv 1000 65534 \_ keyring: _uid.1000
137160032 --alswrv 0 0 \_ user: foo
user@kvm-31992:~$ keyctl print 137160032
foo
(While the key is owned by the privileged user, it's possessed by the
caller. It might even be possible to poison the session-keyring(7)
by creating %user:foo with non-root ownership.) I think the best place
to solve that is in /etc/pam.d/sudo itself, but failing that I suppose
it's acceptable to have the payload readable by root (perhaps only as
fallback, when the caller doesn't have enough right on the key it's
adding).
Perhaps keyctl(1) could provide a wrapper using thread-keyring(7) as
temporary keyring, like the attached PoC. Or we could even rewrite
decrypt_keyctl in C, or merge it with askpass. In fact one of our goals
for this release cycle is to better integrate crypttab(5) with LUKS2
native keyring support, and that probably goes via adding keyring
support in askpass.
Cheers,
Control: reassign -1 sudo 1.8.27-1 Control: affects -1 cryptsetup Control: merge -1 906752 Of course I forgot the attachment :-P That said I'm not sure that using a temporary keyring and changing ownership is the way to go, it adds complexity and not having a reachable user-keyring(7) might cause other problems. I was about to reassign that to sudo but noticed there is already a bug open: https://bugs.debian.org/906752
Hello, Bug #939357 in sudo reported by you has been fixed in the Git repository and is awaiting an upload. You can see the commit message below and you can check the diff of the fix at: https://salsa.debian.org/sudo-team/sudo/-/commit/27364e6eda92d3a55d7a11a9ba93ac088c243614 ------------------------------------------------------------------------ add pam_keyinit to pam.d snippets None of the big distribtions seems to know why this is a good idea, but they all do it, and our users have demanded it. Our change is synchronous to what Red Hat does, and it is also the same configuration for other Debian packages like runuser. su does not have the "pam_keyinit.so revoke" thing in pam.d/su, but it has "pam_keyinit.so force revoke" in pam.d/su-l Closes: #906752, #939357 Thanks: Simon Ruggier <simon80@gmail.com>, Sebastian Mohr <sebi@debian.sebi.name>, Guilhem Moulin <guilhem@debian.org> ------------------------------------------------------------------------ (this message was generated automatically) -- Greetings https://bugs.debian.org/939357
We believe that the bug you reported is fixed in the latest version of
sudo, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 906752@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Marc Haber <mh+debian-packages@zugschlus.de> (supplier of updated sudo package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Tue, 27 Oct 2026 06:39:22 +0100
Source: sudo
Architecture: source
Version: 1.9.17p2-9exp2
Distribution: experimental
Urgency: medium
Maintainer: Debian Sudo Maintainers <sudo@packages.debian.org>
Changed-By: Marc Haber <mh+debian-packages@zugschlus.de>
Closes: 906752 939357
Changes:
sudo (1.9.17p2-9exp2) experimental; urgency=medium
.
* add pam_keyinit to pam.d snippets.
Thanks to Simon Ruggier <simon80@gmail.com>, Sebastian Mohr <sebi@debian.sebi.name>, Guilhem Moulin <guilhem@debian.org>
(Closes: #906752, #939357)
Checksums-Sha1:
3ab59577100c4e682ca415eedc0b7dcb23b7e77e 1980 sudo_1.9.17p2-9exp2.dsc
a8a2b088b164e314551faf36f9bbba19a0d511d6 53640 sudo_1.9.17p2-9exp2.debian.tar.xz
b09ba0b981e4de93f47147ae973566a7198f7cb8 5211 sudo_1.9.17p2-9exp2_source.buildinfo
Checksums-Sha256:
c4ef3667fe2b5513459106238f9b5cc958fc6fbcd96263a7dbd94d87b63f5b19 1980 sudo_1.9.17p2-9exp2.dsc
75f4ccc63f553064dc86b1cba31d547278f77e9a98c13dd5082a76624d5751f4 53640 sudo_1.9.17p2-9exp2.debian.tar.xz
85ffc67c4b37d225748b9669eecfa26d73a4ac8d06f834301119a643d7d7cd22 5211 sudo_1.9.17p2-9exp2_source.buildinfo
Files:
d50976af5d5776fe6b1900a4e01f01ae 1980 admin optional sudo_1.9.17p2-9exp2.dsc
ea47078e6d9a1ad6108e4faf7b68184e 53640 admin optional sudo_1.9.17p2-9exp2.debian.tar.xz
f41ea61f785d4ea6eb9650b2cd4f1a8a 5211 admin optional sudo_1.9.17p2-9exp2_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iJYEARYKAD4WIQRoUtdjQYCq5giMg+rVTTAMN2ORyQUCauA5xSAcbWgrZGViaWFu
LXBhY2thZ2VzQHp1Z3NjaGx1cy5kZQAKCRDVTTAMN2ORycNeAP4h5yMYphPaTu6z
CPfnTzIqzE5UlJUDkMpShbBYiBYpWQEA1NlzDQG4zDO5BDQLJoRbI9y0T2FKYjFi
TkKmBgoi5wI=
=CbUo
-----END PGP SIGNATURE-----
We believe that the bug you reported is fixed in the latest version of
sudo, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 939357@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Marc Haber <mh+debian-packages@zugschlus.de> (supplier of updated sudo package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Tue, 27 Oct 2026 06:39:22 +0100
Source: sudo
Architecture: source
Version: 1.9.17p2-9exp2
Distribution: experimental
Urgency: medium
Maintainer: Debian Sudo Maintainers <sudo@packages.debian.org>
Changed-By: Marc Haber <mh+debian-packages@zugschlus.de>
Closes: 906752 939357
Changes:
sudo (1.9.17p2-9exp2) experimental; urgency=medium
.
* add pam_keyinit to pam.d snippets.
Thanks to Simon Ruggier <simon80@gmail.com>, Sebastian Mohr <sebi@debian.sebi.name>, Guilhem Moulin <guilhem@debian.org>
(Closes: #906752, #939357)
Checksums-Sha1:
3ab59577100c4e682ca415eedc0b7dcb23b7e77e 1980 sudo_1.9.17p2-9exp2.dsc
a8a2b088b164e314551faf36f9bbba19a0d511d6 53640 sudo_1.9.17p2-9exp2.debian.tar.xz
b09ba0b981e4de93f47147ae973566a7198f7cb8 5211 sudo_1.9.17p2-9exp2_source.buildinfo
Checksums-Sha256:
c4ef3667fe2b5513459106238f9b5cc958fc6fbcd96263a7dbd94d87b63f5b19 1980 sudo_1.9.17p2-9exp2.dsc
75f4ccc63f553064dc86b1cba31d547278f77e9a98c13dd5082a76624d5751f4 53640 sudo_1.9.17p2-9exp2.debian.tar.xz
85ffc67c4b37d225748b9669eecfa26d73a4ac8d06f834301119a643d7d7cd22 5211 sudo_1.9.17p2-9exp2_source.buildinfo
Files:
d50976af5d5776fe6b1900a4e01f01ae 1980 admin optional sudo_1.9.17p2-9exp2.dsc
ea47078e6d9a1ad6108e4faf7b68184e 53640 admin optional sudo_1.9.17p2-9exp2.debian.tar.xz
f41ea61f785d4ea6eb9650b2cd4f1a8a 5211 admin optional sudo_1.9.17p2-9exp2_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iJYEARYKAD4WIQRoUtdjQYCq5giMg+rVTTAMN2ORyQUCauA5xSAcbWgrZGViaWFu
LXBhY2thZ2VzQHp1Z3NjaGx1cy5kZQAKCRDVTTAMN2ORycNeAP4h5yMYphPaTu6z
CPfnTzIqzE5UlJUDkMpShbBYiBYpWQEA1NlzDQG4zDO5BDQLJoRbI9y0T2FKYjFi
TkKmBgoi5wI=
=CbUo
-----END PGP SIGNATURE-----
We believe that the bug you reported is fixed in the latest version of
sudo, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 906752@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Marc Haber <mh+debian-packages@zugschlus.de> (supplier of updated sudo package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 04 Nov 2026 17:37:02 +0100
Source: sudo
Architecture: source
Version: 1.9.17p2-11
Distribution: unstable
Urgency: medium
Maintainer: Debian Sudo Maintainers <sudo@packages.debian.org>
Changed-By: Marc Haber <mh+debian-packages@zugschlus.de>
Closes: 906752 939357 1147179
Changes:
sudo (1.9.17p2-11) unstable; urgency=medium
.
* really upload to unstable
.
sudo (1.9.17p2-10) experimental; urgency=medium
.
* upload to unstable
.
sudo (1.9.17p2-9exp2) experimental; urgency=medium
.
* add pam_keyinit to pam.d snippets.
Thanks to Simon Ruggier <simon80@gmail.com>, Sebastian Mohr <sebi@debian.sebi.name>, Guilhem Moulin <guilhem@debian.org>
(Closes: #906752, #939357)
.
sudo (1.9.17p2-9exp1) experimental; urgency=medium
.
[ Mike Gabriel ]
* d/control: B-D on Dh-nss (>= 1.8~)
* d/sudo.nss: Authoritatively manage sudoers: entry in nsswitch.conf.
(Closes: #1147179)
Checksums-Sha1:
a5f319cb5eeb5139d4a91c000d6d3b766426ce45 1968 sudo_1.9.17p2-11.dsc
c691decc459a617b9939f316238d7137c3f38840 53692 sudo_1.9.17p2-11.debian.tar.xz
d85fb93eaddb10130bdb6175dd134e684f021a8d 5225 sudo_1.9.17p2-11_source.buildinfo
Checksums-Sha256:
147a4b3e8528a90233efc30c2a2758900a8dfa1939b0e29a06ad3eb18ce3e444 1968 sudo_1.9.17p2-11.dsc
c22fa6e7b17511ff57f2d995eeb3f9bdfd3358aba0b457c3d82a692d84e9d70b 53692 sudo_1.9.17p2-11.debian.tar.xz
f2f5e1b865965aea484f541afc82ba43a632d74cbbcb069c4a8143f305dbee9c 5225 sudo_1.9.17p2-11_source.buildinfo
Files:
a703d53bae38ac9b437f90b3e6cf7e98 1968 admin optional sudo_1.9.17p2-11.dsc
06a66db53f05e51e5896728bc60a23a2 53692 admin optional sudo_1.9.17p2-11.debian.tar.xz
cc2204fda1a7a09ecdf80879b8206122 5225 admin optional sudo_1.9.17p2-11_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iJYEARYKAD4WIQRoUtdjQYCq5giMg+rVTTAMN2ORyQUCauto7SAcbWgrZGViaWFu
LXBhY2thZ2VzQHp1Z3NjaGx1cy5kZQAKCRDVTTAMN2ORyWGDAQCGwOqHvpEVrCBa
uEjvp4Db6zks8Z+1ilLuCUH6asm3YAD/X3PNmzq9o9YmZo47p3RThzedY7f6otCt
HXXfN5qdaQ8=
=fGrV
-----END PGP SIGNATURE-----
We believe that the bug you reported is fixed in the latest version of
sudo, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 939357@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Marc Haber <mh+debian-packages@zugschlus.de> (supplier of updated sudo package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 04 Nov 2026 17:37:02 +0100
Source: sudo
Architecture: source
Version: 1.9.17p2-11
Distribution: unstable
Urgency: medium
Maintainer: Debian Sudo Maintainers <sudo@packages.debian.org>
Changed-By: Marc Haber <mh+debian-packages@zugschlus.de>
Closes: 906752 939357 1147179
Changes:
sudo (1.9.17p2-11) unstable; urgency=medium
.
* really upload to unstable
.
sudo (1.9.17p2-10) experimental; urgency=medium
.
* upload to unstable
.
sudo (1.9.17p2-9exp2) experimental; urgency=medium
.
* add pam_keyinit to pam.d snippets.
Thanks to Simon Ruggier <simon80@gmail.com>, Sebastian Mohr <sebi@debian.sebi.name>, Guilhem Moulin <guilhem@debian.org>
(Closes: #906752, #939357)
.
sudo (1.9.17p2-9exp1) experimental; urgency=medium
.
[ Mike Gabriel ]
* d/control: B-D on Dh-nss (>= 1.8~)
* d/sudo.nss: Authoritatively manage sudoers: entry in nsswitch.conf.
(Closes: #1147179)
Checksums-Sha1:
a5f319cb5eeb5139d4a91c000d6d3b766426ce45 1968 sudo_1.9.17p2-11.dsc
c691decc459a617b9939f316238d7137c3f38840 53692 sudo_1.9.17p2-11.debian.tar.xz
d85fb93eaddb10130bdb6175dd134e684f021a8d 5225 sudo_1.9.17p2-11_source.buildinfo
Checksums-Sha256:
147a4b3e8528a90233efc30c2a2758900a8dfa1939b0e29a06ad3eb18ce3e444 1968 sudo_1.9.17p2-11.dsc
c22fa6e7b17511ff57f2d995eeb3f9bdfd3358aba0b457c3d82a692d84e9d70b 53692 sudo_1.9.17p2-11.debian.tar.xz
f2f5e1b865965aea484f541afc82ba43a632d74cbbcb069c4a8143f305dbee9c 5225 sudo_1.9.17p2-11_source.buildinfo
Files:
a703d53bae38ac9b437f90b3e6cf7e98 1968 admin optional sudo_1.9.17p2-11.dsc
06a66db53f05e51e5896728bc60a23a2 53692 admin optional sudo_1.9.17p2-11.debian.tar.xz
cc2204fda1a7a09ecdf80879b8206122 5225 admin optional sudo_1.9.17p2-11_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iJYEARYKAD4WIQRoUtdjQYCq5giMg+rVTTAMN2ORyQUCauto7SAcbWgrZGViaWFu
LXBhY2thZ2VzQHp1Z3NjaGx1cy5kZQAKCRDVTTAMN2ORyWGDAQCGwOqHvpEVrCBa
uEjvp4Db6zks8Z+1ilLuCUH6asm3YAD/X3PNmzq9o9YmZo47p3RThzedY7f6otCt
HXXfN5qdaQ8=
=fGrV
-----END PGP SIGNATURE-----