Repository navigation
fix(encode): create temp files in a private directory - #237
Closed
LeadcodeDev wants to merge 1 commit into
Closed
LeadcodeDev wants to merge 1 commit into
LeadcodeDev wants to merge 1 commit into
Conversation
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 21, 2026 23:40
8fcccd8 to
eff63b6
Compare
53 tasks
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 22, 2026 06:10
55e83a3 to
df1d15d
Compare
LeadcodeDev
added this pull request to stack #280
September 22, 2026 06:40
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 22, 2026 08:34
df1d15d to
e703141
Compare
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 22, 2026 08:44
e703141 to
756d9d8
Compare
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 22, 2026 08:59
756d9d8 to
7974a25
Compare
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 22, 2026 09:04
7974a25 to
b9fd1bd
Compare
The path is fully derived from PID plus a counter starting at 0, in a shared, world-writable directory. `create_dir_all` succeeds on an already-existing directory (or a symlink to one) and `fs::write` follows symlinks, so a local attacker who pre-creates `/tmp/rustmotion_audio_<pid>_0/audio.raw` as a symlink gets an arbitrary file truncated and overwritten with PCM bytes under the rendering user's identity; PID space is small enough to pre-seed exhaustively. The same class exists in `video_audio.rs:258`, `std::env::temp_dir().join(format!("rustmotion_vidaud_{:016x}.wav", hash))`, where `hash` comes from `DefaultHasher::new()` (SipHash seeded with fixed keys 0,0 — deterministic across processes and machines), so the path is exactly predictable. There, `if wav_path.exists() { return Some(wav_path) }` (line 298) means a pre-planted file is used verbatim as the render's audio, and the `.partial.wav` sibling is handed to `ffmpeg -y` (line 339-340), which follows a symlink at that path.
Refs #220
LeadcodeDev
force-pushed
the
fix/encode-temp-dir
branch
from
September 22, 2026 09:08
b9fd1bd to
6561fe1
Compare
Owner
Author
|
Closed and reopened as a fresh pull request: GitHub registered this one as part of a stack, and a stacked pull request cannot be merged through either the GraphQL or the REST merge endpoint. The finding itself is unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Severity Low, category security. Location:
crates/rustmotion/src/encode/video/ffmpeg.rs:452Impact
The path is fully derived from PID plus a counter starting at 0, in a shared, world-writable directory.
create_dir_allsucceeds on an already-existing directory (or a symlink to one) andfs::writefollows symlinks, so a local attacker who pre-creates/tmp/rustmotion_audio_<pid>_0/audio.rawas a symlink gets an arbitrary file truncated and overwritten with PCM bytes under the rendering user's identity; PID space is small enough to pre-seed exhaustively. The same class exists invideo_audio.rs:258,std::env::temp_dir().join(format!("rustmotion_vidaud_{:016x}.wav", hash)), wherehashcomes fromDefaultHasher::new()(SipHash seeded with fixed keys 0,0 — deterministic across processes and machines), so the path is exactly predictable. There,if wav_path.exists() { return Some(wav_path) }(line 298) means a pre-planted file is used verbatim as the render's audio, and the.partial.wavsibling is handed toffmpeg -y(line 339-340), which follows a symlink at that path.Fix
Create the scratch directory with
std::fs::create_dir(fails withAlreadyExistsrather than adopting a hostile one) plus a random suffix, or adopt thetempfilecrate for O_EXCL creation with a random name and RAII cleanup. For the video-audio WAV cache, put it under a per-user, non-world-writable directory (e.g.dirs::cache_dir()) instead oftemp_dir(), and verify the cache entry is a regular file rather than trustingexists().Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-44).