The vulnerability is a result of insufficient logging controls in the hermes command-line interface. The root cause is in the main function within src/hermes/commands/cli.py. The commit 7f64f102e916c76dc44404b77ab2a80f5a4e59b1 introduced a debug logging statement that captures and records all command-line arguments passed to the hermes application. When a user provides sensitive information, such as an API token, via the -O option (e.g., hermes deposit -O invenio_rdm.auth_token SECRET), this sensitive data is included in the args object and subsequently written to the log file in clear text. This exposes the secret to anyone with access to the log files.
The patch, provided in commit 90cb86acd026e7841f2539ae7a1b284a7f263514, mitigates this vulnerability by introducing a new function, mask_options_values, in src/hermes/utils.py. This function specifically targets the values associated with the -O options and redacts them. The logging statement in the main function was updated to use this new function, ensuring that sensitive data is masked before being logged. Therefore, the main function is the primary vulnerable function, as it is responsible for processing and logging the potentially malicious input.