Skip to content
Memory corruption Advisory Advanced CVE-2017-12087

Tinysvcmdns Multi-label DNS Heap Overflow Vulnerability

The tinysvcmdns library's nlabel_to_str function allocates a fixed 256-byte heap buffer but copies an unlimited number of bytes from DNS name labels, allowing a remote attacker to overflow the heap with controlled data. An attacker can send a crafted DNS packet to trigger this overflow, potentially leading to arbitrary code execution.

Discovered Lilith > Wyatt Follow

Originally disclosed on Cisco Talos

Critical 10.0 View original

An exploitable heap overflow vulnerability exists in the tinysvcmdns library version 2016-07-18. A specially crafted packet can make the library overwrite an arbitrary amount of data on the heap with attacker controlled values.

Discovered Lilith (>^.^)> Wyatt and Claudio Bozzato, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

The nlabel_to_str function allocates a fixed 256-byte buffer but uses strncpy to copy label data without validating the total length of the DNS name, allowing a heap buffer overflow.

Impact

A remote attacker with network connectivity could overwrite arbitrary heap data with controlled values, potentially leading to code execution or a denial of service.

What the attacker needed

Network access to UDP port 5353

The fix

The function should validate the total length of the DNS name and ensure it does not exceed the allocated buffer size before copying.

How it was found

  1. Send a DNS packet to UDP port 5353 with a multi-label name where labels are not terminated by a zero byte.
  2. The nlabel_to_str function processes the name, copying each label into the fixed 256-byte heap buffer.
  3. Because the total length exceeds 256 bytes, the strncpy calls overflow the heap buffer with attacker-controlled data.

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.

This is a heap overflow bug in a small DNS library. The program reserves a fixed-size memory area (256 bytes) to store a domain name, but when it copies the name from a network packet, it doesn't check how long the name is. An attacker can send a DNS packet with a very long name, causing the program to write past the reserved area and overwrite other memory with data they control. This can crash the program or let the attacker run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.