Skip to content

Fix: Keep credentials out of the process list and the log output - #1384

Open
TheBeast85 wants to merge 1 commit into
greenbone:mainfrom
TheBeast85:fix/credentials-in-process-list-and-log
Open

Fix: Keep credentials out of the process list and the log output#1384
TheBeast85 wants to merge 1 commit into
greenbone:mainfrom
TheBeast85:fix/credentials-in-process-list-and-log

Conversation

@TheBeast85

Copy link
Copy Markdown

What

  • Overwrite the credentials in the command line of the running process once the arguments are parsed (/proc/self/stat on Linux, process environment block on Windows), in a new gvmtools/secrets.py.
  • Redact credentials from all log records via the log record factory. This covers the Parsed arguments line, which wrote the password to the log file with --log DEBUG, and the <username>/<password> elements of GMP requests.
  • Stop printing %(default)r for the credential options in --help, which printed the password from the config file.
  • Add --gmp-password-file, --ssh-password-file, --gmp-password-prompt, --ssh-password-prompt and GVMTOOLS_GMP_PASSWORD / GVMTOOLS_SSH_PASSWORD.

Why

--gmp-password and --ssh-password are readable by any other user of the machine while the process runs, through ps and /proc/<pid>/cmdline on Linux and through the task manager and Win32_Process.CommandLine on Windows. The user name is exposed the same way. The existing options keep working, they just no longer stay visible; the new options avoid the exposure altogether.

Two limits, documented in docs/credentials.md: about a tenth of a second passes between process start and argument parsing, and the shell history is written by the shell.

References

None.

Checklist

  • Tests
  • Documentation (docs/credentials.md)

A password passed as --gmp-password or --ssh-password is readable by every
other user of the machine while the process runs, via ps and
/proc/<pid>/cmdline on Linux and via the task manager and
Win32_Process.CommandLine on Windows. The user name is exposed the same way.

- Add gvmtools/secrets.py, which overwrites the credentials in the command
  line of the running process once the arguments have been parsed. On Linux
  the argument vector is located through /proc/self/stat, on Windows the
  command line is rewritten in the process environment block.
- Redact credentials from all log records by wrapping the log record
  factory. This also covers the "Parsed arguments" line, which used to write
  the password to the log file with --log DEBUG, and the <username> and
  <password> elements of GMP requests.
- Stop printing the default of the credential options in --help. The default
  may come from the configuration file, which put its password into the help
  output.
- Add --gmp-password-file, --ssh-password-file, --gmp-password-prompt,
  --ssh-password-prompt and the environment variables GVMTOOLS_GMP_PASSWORD
  and GVMTOOLS_SSH_PASSWORD as ways to pass a password that never reaches
  the command line.
@TheBeast85
TheBeast85 requested a review from a team as a code owner August 3, 2026 11:52
@greenbonebot
greenbonebot enabled auto-merge (rebase) August 3, 2026 11:52
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Conventional Commits Report

Type Number
Bug Fixes 1

🚀 Conventional commits found.

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