Python UUEncode Vulnerability
The Python uu encoding functions did not sanitise the filename parameter, allowing newline characters to inject uu encoded data into the output. An attacker could use this to insert, replace, or corrupt file contents, or to write arbitrary files when decoding.
sec.stealthcopter.com
Published on sec.stealthcopter.com
I had a look at the Python source code for and discovered a vulnerability in the UUEncode methods in Python. UUEncode is an old data format that is very rarely used anymore.
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
The uu encoding functions passed the filename parameter into the encoded output without sanitising newline characters, allowing the filename to overflow into the content area.
Impact
An attacker could stealthily insert, replace, or corrupt file contents, cause denial of service or data loss, and write arbitrary files (limited to the current directory unless forward slashes can be written).
What the attacker needed
Ability to control the filename parameter; victim decodes the crafted uu file
How it was found
- Call a uu encoding function such as uu.encode or uu_codec.uu_encode with a filename that contains newline characters.
- The newline characters cause the filename to overflow into the uu encoded content area.
- Insert valid uu encoded data, invalid data, or an end control sequence to achieve insert, replace, corrupt, or null attacks.
- When decoding, the filename in the uu file is used directly to create a file, enabling file write attacks.
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.
UUEncode is an old way of turning binary files into text so they can be sent by email. The Python functions that create these text files took a filename from the user but did not check it for newline characters. A newline in the filename could trick the decoder into treating part of the filename as file content, letting an attacker change or add files.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.