Skip to content

🔒 [security fix] Insecure Temporary File Creation in encode.moon#1

Closed
dsetareh wants to merge 1 commit into
masterfrom
fix-insecure-temp-file-creation-10989839207706548942
Closed

🔒 [security fix] Insecure Temporary File Creation in encode.moon#1
dsetareh wants to merge 1 commit into
masterfrom
fix-insecure-temp-file-creation-10989839207706548942

Conversation

@dsetareh

Copy link
Copy Markdown
Owner

🎯 What: The vulnerability fixed was the use of a predictable temporary file path (~/cache_dump.ts) when dumping HLS stream caches.

⚠️ Risk: A predictable filename in a known location can lead to:

  1. File Hijacking/Overwrite: Another process or user could create the file beforehand with specific permissions or content.
  2. Symlink Attacks: An attacker could create a symbolic link at the predictable path pointing to a sensitive file, causing the script to overwrite it.
  3. Collisions: Multiple instances of the script would interfere with each other.

🛡️ Solution:

  • Used os.tmpname() to generate unique, non-predictable temporary filenames.
  • Added a get_temp_path helper that handles Windows-specific quirks (ensuring absolute paths).
  • Introduced a temp_files_to_clean registry and a shutdown event handler to ensure all generated temporary files are deleted, even if the script is interrupted or crashes.
  • Properly exported utility functions to maintain compatibility with the project's build process.

PR created automatically by Jules for task 10989839207706548942 started by @dsetareh

- Replace predictable hardcoded temporary path with unique paths generated by os.tmpname().
- Implement a robust cleanup mechanism using a global tracking table and mpv shutdown event.
- Handle Windows-specific os.tmpname() behavior by prepending system temp directories.
- Export necessary utility functions and variables for cross-module access.

Co-authored-by: dsetareh <15238752+dsetareh@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@dsetareh

Copy link
Copy Markdown
Owner Author

dont care

@dsetareh dsetareh closed this Apr 12, 2026
@google-labs-jules

Copy link
Copy Markdown

dont care

Acknowledged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant