fix: reject invalid output filenames to prevent path traversal (V-002) - #209
Conversation
Automated security fix generated by OrbisAI Security
|
Even with this being a real security issue, I haven't seen any malware that uses Candlestick. It's way easier to create malware for Blender and Animate than Candlestick, and the mentioned softwares also have way more users than Candlestick. |
Narrow the V-002 fix to the actual reachable issue: path traversal via the name parameter feeding output_path in render_video_ffmpeg (CWE-22). Replace the character-stripping sanitizer with an explicit allow-list validator that rejects invalid names outright, so inputs like "../../foo" fail loudly instead of being silently rewritten to "foo". Adds unit tests for the validator.
|
@InternetAstronaut fair pushback — I've updated the PR to reflect that. You're right that the original report overstated this: What's left, and worth fixing regardless of Candlestick's current
Updated title/description are pushed now. Let me know if you'd still |
Summary
Fixes a path-traversal issue (CWE-22) in
render_video_ffmpeg(
src-tauri/src/main.rs): the user-suppliednameparameter was usedto build
output_pathwithout validation, so a crafted project file(e.g.
name = "../../../Users/me/Desktop/evil") could cause therendered
.mp4to be written outside the intended temp renderdirectory.
Scope correction from the original automated report
The original scanner report labeled this CRITICAL and described
"shell metacharacter injection" affecting both
nameandfps. Thatframing doesn't hold up:
Command::new("ffmpeg")in Rust does not invoke a shell, sothere is no shell metacharacter injection here.
fpsis only ever used as&fps.to_string()passed as a singleCommandargument; it isn't used to construct any path.The real, demonstrable issue is narrower:
namefeedingoutput_pathallows path traversal / unintended output fileplacement (CWE-22). This PR fixes that specific issue.
Fix
The previous fix in this PR stripped invalid characters from
namebefore use (silently turning
"../../foo"into"foo"). This revisionreplaces that with an explicit allow-list validator that rejects
invalid names outright instead of transforming them, so the security
boundary is explicit and a caller isn't surprised by a silently
different filename than the one they chose.
Tests
Added
#[cfg(test)] mod tests(first test insrc-tauri) coveringvalid names, empty names, and traversal/separator patterns. Run
locally with
cd src-tauri && cargo test(no CI workflow exists yetin this repo to run this automatically).
Files changed
src-tauri/src/main.rsOriginally opened as an automated security fix by OrbisAI
Security; revised by the PR author to narrow
scope to the actual verifiable issue and strengthen the fix.