Repository navigation
fix(security): read_file withholds a file with more than one hard link - #709
Merged
Merged
Conversation
A hard link to .env under another name matched no name rule and was read verbatim. On Unix a regular file with nlink > 1 is now refused and the refusal points to read_file_raw. Only metadata().nlink(); no scan; no-op on other platforms. Closes #703
ajianaz
force-pushed
the
fix/hardlink-sensitive
branch
from
November 14, 2026 05:41
47b2b43 to
6e45660
Compare
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
read_filerefuses a regular file that has more than one hard link (Unix only) and points toread_file_raw.Why
A hard link to
.envunder an innocuous name (notes.txt) matches neither the requested-name rule nor the canonical-path rule, soread_file(ReadOnly, no approval) returned it verbatim. Left over from #683.Changes
sensitive.rs:has_other_names(&Metadata), true whenis_file() && nlink() > 1on Unix, always false elsewhere.read_file.rs:read_regularchecks it on the open handle forread_file;read_file_rawskips it. The error namesread_file_raw.metadata().nlink(), no directory scan. The git diff filter andcora_searchhits stay name-based (they have no file handle to stat).read_file_raw.Testing
.envis withheld (error namesread_file_raw, no secret in it), a single-link file reads,read_file_rawreads the linked file, and after removing the other name it reads again.nlink > 1000makes the test fail.--workspace --all-targets --all-features -D warnings,cargo test --workspace,tole-core --no-default-featurespass, excepttole-clidoctor_warns_non_fatally_about_a_missing_windowandagents::parent_spawns_child_polls_until_settled, which fail the same way on unmodifieddevelopin my sandbox (cora MCP not approved in the plugin lock).Closes #703