Skip to content
DoS Disclosed report Intermediate

Denial of service in libxml2, using malicious lzma file to consume available system memory

A malicious LZMA-compressed XML file caused libxml2's decompression path to request a very large memory allocation, exhausting available memory. An attacker could use such a file to cause a denial of service against software that parses untrusted compressed XML.

geeknik Follow

Originally disclosed on HackerOne

  • Fixed in 3 months
  • Disclosed after 2.0 years

Reported to the libxml2 devs on 23 August 2017 Patched on 7 September 2017

It was discovered through fuzzing that malicious LZMA compressed files could consume large amounts of memory when decompressed thus posing a DoS risk. I am unsure if a CVE will be assigned in this case.

od -tx1 ./test000
0000000 30 ff ff ff ff ff ff ff ff ff ff ff ff
0000015
./xmllint --valid test000
==31393==ERROR: AddressSanitizer failed to allocate 0x100002000 (4294975488) bytes of LargeMmapAllocator (error code: 12)
==31393==Process memory map follows:
        0x000000400000-0x000000fea000   /root/libxml2/xmllint
        0x0000011ea000-0x0000011eb000   /root/libxml2/xmllint
        0x0000011eb000-0x00000161e000   /root/libxml2/xmllint
        **SNIP**
        0x7f811e9e3000-0x7f811e9e4000
        0x7ffe02632000-0x7ffe02753000   [stack]
        0x7ffe027a9000-0x7ffe027ab000   [vvar]
        0x7ffe027ab000-0x7ffe027ad000   [vdso]
        0xffffffffff600000-0xffffffffff601000   [vsyscall]
==31393==End of process memory map.
==31393==AddressSanitizer CHECK failed: /build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/projects/compiler-rt/lib/sanitizer_common/sanitizer_common.cc:120 "((0 && "unable to mmap")) != (0)" (0x0, 0x0)
    #0 0x4da55f in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/root/libxml2/xmllint+0x4da55f)
    #1 0x4f52d5 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/root/libxml2/xmllint+0x4f52d5)
    #2 0x4e4902 in __sanitizer::ReportMmapFailureAndDie(unsigned long, char const*, char const*, int, bool) (/root/libxml2/xmllint+0x4e4902)
    #3 0x4ee205 in __sanitizer::MmapOrDie(unsigned long, char const*, bool) (/root/libxml2/xmllint+0x4ee205)
    #4 0x4218e2 in __asan::asan_malloc(unsigned long, __sanitizer::BufferedStackTrace*) (/root/libxml2/xmllint+0x4218e2)
    #5 0x4d0544 in malloc (/root/libxml2/xmllint+0x4d0544)
    #6 0x7f811e38926e  (/lib/x86_64-linux-gnu/liblzma.so.5+0xf26e)
    #7 0x7f811e382fe0  (/lib/x86_64-linux-gnu/liblzma.so.5+0x8fe0)
    #8 0x7f811e383472  (/lib/x86_64-linux-gnu/liblzma.so.5+0x9472)
    #9 0x7f811e37ceb0 in lzma_code (/lib/x86_64-linux-gnu/liblzma.so.5+0x2eb0)
    #10 0xee7fb6 in xz_decomp /root/libxml2/xzlib.c:577:19
    #11 0xee6bd9 in xz_make /root/libxml2/xzlib.c:652:13
    #12 0xee4fbf in __libxml2_xzread /root/libxml2/xzlib.c:743:17
    #13 0x78121a in xmlXzfileRead /root/libxml2/xmlIO.c:1435:11
    #14 0x78b8bb in xmlParserInputBufferGrow /root/libxml2/xmlIO.c:3337:8
    #15 0x5571e7 in xmlParserInputGrow /root/libxml2/parserInternals.c:324:8
    #16 0x58669d in xmlGROW /root/libxml2/parser.c:2090:5
    #17 0x67d68d in xmlParseDocument /root/libxml2/parser.c:10590:5
    #18 0x6d4114 in xmlDoRead /root/libxml2/parser.c:15183:5
    #19 0x51b413 in parseAndPrintFile /root/libxml2/xmllint.c:2391:9
    #20 0x5125dc in main /root/libxml2/xmllint.c:3767:7
    #21 0x7f811d4893f0 in __libc_start_main /build/glibc-mXZSwJ/glibc-2.24/csu/../csu/libc-start.c:291
    #22 0x41abb9 in _start (/root/libxml2/xmllint+0x41abb9)

The original report as published on HackerOne, by geeknik. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the LZMA decompression path trusted size information in the compressed stream and attempted a very large allocation without a sensible limit.

Impact

Parsing an untrusted compressed XML file could exhaust system memory and crash or stall the process, a denial of service; the report does not show remote exploitation beyond that.

What the attacker needed

Victim parses an untrusted LZMA-compressed XML file; libxml2 built with LZMA support

The fix

The issue was fixed in libxml2 on 7 September 2017 according to the report.

How it was found

  1. Create a tiny file containing malicious LZMA-compressed data.
  2. Run xmllint with the --valid option on that file.
  3. Observe the decompressor attempting to allocate several gigabytes and the process aborting.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Some programs accept XML files that are compressed to save space, and they unpack them before reading. Here a tiny crafted compressed file made the unpacking step ask for gigabytes of memory, so the program ran out of memory and stopped working. That is a denial of service: the attacker does not steal data, they just stop the service from running.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by geeknik

View all

79 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.