fix: harden rewrite and file handling edge cases#6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f595f4367b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eae422ff38
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 616b40779d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| fn ensure_existing_regular_file(path: &Path, operation: &str) -> io::Result<()> { | ||
| let metadata = fs::symlink_metadata(path)?; | ||
| let metadata = fs::metadata(path)?; |
There was a problem hiding this comment.
Reject symlinks when validating readable files
Switching this check to fs::metadata makes safe_fs::read_to_string follow symlinks, so symlink paths now pass the regular-file guard. I checked src/session/persistence.rs, and session_file_path() falls back to /tmp/whispers/session.json when XDG_RUNTIME_DIR is unset; a precreated symlink there can redirect reads to attacker-chosen regular files, causing session-load DoS or parsing attacker-controlled JSON that was previously blocked by symlink rejection. Keeping symlink-safe read validation (symlink_metadata and nofollow semantics) avoids this /tmp symlink attack surface.
Useful? React with 👍 / 👎.
Summary
Testing
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo testcargo test structured_text -- --nocapturecargo test build_rewrite_plan -- --nocapturecargo test safe_fs -- --nocapturecargo test runtime_diagnostics -- --nocapturecargo check --no-default-featurescargo check --no-default-features --features osdcargo check --no-default-features --features local-rewritecargo check --no-default-features --features cudacargo check --no-default-features --features cuda,local-rewritecargo package --lockedcargo install --path . --features cuda --force