Go back

Threat Hunting Using Memory Leaks in Banner Grabs

Adam Powis

Adam Powis

in/adam-powis-627415226/

In October, I was analysing some of our banner grabs in Target Intelligence and noticed a weird string in some STUN data that looked suspiciously like a memory address.

Further digging into this, using vendor fingerprinting techniques, some reverse engineering and a local lab setup, I was able to show this was a previously unknown vulnerability in coturn 4.10.0, which VulnCheck subsequently assigned CVE-2026-104074.

Using the shape of the leaked bytes, I was also able to tell apart most hosts running the official Debian image, the official Alpine image and Alpine's own coturn package.

Initial Discovery

At THREATCON1 this year, I attended a brilliant talk by Eric Forte on STUN/TURN being used for command and control (C2). STUN and TURN are helper protocols that let devices behind NATs and firewalls (home routers, office networks, mobile carriers) connect directly for things like voice and video calls. STUN tells a device what its public IP address and port look like from the internet, so it can share that address with the other side. When a direct connection still isn't possible, TURN relays the traffic through a server sitting in the middle.

Halfway through the talk, I realised I had forgotten about the existence of TURN in our STUN scanner, so I implemented it that night in my hotel room.

The next morning, I looked at our results and very quickly found 58 hosts whose error reason phrase (the short human-readable text that goes with a STUN error code) held raw bytes such as ffffffff975fb30462c9d0b51e3a73baa63a38bb (an example from our lab), when we should have been seeing ASCII text like Unauthorized, or nothing at all.

I next looked at the REALM in the hosts leaking this data. REALM is part of STUN's long-term credential mechanism: a free-text string, set by whoever configured the server, that tells a client which credentials to use. It varied from host to host, but several values hinted at the product that was running behind the banner data: wiretrustee[.]com is the default in NetBird's coturn config template (Wiretrustee is NetBird's former name), and others were simply openvidu. Both projects ship coturn as their TURN server.

Lab Time

With this in mind, I downloaded the Debian Docker image coturn/coturn:4.12.0, set up a lab and sent some probes. No luck. So I tried 4.11.0, no luck, then 4.10.0. It worked!

What's more, the leak matched the most common shape we were seeing on the internet: ffffffff followed by 16 random bytes, which accounts for about 70% of leaking hosts.

Trying other images and builds, I was able to tie the majority of hosts to different flavours, fingerprinting how each server was built:

FlavourShapeHostsReproduced by
Affffffff + 16 random bytes750 (70.0%)Official Debian image (all tags), source builds on Debian 12, Rocky 9 and Amazon Linux 2023. Same with use-auth-secret.
BXX XX 7x 00198 (18.5%)Alpine 3.23 apk package
CXX 7x 00 0063 (5.9%)Official Alpine image (all tags, either auth mode). Every Ubuntu 24.04 build: ./configure, CMake default and Release, clang, -O0, -O3.
D4 random bytes2 (0.2%)Source build on Ubuntu 22.04
E28 random bytes29 (2.7%)not reproduced
F08 00 00 008 (0.7%)not reproduced
G48 random bytes9 (0.8%)not reproduced
miscother short shapes17 (1.6%)not reproduced

Host counts cover the 1,071 leaking hosts we saw in the 30 days to 2026-11-25. Five hosts showed two different shapes in that window, so the column adds up to slightly more than 1,071.

Code Analysis

The next step was to figure out what was causing the memory leak. Looking at the code in GitHub, I was able to find the code that builds the reason phrase.

From src/client/ns_turn_msg.c in coturn 4.10.0, with comments marked VulnCheck: added by us:

static void stun_init_error_response_common_str(uint8_t *buf, size_t *len, uint16_t error_code, const uint8_t *reason,
                                                stun_tid *id, bool include_reason_string) {
  ...
  uint8_t avalue[513];       // VulnCheck: stack buffer, never zeroed in 4.10.0
  avalue[0] = 0;             // VulnCheck: only the 4 header bytes are set...
  avalue[1] = 0;
  avalue[2] = (uint8_t)(error_code / 100);
  avalue[3] = (uint8_t)(error_code % 100);
  if (include_reason_string) {  // VulnCheck: false by default since PR #1829
    strncpy((char *)(avalue + 4), (const char *)reason, sizeof(avalue) - 4);
  }
  avalue[sizeof(avalue) - 1] = 0;
  // VulnCheck: ...so with the option off, strlen() walks leftover stack bytes
  // after the header until it happens to hit a zero byte
  int alen = 4 + (int)strlen((const char *)(avalue + 4));

  //"Manual" padding for compatibility with classic old stun:
  {
    const int rem = alen % 4;
    if (rem) {
      alen += (4 - rem);  // VulnCheck: rounds up, sending up to 3 more stack bytes past that zero
    }
  }

  // VulnCheck: alen bytes of avalue, leftover stack and all, go into the ERROR-CODE attribute
  stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE, (uint8_t *)avalue, alen);
  ...
}

The fix in 4.11.0 is one line, added straight after the declaration:

  uint8_t avalue[513];
  memset(avalue, 0, sizeof(avalue));

