Skip to content
Memory corruption Write-up Advanced

(CVE-2021-0254) Junos OS overlayd service bss Buffer Overflow

The overlayd service on Junos OS copies packet data into a fixed-size buffer without checking its length, so a crafted UDP packet can overflow that buffer. An unauthenticated attacker who can reach the exposed port could send such a packet and achieve remote code execution on the device.

starlabs.sg

Published on starlabs.sg

(The above pseudo-code snippet is generated by IDA hexray. Some functions and variables were renamed for easy reading) The first function, taskrecvpkt (renamed form sub80917B0), is called to receive the packet.

The author, on starlabs.sg

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a missing length check before copying attacker-controlled packet data into a fixed-size static (bss) buffer in the packet parsing function.

Impact

An unauthenticated remote attacker could trigger the overflow and potentially execute code on the device, since the service runs as root and its port is exposed to the internet.

What the attacker needed

Network access to UDP port 4789; no authentication needed

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 write-up has not been written yet. The Original tab links to the source.

A buffer is a small reserved area of memory. This service copies incoming network data into a fixed-size buffer without first checking how much data arrived, so extra data spills past the end and overwrites nearby memory. Because the service runs with the highest privileges and its port is reachable from the internet, an attacker could take over the device.

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.

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.