Description of problem:
Ramon de Carvalho Valle was testing eCryptfs with fsfuzzer and ran across a
stack overflow bug. At the beginning of each eCryptfs file, metadata is stored
containing things like encrypted file encryption key (EFEK), key signature of
key used to decrypt the EFEK, etc. This metadata is stored in "packets", as
per RFC 2440 - OpenPGP Message Format.
The header of each packet contains a packet length field. As the eCryptfs
kernel module reads the packet contents, it uses that packet length field in a
memcpy() to the destination buffer. However, no checks existed to make sure
the buffer was big enough to hold the entire packet contents.
A malicious user on the system that has permissions to perform an eCryptfs
mount (root or setuid mount helper needed) can modify the metadata using
hexedit and specify a bigger packet size than what the destination buffer can
hold and also modify the packet contents, which would probably allow them to
handcraft the data used to overwrite the stack.
Created attachment 354440 [details]
[PATCH 2/2] eCryptfs: parse_tag_3_packet check tag 3 packet encrypted key size
kernel-220.127.116.11-217.2.3.fc11 has been submitted as an update for Fedora 11.
Common Vulnerabilities and Exposures assigned an identifier CVE-2009-2407 to
the following vulnerability:
Reference: BUGTRAQ:20090728 [RISE-2009003] Linux eCryptfs parse_tag_3_packet Encrypted Key Buffer Overflow Vulnerability
Reference: URL: http://www.securityfocus.com/archive/1/archive/1/505337/100/0/threaded
Reference: MISC: http://risesecurity.org/advisories/RISE-2009003.txt
Reference: CONFIRM: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f151cd2c54ddc7714e2f740681350476cda03a28
Reference: CONFIRM: http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-18.104.22.168
Reference: URL: http://www.debian.org/security/2009/dsa-1844
Reference: URL: http://www.debian.org/security/2009/dsa-1845
Reference: URL: http://www.ubuntu.com/usn/usn-807-1
Reference: URL: http://www.securityfocus.com/bid/35850
Reference: URL: http://secunia.com/advisories/35985
Reference: URL: http://secunia.com/advisories/36045
Reference: URL: http://secunia.com/advisories/36051
Reference: URL: http://secunia.com/advisories/36054
Reference: URL: http://www.vupen.com/english/advisories/2009/2041
Heap-based buffer overflow in the parse_tag_3_packet function in
fs/ecryptfs/keystore.c in the eCryptfs subsystem in the Linux kernel
before 22.214.171.124 allows local users to cause a denial of service
(system crash) or possibly gain privileges via vectors involving a
crafted eCryptfs file, related to a large encrypted key size in a Tag
kernel-126.96.36.199-170.2.78.fc10 has been submitted as an update for Fedora 10.
This issue has been addressed in following products:
Red Hat Enterprise Linux 5
Via RHSA-2009:1193 https://rhn.redhat.com/errata/RHSA-2009-1193.html
kernel-188.8.131.52-170.2.78.fc10 has been pushed to the Fedora 10 stable repository. If problems still persist, please make note of it in this bug report.
kernel-184.108.40.206-217.2.3.fc11 has been pushed to the Fedora 11 stable repository. If problems still persist, please make note of it in this bug report.
Red Hat would like to thank Ramon de C. Valle for reporting this issue.