Fix run_winexe_command leaking plaintext password in logs#69764
Open
ggiesen wants to merge 2 commits into
Open
Fix run_winexe_command leaking plaintext password in logs#69764ggiesen wants to merge 2 commits into
ggiesen wants to merge 2 commits into
Conversation
run_winexe_command reassigned cmd to the full command line before building logging_cmd, so the redacted logging_command interpolated the already-built command. This doubled the winexe prefix and embedded the real password in the INFO and DEBUG log lines despite the XXX-REDACTED-XXX intent. Build the logging command from the original cmd before reassigning cmd; the executed command is unchanged. Fixes saltstack#54910
dwoz
previously approved these changes
Jul 11, 2026
dwoz
reviewed
Jul 11, 2026
| logging_creds = f"-U '{username}%XXX-REDACTED-XXX' //{host}" | ||
| cmd = f"winexe {creds} {cmd} {args}" | ||
| logging_cmd = f"winexe {logging_creds} {cmd} {args}" | ||
| cmd = f"winexe {creds} {cmd} {args}" |
Contributor
There was a problem hiding this comment.
We handled this in the cmd.py module by never logging any arguments. We only ever log the the program name being run.
Contributor
Author
There was a problem hiding this comment.
Thanks @dwoz - good call, that's cleaner than redacting. Switched run_winexe_command to hand win_cmd just the program name ("winexe") as the logged command, so the arguments - credentials and all - never reach the logs, matching the salt.modules.cmdmod._log_cmd convention. Updated the test to assert only the program name is logged, and dropped the redaction entirely.
Per review, follow the salt.modules.cmdmod convention of logging only the program name and never the arguments, rather than redacting the password in a fully-rendered command line. This keeps credentials (and any other argument) out of the logs entirely.
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.
What does this PR do?
Corrects the order of two assignments in
run_winexe_command(salt/utils/cloud.py) so the redactedlogging_commandis built from the originalcmdbeforecmdis reassigned to the full command line. Previously the logging string interpolated the already-built command, which doubled thewinexeprefix and embedded the real plaintext password in the logged output. The actually executed command is unchanged; this is a logging/security fix.What issues does this PR fix or reference?
Fixes #54910
Previous Behavior
run_winexe_commandreassignedcmdto the full command line before buildinglogging_cmd, so the "redacted" log line interpolated the already-built command:The intended
XXX-REDACTED-XXXredaction was defeated: the second, embeddedwinexe -Ufragment carried the real password, and it was written to both the INFO and DEBUG log lines.New Behavior
The logged command is derived from the original inputs and contains a single, fully redacted credential:
The plaintext password no longer appears in any log line. The executed command is identical to before.
Merge requirements satisfied?
changelog/54910.fixed.md)tests/pytests/unit/utils/test_cloud.py:test_run_winexe_command_redacts_password_54910- asserts thelogging_commandpassed towin_cmdis fully redacted, contains no plaintext password, and has a singlewinexe -Ucredential fragment (the regression check).test_run_winexe_command_executes_correct_command_54910- must-not-regress: the executed command is still correct (passes with and without the fix).test_run_winexe_command_returns_win_cmd_result- thewin_cmdreturn value is propagated to the caller.[NOTICE] Commits signed with GPG?: No