Skip to content

🛡️ Sentinel: [HIGH] Fix predictable temp file symlink attack#88

Closed
himattm wants to merge 1 commit intomainfrom
sentinel-symlink-fix-17575191897006099380
Closed

🛡️ Sentinel: [HIGH] Fix predictable temp file symlink attack#88
himattm wants to merge 1 commit intomainfrom
sentinel-symlink-fix-17575191897006099380

Conversation

@himattm
Copy link
Copy Markdown
Owner

@himattm himattm commented May 6, 2026

🚨 Severity: HIGH
💡 Vulnerability: Predictable temporary file names (e.g., path + ".tmp") were used in world-writable directories (os.TempDir()) during atomic file writes in internal/sparkline/sparkline.go and internal/burnrate/burnrate.go. This allows malicious actors to create symlinks and overwrite arbitrary files because os.WriteFile follows symlinks.
🎯 Impact: Local privilege escalation or data corruption, as an attacker could pre-create a symlink with the predictable .tmp name pointing to a sensitive file, causing Prism to overwrite it.
🔧 Fix: Replaced the predictable path + ".tmp" logic with os.CreateTemp(filepath.Dir(path), filepath.Base(path)+".*.tmp"). Properly ensured the temporary file is created safely, has its permissions set to 0644 using f.Chmod(0644), and is explicitly closed before performing os.Rename.
Verification: Verified that tests pass via go test ./... and the logic securely sets up unpredictable file names using os.CreateTemp.


PR created automatically by Jules for task 17575191897006099380 started by @himattm

Fixed a vulnerability in internal/sparkline/sparkline.go and internal/burnrate/burnrate.go where predictable temporary file names (e.g., path + ".tmp") were used during atomic writes in shared temporary directories. Replaced with os.CreateTemp and handled permissions appropriately to prevent symlink attacks.

Co-authored-by: himattm <6266621+himattm@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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request mitigates symlink attack vulnerabilities by replacing predictable temporary filenames with os.CreateTemp in internal/burnrate/burnrate.go and internal/sparkline/sparkline.go. A sentinel documentation file was also added to record this security improvement. Feedback was provided regarding internal/sparkline/sparkline.go, where the error from os.Rename is currently ignored, potentially leading to leaked temporary files if the rename operation fails.

return
}

os.Rename(tmp, path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The error from os.Rename is ignored here. Since os.CreateTemp generates a unique filename for every call, failing to rename the file will result in a leaked temporary file in the system's temp directory. Over time, this can lead to disk space exhaustion. You should handle the error and remove the temporary file if the rename fails, consistent with the implementation in internal/burnrate/burnrate.go.

if err := os.Rename(tmp, path); err != nil {
	os.Remove(tmp)
}

@himattm
Copy link
Copy Markdown
Owner Author

himattm commented May 7, 2026

Closing as superseded by direct commit 42f3149 on main, which consolidated the burnrate/sparkline predictable-temp-file fixes and also preserved PR #82's updater temp-file hardening without the generated .jules note.

@himattm himattm closed this May 7, 2026
@himattm himattm deleted the sentinel-symlink-fix-17575191897006099380 branch May 7, 2026 15:34
@google-labs-jules
Copy link
Copy Markdown
Contributor

Closing as superseded by direct commit 42f3149 on main, which consolidated the burnrate/sparkline predictable-temp-file fixes and also preserved PR #82's updater temp-file hardening without the generated .jules note.

Understood. Acknowledging that this work is now obsolete and superseded by the direct commit on main, and stopping work on this task.

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