Skip to content

Potential fix for code scanning alert no. 4: Clear-text logging of sensitive information - #101

Merged
cvsz merged 1 commit into
mainfrom
alert-autofix-4
Aug 22, 2026
Merged

Potential fix for code scanning alert no. 4: Clear-text logging of sensitive information#101
cvsz merged 1 commit into
mainfrom
alert-autofix-4

Conversation

@cvsz

@cvsz cvsz commented Aug 22, 2026

Copy link
Copy Markdown
Owner

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_tool near line 1253, change:

  • from: printing {name}({json.dumps(inputs)[:60]})
  • to: printing a redacted prompt like {name}(keys=..., total=...)

No new imports are required; we can compute key names inline.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…nsitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cvsz
cvsz marked this pull request as ready for review August 22, 2026 16:11
@cvsz
cvsz merged commit 316ba22 into main Aug 22, 2026
13 of 18 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1253 to +1255
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +1253 to +1255
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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