Bug 1277897 (CVE-2015-7805)

Summary: CVE-2015-7805 libsndfile: Heap overflow vulnerability when parsing specially crafted AIFF header
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: andreas, brendan.jones.it, carnil, dkholia, dominik, dtimms, fdc, gemi, lkundrak, lpoetter, mhlavink, moez.roy, oget.fedora, rdieter, scorneli, slawomir, wtaymans
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-27 12:03:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1277899, 1277900, 1277901, 1277902, 1277903, 1277904, 1277905, 1277906    
Bug Blocks: 1277910    

Description Adam Mariš 2015-11-04 10:23:11 UTC
A heap-based buffer overflow vulnerability was found in libsndfile. Vulnerability is based on the wrong management of the headindex and headend values. While parsing a specially crafted AIFF header, the attacker can manage index values in order to use memcpy(...) to overwrite memory heap. Affected versions are <= 1.0.25.

Reproducer:

https://packetstormsecurity.com/files/133926/libsndfile-1.0.25-Heap-Overflow.html

CVE assignment:

http://seclists.org/oss-sec/2015/q4/216

Comment 1 Adam Mariš 2015-11-04 10:24:32 UTC
Created audacity tracking bugs for this issue:

Affects: fedora-all [bug 1277902]
Affects: epel-all [bug 1277904]

Comment 2 Adam Mariš 2015-11-04 10:24:42 UTC
Created jack-audio-connection-kit tracking bugs for this issue:

Affects: fedora-all [bug 1277901]
Affects: epel-all [bug 1277903]

Comment 3 Adam Mariš 2015-11-04 10:24:50 UTC
Created libsndfile tracking bugs for this issue:

Affects: epel-5 [bug 1277905]

Comment 4 Adam Mariš 2015-11-04 10:24:57 UTC
Created pulseaudio tracking bugs for this issue:

Affects: epel-5 [bug 1277906]

Comment 5 Stefan Cornelius 2015-11-05 15:27:12 UTC
The problem appears to be in the header_read() function in src/common.c

>> if (psf->headindex + bytes > SIGNED_SIZEOF (psf->header))
>>    806 	{	int most ;
>>    807 
>>    808 		most = SIGNED_SIZEOF (psf->header) - psf->headindex ;
>>    809 		psf_fread (psf->header + psf->headend, 1, most, psf) ;
>>    810 		memset ((char *) ptr + most, 0, bytes - most) ;
>>    811 
>>    812 		psf_fseek (psf, bytes - most, SEEK_CUR) ;
>>    813 		return bytes ;
>>    814 		} ;

line 808 is trying to calculate the maximum remaining space in the header, "most". However, this calculation does not take "psf->headend" into account.

in line 809, psf_fread() tries to append "most" bytes to the header, but the start is offset by "psf->headend". Since "psf->headend" was not part of the "most" calculation, we end up overflowing psf->header.

After the psf->header, there are a couple function pointers for special IO functions. It's possible to e.g. overwrite the "seek" function pointer, which causes the psf_fseek() in line 812 to ultimately jump to a location controlled by the attacker.

Comment 7 Fedora Update System 2015-11-13 22:53:52 UTC
libsndfile-1.0.25-17.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2015-11-23 19:54:54 UTC
libsndfile-1.0.17-7.el5 has been pushed to the Fedora EPEL 5 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2015-11-23 22:51:07 UTC
libsndfile-1.0.25-17.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2015-11-23 23:20:10 UTC
libsndfile-1.0.25-16.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.