0001-syntax.c-check-for-syntax-element-inconsistencies.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 466b01d504d7e45f1e9169ac90b3e34ab94aed14 Mon Sep 17 00:00:00 2001
  2. From: Hugo Lefeuvre <hle@debian.org>
  3. Date: Mon, 25 Feb 2019 10:49:03 +0100
  4. Subject: [PATCH] syntax.c: check for syntax element inconsistencies
  5. Implicit channel mapping reconfiguration is explicitely forbidden by
  6. ISO/IEC 13818-7:2006 (8.5.3.3). Decoders should be able to detect such
  7. files and reject them. FAAD2 does not perform any kind of checks
  8. regarding this.
  9. This leads to security vulnerabilities when processing crafted AAC
  10. files performing such reconfigurations.
  11. Add checks to decode_sce_lfe and decode_cpe to make sure such
  12. inconsistencies are detected as early as possible.
  13. These checks first read hDecoder->frame: if this is not the first
  14. frame then we make sure that the syntax element at the same position
  15. in the previous frame also had element_id id_syn_ele. If not, return
  16. 21 as this is a fatal file structure issue.
  17. This patch addresses CVE-2018-20362 (fixes #26) and possibly other
  18. related issues.
  19. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  20. ---
  21. Upstream status: commit 466b01d504d7
  22. libfaad/syntax.c | 12 ++++++++++++
  23. 1 file changed, 12 insertions(+)
  24. diff --git a/libfaad/syntax.c b/libfaad/syntax.c
  25. index f8e808c269c0..e7fb11381e46 100644
  26. --- a/libfaad/syntax.c
  27. +++ b/libfaad/syntax.c
  28. @@ -344,6 +344,12 @@ static void decode_sce_lfe(NeAACDecStruct *hDecoder,
  29. can become 2 when some form of Parametric Stereo coding is used
  30. */
  31. + if (hDecoder->frame && hDecoder->element_id[hDecoder->fr_ch_ele] != id_syn_ele) {
  32. + /* element inconsistency */
  33. + hInfo->error = 21;
  34. + return;
  35. + }
  36. +
  37. /* save the syntax element id */
  38. hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
  39. @@ -395,6 +401,12 @@ static void decode_cpe(NeAACDecStruct *hDecoder, NeAACDecFrameInfo *hInfo, bitfi
  40. return;
  41. }
  42. + if (hDecoder->frame && hDecoder->element_id[hDecoder->fr_ch_ele] != id_syn_ele) {
  43. + /* element inconsistency */
  44. + hInfo->error = 21;
  45. + return;
  46. + }
  47. +
  48. /* save the syntax element id */
  49. hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
  50. --
  51. 2.20.1