Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Secure atomic file replacement#1

Merged
kassoulet merged 4 commits intomainfrom
secure-atomic-file-replacement-11030320871833359191
Mar 2, 2026
Merged

πŸ›‘οΈ Sentinel: [HIGH] Secure atomic file replacement#1
kassoulet merged 4 commits intomainfrom
secure-atomic-file-replacement-11030320871833359191

Conversation

@kassoulet
Copy link
Copy Markdown
Owner

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Predictable temporary filenames and loss of file permissions during in-place updates.
🎯 Impact: The application was vulnerable to symlink attacks where an attacker could pre-create a symlink with the predictable name .unc.<filename> to trick the tool into overwriting a sensitive file. Additionally, restricted permissions (e.g., 600) were lost during processing, potentially making sensitive data world-readable.
πŸ”§ Fix: Integrated the tempfile crate for secure temporary file creation with random suffixes. The tool now captures the original file's permissions and applies them to the new file before atomically replacing the original using persist().
βœ… Verification: Verified using reproduction scripts that permissions are now preserved and symlink attacks are prevented. Standard unit tests pass (ignoring pre-existing failures due to missing system dependencies).


PR created automatically by Jules for task 11030320871833359191 started by @kassoulet

- Use `tempfile::NamedTempFile` for secure, unpredictable temporary filenames.
- Preserve original file permissions when performing in-place updates.
- Ensure atomic file replacement via `persist()`.
- Move `tempfile` to main dependencies.
- Update tests to reflect new output path logic.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ 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.

kassoulet and others added 3 commits March 2, 2026 21:00
- Use `tempfile::NamedTempFile` for secure, unpredictable temporary filenames.
- Preserve original file permissions when performing in-place updates.
- Ensure atomic file replacement via `persist()`.
- Pin `tempfile` to 3.12.0 to maintain MSRV compatibility (Rust 1.82).
- Fix Clippy warning by using the `?` operator.
- Update tests to reflect new output path logic.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Use `tempfile::NamedTempFile` for secure, unpredictable temporary filenames.
- Preserve original file extension for temporary files to support external tools like `gdal_translate`.
- Preserve original file permissions when performing in-place updates.
- Ensure atomic file replacement via `persist()`.
- Pin `tempfile` to 3.12.0 to maintain MSRV compatibility (Rust 1.82).
- Fix Clippy warning by using the `?` operator.
- Update tests to reflect new output path logic.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Use `tempfile::NamedTempFile` for secure, unpredictable temporary filenames.
- Preserve original file extension for temporary files to support external tools like `gdal_translate`.
- Preserve original file permissions when performing in-place updates.
- Ensure atomic file replacement via `persist()`.
- Pin `tempfile` to 3.12.0 to maintain MSRV compatibility (Rust 1.82).
- Fix Clippy warning by using the `?` operator.
- Update tests to reflect new output path logic.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@kassoulet kassoulet merged commit 5721ebc into main Mar 2, 2026
5 checks passed
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