Here is a snippet from a report we received on 2026-05-26
we got a report from AISLE about potential use after free in gpg keygen,
while processing the keyserver attribute, when generating multiple keys in
batch mode.This is caused by the ownership mismatch of the opt.def_keyserver_url.
which is not copied from the first block context, but reused in the second
block.I do not think this is practically exploitable as it would require users to
process "malicious" batch files, but I still think its worth fixing at your
own timeline.
Reproducer:
cat > params.txt <<'EOF'
Key-Type: RSA
Subkey-Type: RSA
Name-Real: UAF One
Name-Email: one@example.org
Expire-Date: 0
Keyserver: hkps://keys.openpgp.org
%no-protection
%commitKey-Type: RSA
Subkey-Type: RSA
Name-Real: UAF Two
Name-Email: two@example.org
Expire-Date: 0
%no-protection
%commit
'EOF'
valgrind gpg --batch --generate-key params.txt
Reported by: Jakub Jelen, Found by AISLE in partnership with Red Hat