fix(config): do not echo secrets when setting config values [full-ci] - #41780
Merged
Conversation
config:system:set and config:app:set printed the value that had just been written back to stdout, so every secret configured through occ ended up in the terminal scrollback, the container log or the CI log of whoever ran the command. Both commands now print a placeholder instead of the value when the config key holds a secret. Recognition reuses the existing list of sensitive keys in OC\SystemConfig through the new isSensitiveKey(), and falls back to matching the key name against the patterns credential, key, passwd, password, pwd, salt, secret and token. That fallback covers the keys of apps, which core does not know, such as wopi.token.key or jwt_secret. Boolean values keep being shown, as they cannot hold a secret. Only the confirmation output changed, the stored value is written as before. Fixes #41779 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
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.
Description
config:system:setandconfig:app:setechoed the value they had just writtenback to stdout, so every secret configured through
occended up in the terminalscrollback, the container log or the CI log of whoever ran the command.
Both commands now print
***REMOVED SENSITIVE VALUE***instead of the value whenthe config key holds a secret:
Only the confirmation output changed — the stored value is written as before.
How a key is recognised as sensitive
The existing list of sensitive keys in
OC\SystemConfig::$sensitiveValuesstaysthe single source of truth and is now reachable through a new
SystemConfig::isSensitiveKey(array $keys), which walks the very same nestedlist that
getFilteredValue()uses — including the repeating-0convention, solog.conditions 3 shared_secretis matched.That list alone does not cover the two keys from the issue:
wopi.token.keyisnot on it, and app config is not covered by
SystemConfigat all. A name-patternfallback in the command layer (
credential,key,passwd,password,pwd,salt,secret,token, matched case insensitively) therefore catches the keysof apps, which core cannot know in advance.
IConfig::getFilteredSystemValue()was deliberately left untouched: it is publicAPI, and adding pattern matching there could hand apps a placeholder where they
expect a real value.
Two judgement calls worth a look
nullare never masked. They cannot hold a secret, andmasking them broke useful feedback on real keys such as
token_auth_enforcedand
grace_period.demo_key.show_popup. Integers and doubles are masked,because a numeric secret is possible.
lost_password_linkandgrace_period.demo_key.linkare string keys matching*password*/*key*,so their URLs now print masked. Left as is — a URL can embed a token, so this
errs on the safe side.
Related Issue
Motivation and Context
This is how WOPI signing keys and ONLYOFFICE JWT secrets leak out of Docker
deployments that configure them from a startup hook — see
owncloud-docker/base#545 for a real-world log. The confirmation line does not
need the value to be useful.
The only workaround so far was Symfony's global
-q, which is easy to miss andalso hides the genuine feedback.
How Has This Been Tested?
while master is 11.0.0, so the PHPUnit bootstrap aborts with "Upgrade is
required" — the unit and acceptance suites were not run locally and are left
to CI. Verification was done by driving the real command classes through a
real Symfony console with stubbed config backends:
stored values are still verbatim (
Pc7rTwpsnKfT3NfpvbChTPMxVfMr9X7t/VmNz3qhMWjsxnw4rMPpFxnM7C9hg9Xw).secret is absent from the output and that the placeholder is present.
isSensitiveKey()(list keys, nested keys,parents, numeric string path segments as the console passes them) and the name
patterns.
castValue()expectations are byte-identical,so the added third parameter is backwards compatible.
con/conkey,empty string) are unchanged, so no existing scenario needed rewriting.php-cs-fixerreports 0 of 20 touched files needing changes.phpstancouldnot be installed locally (composer cannot authenticate against github.com in
this environment), so it is left to CI.
Types of changes
Checklist:
🤖 Generated with Claude Code