Repository navigation
Conversation
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.
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.
Problem
plugins/mgrep/hooks/mgrep_watch.pyruns on every Claude Code session start and callsdebug_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 containsMXBAI_API_KEYand other credentials the agent was started with. On my machine the log held 39 such dumps.Change
Remove that one
debug_logline. 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_LOGpointed at a temporary file). The log contains onlyStarted mgrep watch process: <pid>;grep -c canary123returns 0. Before the change, the same run logs the full environment, canary included.python3 -m py_compilepasses.Not checked: other platforms' default
/tmppermissions. Existing/tmp/mgrep-watch.logfiles keep their old content; users may want to delete them.Model and harness: Claude Opus 5.5 (1M context) in Claude Code.