[Swan-announce] CVE-2013-2052: Libreswan remote buffer overflow in atodn()

The Libreswan Project team at libreswan.org
Tue May 14 01:25:49 EEST 2013

Hash: SHA256

Release date: Mon May 13, 2013

Subject: CVE-2013-2052 Libreswan remote buffer overflow in atodn()
URL: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2013-2052

This alert (and any possible updates) is available at the following URLs:

See also: Openswan atodn() CVE-2013-2053, Strongswan atodn() CVE-2013-2054

An audit of code from The Libreswan Project revealed a remote buffer overflow
in the atodn() function used by both libreswan, openswan, and older versions
of strongswan and superfreeswan when called from atoid()

Vulnerable versions: libreswan 3.0 and 3.1
Not vulnerable     : libreswan 3.2 and 3.3

Vulnerability information
- -------------------------

When enabling Opportunistic Encryption ("OE") using oe=yes (default is
'no') the IKE daemon pluto requests DNS TXT records to obtain public
RSA keys of itself and its peers. These records can contain an IPsec
gateway specification containing an fully qualified hostname which is
passed to a function atoid().

When X.509 support was added to FreeS/WAN, ASN.1 parsing was added to
the function atoid() which converts an ASCII ID representation into an
internal struct id representation using a static buffer via the function

While DNS TXT records cannot contain ASN.1 representations, the code
mistakenly checked for such interpretation if the DNS TXT FQDN contained
an '=' symbol. Since DNS TXT buffers can be larger than what the ASN.1
parsing code expected, parsing such a record can trigger a buffer overflow
leading to remote execution of code, specifically when overflowing into
the struct kernel_ops which is a table of function pointers.

- ------------

This exploit can only be triggered when the ipsec.conf configuration
file enables Opportunistic Encryption via the option 'oe=yes'. If this
option is not present, it defaults to 'no'.

Configurations that enable "OE" without preconfiguring their own public
RSA key in DNS will be under severe connectivity problems leaving the
machine with 30 second delay for each outgoing connection - a deployment
scenario that is extremely unlikely to appear in the wild.

In the unlikely event that machines are configured as such, this
vulnerability can only be exploited by a local attacker controlling
the reverse DNS entry for the IP address of the targetted host. If the
machine is properly configured for OE, an attacker only needs to trigger
a connection to an IP address for which they control the reverse DNS
zone where they can place the malicious DNS record.

- ----------

If you cannot upgrade to libreswan version 3.2 or 3.3, the following patch
addresses the vulnerability:


Alternatively, the following patch can be used to permanently disable the
oe=yes option:

diff --git a/lib/libipsecconf/keywords.c b/lib/libipsecconf/keywords.c
index b69d5e1..d7ca5a5 100644
- --- a/lib/libipsecconf/keywords.c
+++ b/lib/libipsecconf/keywords.c
@@ -381,7 +381,7 @@ struct keyword_def ipsec_conf_keywords_v2[]={
      {"plutofork",           kv_config, kt_bool,      KBF_PLUTOFORK,NOT_ENUM},
      {"perpeerlog",        kv_config, kt_bool,   KBF_PERPEERLOG,NOT_ENUM},
      {"perpeerlogdir",        kv_config, kt_dirname,   KSF_PERPEERDIR,NOT_ENUM},
- -    {"oe",             kv_config, kt_bool,      KBF_OPPOENCRYPT,NOT_ENUM},
+    {"oe",             kv_config, kt_obsolete,  KBF_WARNIGNORE,NOT_ENUM},
      {"fragicmp",       kv_config, kt_bool,      KBF_FRAGICMP,NOT_ENUM},
      {"hidetos",        kv_config, kt_bool,      KBF_HIDETOS,NOT_ENUM},
      {"uniqueids",      kv_config, kt_bool,      KBF_UNIQUEIDS,NOT_ENUM},

- -------

These functions are also used in other freeswan derivatives - openswan 1.x to 2.6.38,
strongswan 1.x to 4.3.4 and superfreeswan.

For full information regarding openswan, see CVE-2013-2053
For full information regarding strongswan, see CVE-2013-2054

- -------

This vulnerability was found by Florian Weimer of the Red Hat Product
Security Team (https://access.redhat.com/security/team/)

About libreswan (https://libreswan.org/)
- ----------------------------------------

Libreswan is a free implementation of the Internet Protocol Security
(IPsec) suite and Internet Key Exchange (IKE) protocols. It is a
descendant (fork) of openswan 2.6.38.

IPsec uses strong cryptography to provide both authentication and
encryption services. These services allow you to build secure tunnels
through untrusted networks. Everything passing through the untrusted
network is encrypted by the IPsec gateway machine, and decrypted by
the gateway at the other end of the tunnel. The resulting tunnel is a
virtual private network (VPN).
Version: GnuPG v1.4.13 (GNU/Linux)


More information about the Swan-announce mailing list