John is using 2.1.14, but this bug was fixed in 2.1.15.
- Queries
- All Stories
- Search
- Advanced Search
- Transactions
- Transaction Logs
Advanced Search
Nov 29 2016
Oct 13 2016
Oct 12 2016
This is apparently just re-reported on gnupg-users:
https://lists.gnupg.org/pipermail/gnupg-users/2016-October/056892.html
So i don't think it's fixed.
And fwiw, it seems like a clear bug to me if i use "ssh-add" and then it is not
added to the agent.
From the ssh-add's client's perspective, some keys are magically never added,
but others are. This kind of mystery behavior is confusing and frustrating. If
gpg-agent is going to handle the ssh-agent protocol, it should aim toward behave
as the user of the ssh-agent protocol expects, regardless of whether the user
knows that they're using gpg-agent or some other implementation.
Jul 25 2016
Ah, I misunderstood your problem. In the future, please paste all program interactions in one chunk
in the right order. We did merge some changes related to exporting of secret keys, so it may very
well be solved by that.
Thanks for caring :)
Jul 22 2016
I think the problem is that your key export fails, because you pointed
--homedir at the (presumably) empty directory "%tmp%\_tempKeyring".
The export did not use any filter and tried to export a key as can be seen in
Msg8313 "error receiving key from agent"
The import itself also stated no errors as it can be seen in T2355 (dranft on May 12 2016, 03:00 PM / Roundup), but this
imported secret key cannot be used (or exported) anymore.
Also important: This is no longer reproducible in 2.1.14 (which might be enough
to set the bug to fixed)
I don't believe this demonstrates a bug.
I think the problem is that your key export fails, because you pointed --homedir at the (presumably)
empty directory "%tmp%\_tempKeyring". This leads to the not very helpful error message about the
eof. If the export were successful, gpg would have written the key to stdout.
For reference, here is what I tried. First GNUPGHOME points to a home with the key I want to export:
$ echo $GNUPGHOME /tmp/tmp.T7I4M9RIc3 $ g10/gpg --list-keys alpha gpg: please do a --check-trustdb pub dsa1024 1999-03-08 [SCA] A0FF4590BB6122EDEF6E3C542D727CC768697734 uid [ unknown] Alfa Test (demo key) <alfa@example.net> uid [ unknown] Alpha Test (demo key) <alpha@example.net> uid [ unknown] Alice (demo key) sub elg1024 1999-03-08 [E]
You need some kind of pinentry program, because you may be asked for the current passphrase or an
export passphrase:
$ cat $GNUPGHOME/gpg-agent.conf pinentry-program /usr/bin/pinentry-x11
Now export the key:
$ g10/gpg --export-secret-keys alpha >/tmp/alpha.gpg
Now I create an empty home, and import the key in batch mode:
$ export GNUPGHOME=$(mktemp -d) $ g10/gpg --batch --import /tmp/alpha.gpg gpg: keybox '/tmp/tmp.bL2caQmZri/pubring.kbx' created gpg: /tmp/tmp.bL2caQmZri/trustdb.gpg: trustdb created gpg: key 2D727CC768697734: public key "Alfa Test (demo key) <alfa@example.net>" imported gpg: key 2D727CC768697734: secret key imported gpg: Total number processed: 3 gpg: imported: 1 gpg: secret keys read: 3 gpg: secret keys imported: 2
Could you please check if that works for you?
Jul 19 2016
I do consider it a bug, at least because we did not signal an error to ssh-add.
Fortunately, this was easy to fix.
Fixed in 270f7f7b.
Yes, that is very likely the same bug. Feel free to reopen this report if yuo
can still reproduce it, in which case a backtrace would be very handy.
Fixed in 28fd0ab.
Jul 18 2016
Fixed in f4742493.
Jun 9 2016
Sorry for going AWOL on this, Werner. Do you still need a backtrace from me, or is the
one from 2371 enough?
May 30 2016
See bug 2371, which has a backtrace attached.
Duplicate of T2371
May 19 2016
Thanks. I need a stack backtrace to find the location of the cause.
Please start gpg-agent using:
gpg-connect-agent /bye
The figure out the PID of the gpg-agent process and run
gdb /usr/local/bin/gpg-agent PID
At the gdb prompt enter
handle SIGPIPE nostop noprint pass c
The "c" continues operation of gpg-agent. In another terminal run
gpg2 --sign
as done in your example. GDB in the first terminal will eventually
stop due to the assert. Enter at the gdb prompt:
bt
and post the output. I would also like to know which version of
libgpg-error you are using:
gpg-error --version
should show this (or use gpg-error-config --version).
May 12 2016
PS: forget the --homedir thing, it is even reprodicable in the default folder in
%appdata%.
Sorry, forgot my import cmdline:
C:\Program Files (x86)\GNU\GnuPG\2.1.12\bin>gpg --batch --homedir
%tmp%\_tempKeyring --import "P:\2EEC2B65A2B4B3EF.sec.asc"
gpg: Die "Keybox" `C:/Users/ranftd/AppData/Local/Temp/_tempKeyring/pubring.kbx'
wurde erstellt
gpg: C:/Users/ranftd/AppData/Local/Temp/_tempKeyring/trustdb.gpg: trust-db erzeugt
gpg: Schlüssel A2B4B3EF: Öffentlicher Schlüssel "Daniel Ranft (Giegerich &
Partner GmbH)" importiert
gpg: Schlüssel A2B4B3EF: "Daniel Ranft (Giegerich & Partner GmbH)" nicht geändert
gpg: Schlüssel A2B4B3EF: geheimer Schlüssel importiert
gpg: Anzahl insgesamt bearbeiteter Schlüssel: 4
gpg: importiert: 1
gpg: unverändert: 1
gpg: gelesene geheime Schlüssel: 3
gpg: unveränderte geh. Schl.: 2
gpg: keine ultimativ vertrauenswürdigen Schlüssel gefunden
Apr 19 2016
I think I was confused by the fact that I didn't use ssh-add to add the key and
I didn't realize that I could add it manually to sshcontrol. I did that and it
now works as expected. Sorry about the noise.
Although maybe it would be nice to be able to make 'confirm' the default for
keys which are not listed in sshcontrol. But that's a very minor thing.
Apr 15 2016
Apr 14 2016
I would not consider this a bug. sshcontrol is used to enable certain keys for
use with ssh. Updating keys is useless if they are already available.
If you remove the keys from sshcontrol you disable them. I would suggest to put
a '!' in front of the keygrip instead of deleting the line in sshcontrol. This
allows to re-enable a key w/o problems.
Apr 13 2016
The solution is to remove the key in private-keys-v1.d before running ssh-add.
Apr 8 2016
Apr 5 2016
gpg-agent does disable core dumps both in the stable and modern version.
Furthermore I have to agree with Werner here, if there is a process that can
ptrace your gpg-agent, then you have already lost anyway.
Mar 1 2016
Jan 15 2016
Jan 5 2016
I've tested to generate an rsa2048 key with backup on a v2.0 card and it works
now. I have not tested restoring from backup etc. But as this report was about
the failed generation, this issue is resolved imo.
Thanks!
Dec 24 2015
I removed the not-working checkbkupkey subcommand in
44aee35e69540510617aea4b886ef845590960fe
Also fixed the bkuptocard subcommand in: 40959add1ba0efc1f4aa87fa075fa42423eff73c
Dec 18 2015
Dec 17 2015
I'm considering fixing this.
Dec 7 2015
Nov 20 2015
Keep the bug open. We won't fix it for the next release.
werner: What is your call to action? Should pinentry always be shutdown or is
the status quo acceptable? Thanks.
Nov 5 2015
I am pretty sure that there is a race. The two sessions are not mutally locked
and thus the second client may ask for the passprase again.
Pinentry-1 returns to Client-1 task switch Client-2 now checks the cache again, does not see an update, starts Pinentry-2 task switch Client-1 updates the cache
How ever it will be a rare problem and it would at best be annoying.
Nov 4 2015
I tried running:
echo | gpg -s -a
in two terminal. In the first terminal, I got a pinentry prompt (I'm using
pinentry-tty) and in the second, gpg2 appeared to freeze. Once I entered my
passphrase correctly in the first terminal, the first gpg2 process split out the
signed message and less than a second later, the second did as well.
The code also suggests that this is fixed (agent/findkey.c)
/* If the pinentry is currently in use, we wait up to 60 seconds for it to close and check the cache again. This solves a common situation where several requests for unprotecting a key have been made but the user is still entering the passphrase for the first request. Because all requests to agent_askpin are serialized they would then pop up one after the other to request the passphrase - despite that the user has already entered it and is then available in the cache. This implementation is not race free but in the worst case the user has to enter the passphrase only once more. */
Interestingly, this comment is from 2006 (commit: df52700f), which predates this
bug report.
As such, I'm changing this bug's status to needs-eg. Perhaps Werner can shed
some more light on this issue.
Oct 12 2015
Oct 3 2015
Please describe which certifciates you see, which version of GnuPG you are
using, and what error you get when trying to delete a cert.
Sep 28 2015
Sep 24 2015
Are you using an Ed25519 key? There was a regression in 2.1.8 which has
meanwhile be fixed in the repo. See also T2096.
Sep 23 2015
Sep 21 2015
Sep 9 2015
Sep 8 2015
Aug 21 2015
Aug 13 2015
c) Run gpg-agent under gdb
d) Run a modified gpg-agent (rm ~/S.gpg-agent; my-gpg-agent --daemon)
e) Hook into the tty and use pinentry-curses
f) scp ~/.gnupg/private-keys-v1.d/* mybox: and sniff the passphrase.
Aug 12 2015
so far, the proposed mechanisms for getting at gpg-agent's memory from a peer
process running as the same user are:
a) ptrace (e.g. via /usr/bin/gcore or /usr/bin/strace)
b) /proc/$PID/mem, which is owned by the user and mode 0600
DarkStarSword's patch effectively closes (a) (by rejecting ptrace connections)
and appears on my GNU/Linux system to close (b) as well: /proc/$PID/mem is
root-owned when the patch is applied instead of being user-owned.
Are there other channels for per-process memory access that we should be
thinking about?
I agree with Werner and Neal that the UNIX model is probably insufficient to
close all the holes easily, but i also don't think that's a good reason to avoid
closing those holes we can close.
If there are other ways that another process by the same user can get at the
RAM, please point them out and i'll look into ways to address them too.
In the meantime, i'll also look into ways to facilitate running the process as a
separate user account entirely.
I am closing this.
BTW: I can't share DarkStarSword's fear about prioritizing ease of debugging
over security - I would never do that for a real security problem; Neal and me
both explained why this proposed fix does can't help against an attack.
I'm going to introduce the prctl(SET_DUMPABLE, 0) change to main in
agent/gpg-agent.c in the debian 2.1.x series as of 2.1.7-1, using the patch i'm
attaching here.
I make no representations that this solves all possible memory leakages, but it
does address one specific and relatively straightforward attack.
As to Werner's legitimate concerns about making debugging harder, there remain
at least two options: ptrace as the superuser, and launching gpg-agent itself
under gdb directly.
If this experiment proves disastrous somehow (i'm not seeing how), we can always
revert the patch.
Aug 11 2015
Aug 9 2015
Glad I was able to help get one bug fixed at least :)
The in-memory encryption will definitely help in this scenario (that is, a
casual attack by e.g. a colleague or another student having a laugh as their
friend left their screen unlocked... real attack - I should know, I've done it,
and had it done to me, as had several of my friends back in uni (to be fair -
that was on Firefox password manager, but it could just as easily have been
gpg-agent)... This is not about stopping a motivated attacker with physical
access to the system as they could always subvert the system in other ways e.g.
adding a shell alias to run a trojaned gpg-agent instead of the real thing,
install a key logger, etc).
I'm still not super happy that a casual attacker could walk away with a core
file containing the encrypted passphrase and the key to decrypt it. What started
as a casual attack for a laugh could later transform into a more serious attack
given that they can hold onto this information indefinitely. I'm not a motivated
attacker, but that would tempt the hell out of me if I was even slightly so
inclined. I should know, because I've been in a similar situation in the past
where I obtained an unshadowed passwd file (through a purely casual attack when
I was looking up a friend's uid and discovered the passwd file was not
shadowed... so of course I made a copy). I could have left it alone, but it
tempted the hell out of me and I ended up running john over it for two straight
weeks (never did much with the result, but that's not the point)!
I would hope that the developers of any security product learns to think like an
attacker.
I must say I am deeply troubled by the priority seeming to be on the ease of
debugging a security product which has the sole purpose of keeping a passphrase
safe. As the saying goes security is always a trade-off, but given that
gpg-agent is a security product and not a word processor, this particular trade
off does not sit right with me. I would expect the development team to have root
access on their own systems, which avoids the issue as the root user can always
attach a debugger with or without this change - is there truly a reason that
they need to attach to a running gpg-agent on a system they don't have root on?
And what about the thousands of gpg-agents running on other systems in the wild
that should never need to attach a debugger (and if they do... sudo)?
The information about FIPS mode and SELinux is good to know, at least for people
running distributions that support and enable them by default. But from what I
can gather FIPS mode is a RHEL only feature (I may be wrong - I'm not all that
familiar with it), and SELinux is still either not enabled, or in permissive
mode in many distributions by default (including Debian and Ubuntu).
As I mentioned in the original report, an alternative way to protect the memory
of gpg-agent is to install it with the setgid bit set (ssh-agent does both the
prctl() and setgid for example - now there's some developers I applaud). Unlike
SELinux and FIPS mode this works in every distribution and has been supported
for donkeys years.
Aug 7 2015
This identified another bug: To be prepared for FIPS evaluation,
gpg-agent does not store the cached passphrases in the clear but
encrypts them in memory. Right this is security by obscurity but if
we ever have a way to store that key in a secured RAM (e.g. TPM, ARM
TrustZone) we can indeed limit the time a passphrase is available in
the clear to the period it is really needed. This all seems to work
but your tests shows that libassuan does not clear its internal line
buffers so that you can actually find the passphrase in the core
file. I just pushed a fix for this.
IIRC, FIPS mode in Linux inhibits all access to process memory system
wide. Changing this just a for a single user process does not make
much sense.
Further, being able to attach to a running processing is one of the
best debug methods we have. Giving up on this without for a perceived
extra protection is not going to work. There are too many ways to get
the passphrase using other ways. Linux can't protect a user to get
data belonging to him. Iff gpg-agent were a system daemon things
would be different and extra protection would make sense as a
fallback.
Without this I can do gcore pidof gpg-agent and QUITE CLEARLY see my
passphrase in the produced dump:
ian@draal~ [i]> gcore (pidof gpg-agent) 0x00007fb8f8849293 in __select_nocancel () at
../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory. warning: target file /proc/1560/cmdline contained unexpected null characters warning: Memory read failed for corefile section, 8192 bytes at 0x7ffce0a12000. Saved corefile core.1560 0x00007f2dd583c293 in __select_nocancel () at
../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory. warning: target file /proc/1540/cmdline contained unexpected null characters warning: Memory read failed for corefile section, 8192 bytes at 0x7ffccfbe3000. Saved corefile core.1540 ian@draal~ [i]> strings core.1560 | grep pass passwd This is my ultra secure passphrase - I definitely expect any program that
manages this to take reasonable steps to keep it safe even if I accidentally
leave my screen unlocked one day!
Invalid passphrase; please try again You need a passphrase to unlock the secret key for user:%0A"test123
<test@test.com>"%0A2048-bit RSA key, ID DE3A7EAB, created 2015-08-06 (main key
ID F459B571)%0A
SETERROR Invalid passphrase; please try again his is my ultra secure passphrase - IQ ian@draal~ [i]>
With this one line change I cannot do the above - that's the definition of
reducing the attack surface last time I checked.
You absolutely can still use gdb to debug it - you just have to start it under
gdb as opposed to attaching to an existing process, or attach the debugger as
root. You could also just disable the syscall in a debug build.
Aug 6 2015
It does not reduce the attack surface. And yes, it complicates things
because you can't anymore debug the process without changing the code
or using other tricks (aka attack). I have not tested the SELinux
feature for quite some time but gnupg supports SELinux if configured
with --enable-selinux-support. If you want some protection better use
that.
dkg: We disable core dumps for the simple reason that we do not want
to see core files on disk. Disk sectors have a longer lifetime than a
process and a user session - thus avoiding core files is a real world
threat mitigation.
Aug 5 2015
So a single syscall to demonstrably reduce the attack surface really complicates
things does it?
News to me.
I agree with you that the standard UNIX model is generally insufficient here.
Perhaps the distros could weigh in with mechanisms to facilitate
secondary-account creation for agents and the like. I've opened
https://bugs.debian.org/794667 about this.
However, i don't think the weak UNIX permissions model is a reason to avoid a
small piece of code like that offered by DarkStarSword below. Closing off one
avenue of attack is still worthwhile, even if other avenues remain. As werner
said, gpg-agent won't create a coredump (even though other avenues of attack are
possible).
Is there something about the complexity of prctl(PR_SET_DUMPABLE, 0); that makes
it undesirable?
dkg: The problem is that the underlying architecture is broken. Unix's stock
permission model is about protecting users from other users, not protecting
processes from other processes. Thus, I don't think it makes any sense to
complicate the code by implementing these effectively useless protections.
FWIW, a widely used practical system that does a much better job at this is
Android. Android runs every program under its own uid. We could do the same
thing with gpg-agent. In fact, this is currently possible with a little help
from ssh. Unfortunately, this requires a fair amount of work by the user to set
up. In particular, the user needs to create a secondary account. It would be
nice if distributions provided a simply way for an unprivileged user to allocate
additional uids, but this is probably a lot of work.
Aug 4 2015
fwiw, i'd be fine with enabling protection against ptrace for gpg-agent, even if
that doesn't fix all the other ways a process can be attacked from another process.
if there are multiple holes, we should plug the ones we can plug, to increase
the pressure to make the other ones fixable.
Jun 29 2015
Done with commit 9bca96d. Here is how to use it:
$ gpg-connect-agent > passwd --verify 2C1103C5C84AAD061B5E3221C048A93D878F7EEE OK > passwd --verify 2C1103C5C84AAD061B5E3221C048A93D878F7EEE ERR 83886179 Operation cancelled <Pinentry> > passwd --verify 2C1103C5C84AAD061B5E3221C048A93D878F7EEE ERR 67108875 Bad passphrase <GPG Agent>
For the OK I entered the correct passpharse, for the bad passpharse I entered a
bad passphrase three times in a row.
Jun 23 2015
We can already do a dummy signature, but it feels sloppy for several reasons:
- it's not clear exactly what to sign with a dummy signature -- should you sign
static text or a dynamic (random) block?
- it's not clear what to do with the signatures after creation. It's
concievable that a dummy signature could be abused/misused if the material being
signed turns out to have some other meaning.
- gpg-agent can be configured to log to an append-only file as a means of
monitoring what signatures have ever been made by a given key. Dummy signatures
introduce spurious signing events that are indistinguishable from real
signatures in this log
- the creation of arbitrary signatures takes more time than testing passphrase
and returning feedback.
Why not doing a dummy signing then?
Jun 16 2015
Just checked:
/* Reset the pinentry (in case of popup messages). */ agent_reset_query (ctrl);
Thus the pinentry is only closed if it is used as a simple popup winode (e.g.
"Insert card with serial number xxx") but not for a regular Pinentry.