Skip to content

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

Open
nsextonTT wants to merge 1 commit into
mainfrom
alert-autofix-35
Open

nsextonTT wants to merge 1 commit into
mainfrom
alert-autofix-35

Conversation

@nsextonTT

Copy link
Copy Markdown
Collaborator

Potential fix for https://github.com/tenstorrent/tt-inference-server/security/code-scanning/35

The best fix is to preserve current functionality (still print runnable Docker commands) while masking values of sensitive -e environment variables in the printed output only. Do not change how real commands are executed; only sanitize display strings.

Implement this in workflows/run_docker_server.py by updating format_docker_command to detect -e KEY=value arguments and replace values for sensitive keys (for example API_KEY, OPENAI_API_KEY, and common secret-token key patterns) with a placeholder like ***REDACTED***. Because run.py already uses format_docker_command(...) for the flagged print path, this single change addresses all listed variants at once, including single-host and multi-host printed command paths, without altering runtime behavior.

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

…ensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@nsextonTT
nsextonTT marked this pull request as ready for review November 11, 2026 03:54
@nsextonTT
nsextonTT requested a review from a team as a code owner November 11, 2026 03:54

@fivanovicTT fivanovicTT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few follow-up observations on the redaction behavior. The display-only approach makes sense; these comments focus on matching and copying the printed command.

key_upper = key.upper()
if (
key_upper in sensitive_env_keys
or "TOKEN" in key_upper

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we narrow the token matching? "TOKEN" in key_upper also redacts ordinary settings such as VLLM__MAX_NUM_BATCHED_TOKENS=3072, which our embedding model specs use, and TOKENIZERS_PARALLELISM=false. This hides useful debugging information and makes copied commands pass ***REDACTED*** where a number or boolean is expected. Known credential names plus narrower patterns such as _TOKEN, _SECRET, and _PASSWORD would avoid these false positives. A regression test for an ordinary token-count setting would be useful.

or "PASSWORD" in key_upper
or key_upper.endswith("_KEY")
):
return f"{key}=***REDACTED***"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The placeholder is appropriate for diagnostic logs, but copying the printed command now sets the container API key to the literal ***REDACTED***. That changes authentication behavior, so the PR description’s promise to preserve runnable commands needs qualification. Could we label this output as requiring credential substitution, or handle --print-docker-cmd separately? For manual execution, -e API_KEY can inherit the value without printing it, provided the variable is exported in the environment where Docker runs. Please also test that formatting leaves the original execution arguments unchanged.

):
next_quoted = shlex.quote(docker_command[i + 1])
next_arg = docker_command[i + 1]
if docker_command[i] in ("-e", "--env"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Smaller completeness point: this catches separate -e KEY=value and --env KEY=value arguments, but inline forms such as --env=API_KEY=... and -eAPI_KEY=... still expose the value. Current command generation uses separate arguments, so this does not block the immediate fix. Could we either document that input assumption or cover the inline forms with redaction and focused tests?

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.

2 participants