Skip to content

security(files): a hard link to a sensitive file under another name is read verbatim #703

Closed

Description

@ajianaz

Left over from #683 (the optional part of its suggested fix; PR #698 did the name rules and the configurable list).

Problem

is_sensitive_name checks the requested name and the canonical path. A hard link to .env (or any other sensitive file) under an innocuous name is neither, so read_file (ReadOnly, no approval) returns it verbatim. Severity: low; creating the link needs a command the owner approved.

Fix

  • In read_file and the other readers that use the sensitive rule: on a regular file with nlink > 1, treat it as sensitive unless every other name can be shown to be non-sensitive (cheap rule: nlink > 1 inside the workspace is withheld and the refusal points to read_file_raw).
  • Unix only; no-op elsewhere. No extra directory scan, just metadata().nlink().
  • Test: a hard link notes.txt to .env is withheld; a normal single-link file is not; a link outside the sensitive rule list stays readable when nlink == 1.

Activity

  1. added
    bug
    on Nov 14, 2026
  2. added a commit that references this issue on Nov 14, 2026
    6e45660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions