Skip to content

fix(hooks): watch hook no longer writes the environment to /tmp - #152

Open
F0rce wants to merge 1 commit into
mixedbread-ai:mainfrom
F0rce:fix/watch-log-env-dump
Open

F0rce wants to merge 1 commit into
mixedbread-ai:mainfrom
F0rce:fix/watch-log-env-dump

Conversation

@F0rce

@F0rce F0rce commented Oct 6, 2026

Copy link
Copy Markdown

Problem

plugins/mgrep/hooks/mgrep_watch.py runs on every Claude Code session start and calls debug_log(f"All environment variables: {os.environ}"). That writes the full environment of the agent process to /tmp/mgrep-watch.log, which is created with the default umask (-rw-r--r--), so other local users can read it. The environment typically contains MXBAI_API_KEY and other credentials the agent was started with. On my machine the log held 39 such dumps.

Change

Remove that one debug_log line. The other log lines (watcher start, stale pid file) stay.

Scope and approval

Very small, focused fix of an obvious bug: one line, no behaviour change besides the log no longer containing the environment.

Verification

Ran the patched hook with a payload and a canary variable in its environment (SECRET_CANARY=canary123, MGREP_WATCH_LOG pointed at a temporary file). The log contains only Started mgrep watch process: <pid>; grep -c canary123 returns 0. Before the change, the same run logs the full environment, canary included. python3 -m py_compile passes.

Not checked: other platforms' default /tmp permissions. Existing /tmp/mgrep-watch.log files keep their old content; users may want to delete them.

Model and harness: Claude Opus 5.5 (1M context) in Claude Code.

mgrep_watch.py logged `os.environ` to /tmp/mgrep-watch.log on every
session start. The log is world-readable by default and the environment
can contain MXBAI_API_KEY and other agent credentials. Remove the line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant