Skip to content

security: tool output scrubbing misses raven's own oauth token files #842

Open

Description

@0xKT

Problem

Tool output scrubbing (added in #833) does not cover Raven's own OAuth token files, so a turn that reads one hands the access and refresh tokens to the model.

Two passes scrub a tool result before a model sees it (raven/config/held_secrets.py scrub_tool_output):

  1. scrub_held_secrets -- exact match on the values in config.json only;
  2. redact_home_config_read (raven/security/redact.py) -- pattern redaction when the call reaches into a dot-directory of the home.

The fix for the workspace false positive in #833 made _home_config() skip all of Raven's home (~/.raven), on the grounds that Raven's own keys are covered by pass 1. That holds for config.json, but not for the sign-in tokens under get_oauth_dir() (~/.raven/oauth/<provider>/...: chatgpt/auth.json, github_copilot/, MiniMax, litellm). They are in neither pass.

Repro

With #833 in, using a fake token:

import os
from raven.config.held_secrets import scrub_tool_output

home = os.path.expanduser("~")
tok = '{"access_token": "eyJhbGciOiJSUzI1NiJ9.FAKEPAYLOAD.sig", "refresh_token": "rt_FAKE0123456789abcdef"}'
print(scrub_tool_output({"path": f"{home}/.raven/oauth/chatgpt/auth.json"}, tok))  # unchanged
print(scrub_tool_output({"path": f"{home}/.codex/auth.json"}, tok))                # [redacted]

A refresh token is a long-lived account credential; once in a tool result it is in the session record and the provider's logs. The self-config skill tells the agent not to open credential stores, but #833's own measurement is that a model diagnosing an agent reads its settings anyway.

Suggested fix

Narrow the exclusion in _home_config() from Raven's whole home to the directories where a coding turn reads its own source: <raven home>/workspace and <raven home>/tmp (and the bound workdir). ~/.raven/oauth/... and the rest of Raven's home then stay under the pattern pass. Correct the _home_config() docstring, which says Raven's own keys are covered by the exact-match pass.

Verify: in tests/test_security_untrusted_context.py, assert a read of ~/.raven/oauth/<provider>/auth.json is redacted, next to the existing case that ~/.raven/workspace/... and ~/.raven/tmp/... stay unchanged; uv run pytest -q tests/test_security_untrusted_context.py.

Not a regression against the release before #833 (there was no scrubbing then); a gap in the new protection.

Activity

  1. akushonkamen commented on Oct 11, 2026

    @akushonkamen
    Contributor

    Confirmed the gap at HEAD (4acc63c): raven/security/redact.py:112-129 _home_config() exempts all of ~/.raven from the pattern pass on the assumption that Raven's own keys are covered by the exact-match pass, but raven/config/held_secrets.py:66-87 held_secrets() only collects values from config.json (get_config_path()) — nothing under get_oauth_dir() (raven/config/paths.py:86). So scrub_tool_output (held_secrets.py:111-119) lets ~/.raven/oauth/<provider>/auth.json contents through untouched, while ~/.codex/auth.json is redacted. Reproduced locally with the token JSON from this issue: oauth path unchanged, codex path [redacted].

    Taking this. Plan: follow the suggested fix — keep the _home_config() exemption only for the directories a coding turn legitimately reads/writes (Raven's workspace, tmp, and the bound workdir), so oauth token files fall back under the pattern pass; correct the docstring; add regression cases in tests/test_security_untrusted_context.py for both the newly redacted oauth path and the still-exempt workspace/tmp paths.

    This fix was produced with AI assistance (Claude / GLM), disclosed per repo convention.

  2. akushonkamen commented on Oct 11, 2026

    @akushonkamen
    Contributor

    Opened #917 with the suggested fix: _home_config() now exempts only the workspace and scratch directories, so a read of ~/.raven/oauth/<provider>/... is redacted like another program's settings read, and the docstring no longer claims the exact-match pass covers the token store.

    Verified: the repro script redacts both files; uv run --frozen --all-extras pytest tests/test_security_untrusted_context.py -q gives 25 passed (new oauth test next to the #833 exemption tests); full suite pytest tests -q --ignore=tests/manual gives 28194 passed / 4 failed / 118 skipped, the 4 failing with the change stashed on a clean main too.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions