Hash: SHA1

             AUSCERT External Security Bulletin Redistribution

                    ESB-2006.0871 -- [Win][UNIX/Linux]
            GnuPG 1.4.5 and 2.0.0 buffer overflow vulnerability
                             29 November 2006


        AusCERT Security Bulletin Summary

Product:              GnuPG 2.0.0 and prior
                      GnuPG 1.4.5 and prior
Operating System:     UNIX variants (UNIX, Linux, OSX)
Impact:               Execute Arbitrary Code/Commands
Access:               Remote/Unauthenticated

- --------------------------BEGIN INCLUDED TEXT--------------------

GnuPG 1.4 and 2.0 buffer overflow


While fixing a bug reported by Hugh Warrington, a buffer overflow has
been identified in all released GnuPG versions. The current versions
1.4.5 and 2.0.0 are affected. A small patch is provided.

Please do not send private mail in response to this message. The
mailing list gnupg-devel is the best place to discuss this problem
(please subscribe first so you don't need moderator approval [1]).


When running GnuPG interactively, special crafted messages may be used
to crash gpg or gpg2. Running gpg in batch mode, as done by all
software using gpg as a backend (e.g. mailers), is not affected by
this bug.

Exploiting this overflow seems to be possible.

gpg-agent, gpgsm, gpgv or other tools from the GnuPG suite are not


Apply the following patch to GnuPG. It should apply cleanly to
current versions (1.4.5 as well as 2.0.0) but might also work for
older versions.

2006-11-27 Werner Koch <wk (at) g10code (dot) com [email concealed]>

* openfile.c (ask_outfile_name): Fixed buffer overflow occurring
if make_printable_string returns a longer string. Fixes bug 728.

- --- g10/openfile.c (revision 4348)
+++ g10/openfile.c (working copy)
@@ -144,8 +144,8 @@

s = _("Enter new filename");

- - n = strlen(s) + namelen + 10;
defname = name && namelen? make_printable_string( name, namelen, 0): NULL;
+ n = strlen(s) + (defname?strlen (defname):0) + 10;
prompt = xmalloc(n);
if( defname )
sprintf(prompt, "%s [%s]: ", s, defname );


The code in question has been introduced on July 1, 1999 and is a
pretty obvious bug. make_printable_string is supposed to replace
possible dangerous characters from a prompt and returns a malloced
string. Thus this string may be longer than the orginal one; the
buffer for the prompt has only be allocated at the size of the original
string - oops. Note, that using snprintf would not have helped in
this case. How I wish C-90 had introduced asprintf or at least it
would be available on more platforms.

The original bug report is at https://bugs.g10code.com/gnupg/issue728 .

[1] See http://lists.gnupg.org/mailman/listinfo/gnupg-devel .

- --
Werner Koch <wk (at) gnupg (dot) org [email concealed]>
The GnuPG Experts http://g10code.com
Join the Fellowship and protect your Freedom! http://www.fsfe.org

- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

NOTE: Third Party Rights
This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content. The decision to follow or act on information or advice
contained in this security bulletin is the responsibility of each user or
organisation, and should be considered in accordance with your organisation's
site policies and procedures. AusCERT takes no responsibility for consequences
which may arise from following or acting on information or advice contained in
this security bulletin.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:


If you believe that your computer system has been compromised or attacked in 
any way, we encourage you to let us know by completing the secure National IT 
Incident Reporting Form at:


Australian Computer Emergency Response Team
The University of Queensland
Qld 4072

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for member emergencies only.

Comment: http://www.auscert.org.au/render.html?it=1967