write up talk tuah
The podcast-hosting app validated an MP3's episode_name tag with isalnum() but then extracted the tag from the same file later, creating a time-of-check/time-of-use race. By racing two uploads with the same filename, an attacker could overwrite the file between validation and extraction, inject a path traversal sequence, and write a template file to achieve server-side template injection.
medium.com
Published on medium.com
My name is Fahad Almutairi AKA phisher . I’m ctf player,bug hunter and Cyber security enthuses .
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 time-of-check/time-of-use race: the app validated the episode_name tag with isalnum() but later extracted the tag from the same file without re-validating, allowing a concurrent overwrite to change the value.
Impact
An attacker could write arbitrary files outside the intended directory and achieve server-side template injection, potentially leading to code execution on the server.
What the attacker needed
Ability to upload MP3 files; ability to send concurrent upload requests; same filename for both uploads
The fix
The app should re-validate the episode_name tag after extraction or use a secure filename function to prevent path traversal, and avoid using the same file for validation and extraction.
How it was found
- Create an innocent MP3 file with ffmpeg.
- Create an exploit MP3 with the same filename but with a traversal sequence and SSTI payload in its metadata.
- Upload both files in parallel using the same filename so the second request overwrites the first upload's file.
- Repeat the race many times, using multiple script instances, until the race succeeds.
- The app writes the template file outside the intended directory, achieving SSTI.
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.
The app checked an MP3's metadata tag to make sure it was safe, but then read the tag again later from the same file. If an attacker swaps the file in between those two moments, the app uses the old safe check on a now-dangerous file. This let the attacker write a file outside the intended folder and run template code on the server.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.