Skip to content
Memory corruption Advisory Advanced CVE-2023-38562

Weston Embedded uC-TCP-IP IP header loopback parsing double-free vulnerability

A double-free vulnerability in the IP header loopback parsing of Weston Embedded uC-TCP-IP v3.06.01 allows an unauthenticated attacker to send a sequence of packets that causes memory corruption, potentially leading to code execution.

Kelly Patterson Follow

Originally disclosed on Cisco Talos

High 8.7 View original

A double-free vulnerability exists in the IP header loopback parsing functionality of Weston Embedded uC-TCP-IP v3.06.01. A specially crafted set of network packets can lead to memory corruption, potentially resulting in code execution.

Kelly Patterson, 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

Likely the error-handling path frees the same transmit buffer twice because the loopback interface is not enabled, causing the first free in NetIF_TxPktDiscard and a second free in NetICMPv4_TxPktDiscard.

Impact

The double free could lead to memory corruption and potentially code execution, but the report notes that the immediate effect is a crash when writing to a NULL pointer, and exploitation depends on the memory layout of the target system.

What the attacker needed

Network access to the device; Loopback interface not enabled; No authentication required

The fix

The vulnerability was fixed in a vendor patch release, and can also be mitigated by enabling the NET_ERR_CFG_ARG_CHK_DBG_EN configuration option.

How it was found

  1. Send a packet with an identical source and destination address and an invalid IP header option.
  2. The IP header parsing code detects the error and calls NetICMPv4_TxMsgErr, which allocates a buffer for an ICMP error message.
  3. NetIPv4_Tx is called with swapped source and destination, and the route selection determines the packet is destined for localhost.
  4. The loopback interface is not enabled, so NetIF_TxHandler calls NetIF_TxPktDiscard, freeing the buffer for the first time.
  5. NetIPv4_Tx returns an error to NetICMPv4_TxMsgErr, which calls NetICMPv4_TxPktDiscard, freeing the same buffer a second time.
  6. Subsequent network buffer allocations return the same memory twice, leading to a crash when an ARP reply is processed.

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 report describes a bug in a small networking software package used in embedded devices. When the software receives a malformed network packet, it tries to send an error message back, but a mistake causes the same piece of memory to be freed twice. That can later make the program crash or, in some cases, let an 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 by Kelly Patterson

View all

20 more disclosed reports, best first.

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.