The bug came in with a March 2026 change aimed at reducing UDP amplification, which made the reason text optional and off by default. 4.9.0 always copies the text in, and 4.11.0 quietly added the memset as part of a fuzzing change, with no advisory, so 4.10.0 is the only affected release. Running it under Valgrind confirmed the uninitialised read on the unauthenticated 401 response.

Impact

  • No authentication, one packet. A single unauthenticated TURN Allocate is enough to get a 401 back with leaked stack memory in it.
  • Every error response leaks, not just the 401. All of coturn's STUN and TURN error responses are built by the same function, so in our lab every error path we tried leaked, including plain STUN errors that don't involve TURN at all.
  • Small, but not harmless. In our lab, each response carried 4 to 20 bytes of leftover stack, and on the internet we've seen up to 48. On common builds, these can include fragments of memory addresses, which helps an attacker work around ASLR. We didn't see credentials or other secrets in the leaked bytes.
  • CVSS: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.

Exposure

  • We see 449 to 578 distinct leaking hosts every week: a peak of 578 in the week of October 19, easing to about 450 a week through November. That makes 1,071 over the 30 days to 2026-11-25.
  • Why it hasn't gone away: coturn's official Docker image tagged latest was 4.10.0 from mid-April to early May 2026, so any container started then and never recreated is still vulnerable. Alpine 3.23's own coturn package is still 4.10.0-r0 today.
  • These numbers are a floor. A vulnerable server only shows the bug when the stack happens to hold non-zero bytes at the wrong spot. When it holds a zero, the server sends an empty reason phrase, which looks exactly like a patched server running the default config. In our lab, every arm64 build of 4.10.0 did this. Those hosts are vulnerable but invisible to a scan.

Timeline

DateEvent
2026-03-07coturn PR #1829 makes the reason phrase optional and off by default, introducing the bug
2026-04-14coturn 4.10.0 released
2026-04-23coturn PR #1878, a fuzzing change, adds the missing memset
2026-05-08coturn 4.11.0 released, silently fixing the leak, with no advisory
2026-10-06We spot the leak in our new TURN scan data, trace it to 4.10.0 and ship a detection
2026-10-07Valgrind confirms the uninitialised read in a lab build of 4.10.0
2026-10-15VulnCheck, as the CNA for coturn, assigns CVE-2026-104074

Mitigations

  • Upgrade to coturn 4.11.0 or later. Only 4.10.0 is affected.
    • On Docker, re-pull and recreate the container from a pinned tag (e.g. coturn/coturn:4.11.0 or newer); containers started from latest in April-May 2026 are still on 4.10.0 until recreated.
    • On Alpine, apk upgrade on 3.23 still installs 4.10.0-r0; move to Alpine 3.24 (which ships 4.19.2) or use the official image.
  • If you can't upgrade straight away, add include-reason-string to turnserver.conf (or start with --include-reason-string) and restart. In our lab this stopped the leak on every error path, at the cost of slightly larger error responses, which is what the default was trying to avoid.

Detections

VulnCheck exploit availability

An information disclosure exploit for CVE-2026-104074 is available to VulnCheck Initial Access Intelligence customers as of November 25, along with Snort and Suricata rules, a Nuclei template, a PCAP and a target Docker container. The go-exploit module sends one unauthenticated Allocate, saves the leaked bytes and makes a best guess at how the server was built from the shape of the leak.

Checking your own servers

To check a server yourself, send it a TURN Allocate with no credentials and look at the reason phrase in the 401 that comes back. Text such as Unauthorized or an empty reason is fine. Anything else, especially non-printable bytes, means it's running 4.10.0. An empty reason doesn't prove a server is patched, though: as covered under Exposure, some vulnerable builds send an empty reason too, so check the version on the host as well.

Conclusion

Using banner grabs to fingerprint what devices are present in a network or on the internet is a well-understood pattern. In this instance, we showed that the data can be used for real vulnerability research by looking for responses that don't line up with the protocol's grammar.

Over the next few months, I will share more examples of how we used our data to find other vulnerabilities in a similar fashion. We have automated the discovery of this type of data and have disclosed several vulnerabilities to vendors, including three Modbus memory leaks and an OpenVPN Heartbleed-style out-of-bounds read.

About VulnCheck

VulnCheck's research team tracks internet-facing exposure and exploitation activity using our Target Intelligence and Initial Access Intelligence datasets.

Sign up for the VulnCheck community today to get free access to our VulnCheck KEV, enjoy our comprehensive vulnerability data, and request a trial of our Target Intelligence, Initial Access Intelligence, and Exploit & Vulnerability Intelligence products.

Ready to get Started?

Explore VulnCheck, a next-generation Cyber Threat Intelligence platform, which provides exploit and vulnerability intelligence to help you prioritize and remediate vulnerabilities that matter.
  • Vulnerability Prioritization
    Prioritize vulnerabilities that matter based on the threat landscape and defer vulnerabilities that don't.
  • Early Warning System
    Real-time alerting of changes in the vulnerability landscape so that you can take action before the attacks start.