Skip to content
Memory corruption Write-up Advanced

0xsha/CVE-2021-44142.py

A proof-of-concept script shows that Samba's handling of the Netatalk metadata extended attribute on a file's AFP_AfpInfo named stream can be made to read past the end of a buffer. An attacker with write access to a share could leak memory contents and, per the comments, potentially write out of bounds.

gist.github.com

Published on gist.github.com

Clone this repository at <script src="https://gist.github.com/0xsha/0859033e1777490576923a27fbcd23ac.js"></script> - Save 0xsha/0859033e1777490576923a27fbcd23ac to your computer and use it in GitHub Desktop.

The author, on gist.github.com

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 an off-by-one in parsing the Netatalk metadata extended attribute, where an offset is set to one less than the data length, so a later read runs past the buffer.

Impact

An attacker able to write the metadata attribute on a share could read out-of-bounds memory and, as the author notes, potentially perform an out-of-bounds write; the script itself only demonstrates the read.

What the attacker needed

Write access to a Samba share; ability to set extended attributes; samba4-python library installed

How it was found

  1. Place a file on the Samba share that carries the Netatalk metadata extended attribute.
  2. Connect to the share with the script's SMB helper using a username and password.
  3. Open the file's AFP_AfpInfo named stream for writing.
  4. Read a small amount of data from that stream, which returns leaked memory contents.

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.

Samba is software that lets Linux machines share files with Windows-style networks. A buffer is a fixed-size area of memory; reading or writing past its end ('out of bounds') can expose other data or corrupt memory. This script demonstrates such a read on a file's special metadata, which could let someone with access to a share see memory they should not.

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.