Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

mcp: the token document's mode check never compares its owner to the daemon's euid #1315

Backlog

Description

@chappie-daemon

Found by job 045's security lens (row 5 of #868) at 8488bf13.

checked judges type, permission bits and size only (crates/nostream-mcp/src/credential.rs:273-292); the refusal text claims "no one but its owner can read or rewrite it", but the owner it names is never compared to the process. The file form re-reads the document on every call, so the grant is live: an owner other than the daemon's euid can rewrite {"scopes":["write"]} between a read call and a write call. The exposure needs a root-run --mcp-stdio pointed at a file another user owns (a non-root daemon cannot open a foreign 0600 file at all, which is the fail-closed half), so it is low rather than high.

Evidence

grep -n 'if mode & GROUP_OR_OTHER != 0' crates/nostream-mcp/src/credential.rs → 278: if mode & GROUP_OR_OTHER != 0 {

What a fix changes

Compare the document's owner (MetadataExt::uid) to the effective uid and refuse a foreign-owned document, which also makes the refusal text true. The code comment calls this a shortcut that "needs a dependency this crate was not given" (crates/nostream-mcp/src/credential.rs:218-221); std::os::unix::fs::MetadataExt supplies it without a new dependency.

Acceptance

  • A case creates a 0600 document owned by another uid and asserts the refusal.
  • The refusal text and the check agree, or the text is narrowed to what is checked.

Record: docs/rewrite/reviews/2026-11-30-relay-storage.md — finding F19, lens security, tree 8488bf13.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Nov 30, 2026
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

    bugfactoryrewriterust

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions