π‘οΈ Sentinel: [HIGH] Fix path traversal in file uploads - #29
Conversation
Co-authored-by: adihex <82704954+adihex@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Run-on: Niteshift
π¨ Severity: HIGH
π‘ Vulnerability: A path traversal vulnerability existed in the audio upload handler (
/transcribe) becausepath.basenamedoes not strip Windows-style path separators (\) when running in a POSIX environment. An attacker could bypass filename extraction by supplying a filename like..\..\..\etc\passwd, which would be processed as a literal string bypath.basenameand resolved as an absolute path bypath.join, leading to arbitrary file write.π― Impact: Arbitrary file write to the server's filesystem, which could lead to remote code execution (RCE) or system compromise.
π§ Fix: Replaced
path.basename(file.name)with a strict regex substitutionfile.name.replace(/[^a-zA-Z0-9.-]/g, "_"). This sanitizes the filename to only contain safe alphanumeric characters, dots, and hyphens, completely removing any risk of directory traversal characters.β Verification: Upload an audio file with a filename containing
..\..\to the/transcribeendpoint and observe that the saved file name uses underscores instead of backslashes, effectively rendering the traversal string harmless. Ensure tests run successfully (pnpm test).PR created automatically by Jules for task 12258315872887433358 started by @adihex