Potential fix for code scanning alert no. 4: Clear-text logging of sensitive information - #101
Conversation
…nsitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ea2e24256
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| input_keys = ", ".join(sorted(str(k) for k in inputs.keys()))[:60] | ||
| print( | ||
| f"\n\033[93m [permission] {name}(keys=[{input_keys}], total={len(inputs)})\033[0m" |
There was a problem hiding this comment.
Redact the earlier tool trace as well
When the CodeAgent runs with the default output_mode="stream", query() prints json.dumps(tinput)[:60] at lines 1521–1522 immediately before calling _execute_tool. Sensitive values in a Bash command or MCP argument therefore reach the same output stream before this redacted permission message is displayed, so the normal CLI path remains vulnerable to the clear-text disclosure this change is intended to fix.
Useful? React with 👍 / 👎.
| input_keys = ", ".join(sorted(str(k) for k in inputs.keys()))[:60] | ||
| print( | ||
| f"\n\033[93m [permission] {name}(keys=[{input_keys}], total={len(inputs)})\033[0m" |
There was a problem hiding this comment.
Escape untrusted key names before printing
If a model-generated tool input contains an unexpected key with a newline or terminal escape sequence, interpolating input_keys writes those characters directly beside the approval prompt; the previous json.dumps representation escaped such control characters. A crafted tool call can consequently clear or spoof terminal output before asking the user to approve it, so either omit key names entirely or render them with a control-character-safe representation.
Useful? React with 👍 / 👎.
Potential fix for https://github.com/cvsz/zcoder/security/code-scanning/4
To fix this without changing functionality, keep the permission prompt behavior intact but stop logging raw tool arguments.
Best approach: replace the current
print(...json.dumps(inputs)...)with a message that includes only the tool name and a safe summary (for example, argument keys and count), not values.In
src/zcoder/claude/capabilities/code.py, within_execute_toolnear line 1253, change:{name}({json.dumps(inputs)[:60]}){name}(keys=..., total=...)No new imports are required; we can compute key names inline.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.