Skip to contentSkip to conversation

package/libsndfile: fix CVE-2018-19758

PATCH New Fabrice Fontaine 2 participants 6 messages Mar 4, 2020 – Mar 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/libsndfile: fix CVE-2018-19758

There is a heap-based buffer over-read at wav.c in wav_write_header in libsndfile 1.0.28 that will cause a denial of service.

---
 ...004-src-wav.c-Fix-heap-read-overflow.patch | 35 +++++++++++++++++++
 package/libsndfile/libsndfile.mk              |  2 ++
 2 files changed, 37 insertions(+)
 create mode 100644 package/libsndfile/0004-src-wav.c-Fix-heap-read-overflow.patch
package/libsndfile/0004-src-wav.c-Fix-heap-read-overflow.patch new file +35 -0
new file mode 100644
index 0000000000..2e730ca3fa
@@ -0,0 +1,35 @@
+From 42132c543358cee9f7c3e9e9b15bb6c1063a608e Mon Sep 17 00:00:00 2001
+From: Erik de Castro Lopo <[email protected]>
+Date: Tue, 1 Jan 2019 20:11:46 +1100
+Subject: [PATCH] src/wav.c: Fix heap read overflow
+
+This is CVE-2018-19758.
+
+Closes: https://github.com/erikd/libsndfile/issues/435
+[Retrieved (and backported) from:
+https://github.com/erikd/libsndfile/commit/42132c543358cee9f7c3e9e9b15bb6c1063a608e]
+Signed-off-by: Fabrice Fontaine <[email protected]>
+---
+ src/wav.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/wav.c b/src/wav.c
+index 9d71aadb..5c825f2a 100644
+--- a/src/wav.c
++++ b/src/wav.c
+@@ -1,5 +1,5 @@
+ /*
+-** Copyright (C) 1999-2016 Erik de Castro Lopo <[email protected]>
++** Copyright (C) 1999-2019 Erik de Castro Lopo <[email protected]>
+ ** Copyright (C) 2004-2005 David Viens <[email protected]>
+ **
+ ** This program is free software; you can redistribute it and/or modify
+@@ -1146,6 +1146,8 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
+ 		psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (0)) ; /* SMTPE format */
+ 		psf_binheader_writef (psf, "44", BHW4 (psf->instrument->loop_count), BHW4 (0)) ;
+ 
++		/* Loop count is signed 16 bit number so we limit it range to something sensible. */
++		psf->instrument->loop_count &= 0x7fff ;
+ 		for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
+ 		{	int type ;
+ 
package/libsndfile/libsndfile.mk +2 -0
index 19c3184961..7be822b875 100644
@@ -20,6 +20,8 @@ LIBSNDFILE_IGNORE_CVES += \
 	CVE-2018-19661 CVE-2018-19662
 # disputed, https://github.com/erikd/libsndfile/issues/398
 LIBSNDFILE_IGNORE_CVES += CVE-2018-13419
+# 0004-src-wav.c-Fix-heap-read-overflow.patch
+LIBSNDFILE_IGNORE_CVES += CVE-2018-19758
 
 LIBSNDFILE_CONF_OPTS = \
 	--disable-sqlite \
Signature · 1 line
2.25.0
#1 lore raw

PATCH 2/2 package/libsndfile: fix CVE-2019-3832

It was discovered the fix for CVE-2018-19758 (libsndfile) was not complete and still allows a read beyond the limits of a buffer in wav_write_header() function in wav.c. A local attacker may use this flaw to make the application crash.

---
 ...header-don-t-read-past-the-array-end.patch | 33 +++++++++++++++++++
 package/libsndfile/libsndfile.mk              |  2 ++
 2 files changed, 35 insertions(+)
 create mode 100644 package/libsndfile/0005-wav_write_header-don-t-read-past-the-array-end.patch
package/libsndfile/0005-wav_write_header-don-t-read-past-the-array-end.patch new file +33 -0
new file mode 100644
index 0000000000..e958517808
@@ -0,0 +1,33 @@
+From 6d7ce94c020cc720a6b28719d1a7879181790008 Mon Sep 17 00:00:00 2001
+From: Emilio Pozuelo Monfort <[email protected]>
+Date: Tue, 5 Mar 2019 11:27:17 +0100
+Subject: [PATCH] wav_write_header: don't read past the array end
+
+If loop_count is bigger than the array, truncate it to the array
+length (and not to 32k).
+
+CVE-2019-3832
+[Retrieved from:
+https://github.com/erikd/libsndfile/commit/6d7ce94c020cc720a6b28719d1a7879181790008]
+Signed-off-by: Fabrice Fontaine <[email protected]>
+---
+ src/wav.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/wav.c b/src/wav.c
+index 5c825f2a..104bd0a7 100644
+--- a/src/wav.c
++++ b/src/wav.c
+@@ -1146,8 +1146,10 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
+ 		psf_binheader_writef (psf, "44", BHW4 (0), BHW4 (0)) ; /* SMTPE format */
+ 		psf_binheader_writef (psf, "44", BHW4 (psf->instrument->loop_count), BHW4 (0)) ;
+ 
+-		/* Loop count is signed 16 bit number so we limit it range to something sensible. */
+-		psf->instrument->loop_count &= 0x7fff ;
++		/* Make sure we don't read past the loops array end. */
++		if (psf->instrument->loop_count > ARRAY_LEN (psf->instrument->loops))
++			psf->instrument->loop_count = ARRAY_LEN (psf->instrument->loops) ;
++
+ 		for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
+ 		{	int type ;
+ 
package/libsndfile/libsndfile.mk +2 -0
index 7be822b875..63d9a521e6 100644
@@ -22,6 +22,8 @@ LIBSNDFILE_IGNORE_CVES += \
 LIBSNDFILE_IGNORE_CVES += CVE-2018-13419
 # 0004-src-wav.c-Fix-heap-read-overflow.patch
 LIBSNDFILE_IGNORE_CVES += CVE-2018-19758
+# 0005-wav_write_header-don-t-read-past-the-array-end.patch
+LIBSNDFILE_IGNORE_CVES += CVE-2019-3832
 
 LIBSNDFILE_CONF_OPTS = \
 	--disable-sqlite \
Signature · 1 line
2.25.0
#2 lore raw

PATCH 2/2 package/libsndfile: fix CVE-2019-3832

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabrice" == Fabrice Fontaine <[email protected]> writes:

It was discovered the fix for CVE-2018-19758 (libsndfile) was not complete and still allows a read beyond the limits of a buffer in wav_write_header() function in wav.c. A local attacker may use this flaw to make the application crash.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 2/2 package/libsndfile: fix CVE-2019-3832

In reply to Fabrice Fontaine
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabrice" == Fabrice Fontaine <[email protected]> writes:

It was discovered the fix for CVE-2018-19758 (libsndfile) was not complete and still allows a read beyond the limits of a buffer in wav_write_header() function in wav.c. A local attacker may use this flaw to make the application crash.

Committed to 2019.02.x and 2019.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

PATCH 1/2 package/libsndfile: fix CVE-2018-19758

In reply to Fabrice Fontaine
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Fabrice" == Fabrice Fontaine <[email protected]> writes:

There is a heap-based buffer over-read at wav.c in wav_write_header in libsndfile 1.0.28 that will cause a denial of service.

Committed to 2019.02.x and 2019.11.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard