Auditor recorded output

← All 27 packs

Proven

Validation error echoes the rejected value, which may be the secret itself

securitylow src/argus_scout/config.py:3

The finding

This validator exists to catch a config field that should hold an environment-variable name but instead holds the raw secret. The error message says as much: "put the secret in .env and name it here". In exactly that case, {value!r} copies the full secret (API key, token, password) into the ValueError. Config validation errors usually end up in startup logs, tracebacks, container stdout, or monitoring and event streams. So the check meant to keep secrets out of config ends up leaking them into logs.

    1| """The one config file: every other file scout reads, every service URL, and the schedule.
    2| 
    3| ``scout.yaml`` is validated by :class:`ScoutConfig` (pydantic v2, unknown keys rejected at every level).
    4| Relative paths in it resolve against the config file's own directory, so a config directory can be moved
    5| or mounted anywhere.
    6| 
    7| **Secrets never live in the YAML.** The file names an environment variable (``token_env: SCOUT_API_TOKEN``)
    8| and :func:`resolve_secret` reads it from the process environment. :func:`load_config` first loads a
    9| ``.env`` file beside the config into the environment, without overriding variables that are already set,
   10| so a real environment always wins over the file. Resolved values come back as :class:`~pydantic.SecretStr`
   11| and the config model itself holds only variable *names*, so neither its repr nor its dumps can leak one.
   12| 
   13| **Strict here, forgiving there.** The two kinds of config fail differently, on purpose:
   14| 
   15| - This top-level file is read once at startup, and :func:`load_config` raises :class:`ConfigError` on

The work pack

Recommendation. Do not interpolate the rejected value. Either name only the field, or show a redacted form such as length plus the first 2 characters. Example: raise ValueError("value is not an environment variable name; put the secret in .env and reference it by name here").

Acceptance criteria

  • Address: Validation error echoes the rejected value, which may be the secret itself
  • Keep the change scoped to the cited file/symbols unless impact requires otherwise
  • Do not interpolate the rejected value. Either name only the field, or show a redacted form such as length plus the first 2 characters. Example: raise ValueError("value is not an environment variable name; put the secret in .env and referenc
  • Re-check src/argus_scout/config.py after the fix

Status

  1. claimed
  2. resolved

The fix

e3c421c2fe fix: config errors never echo a rejected value (it may be the secret).

diff --git a/src/argus_scout/config.py b/src/argus_scout/config.pyindex 795a15c..7bf921f 100644--- a/src/argus_scout/config.py+++ b/src/argus_scout/config.py@@ -96,7 +96,8 @@ def _resolve_path(value: Path, info: ValidationInfo) -> Path:  def _check_env_name(value: str) -> str:     if not _ENV_NAME.match(value):-        raise ValueError(f"{value!r} is not an environment variable name; put the secret in .env and name it here")+        # Never echo the value: when it isn't a name it is most likely the secret itself.+        raise ValueError("not an environment variable name; put the secret in .env and name it here")     return value  @@ -161,7 +162,9 @@ Name = Annotated[str, AfterValidator(_check_name)]   class _Section(BaseModel):-    model_config = ConfigDict(extra="forbid", frozen=True)+    # hide_input_in_errors: a rejected value (maybe a secret pasted where its env-var name belongs) never+    # reaches a ValidationError's text, a traceback or a log.+    model_config = ConfigDict(extra="forbid", frozen=True, hide_input_in_errors=True)   # --- sections ----------------------------------------------------------------------------------------------diff --git a/tests/test_config.py b/tests/test_config.pyindex 7a9071c..f17efe3 100644--- a/tests/test_config.py+++ b/tests/test_config.py@@ -13,6 +13,7 @@ from argus_scout.config import (     ScoutConfig,     WebhookSource,     load_config,+    parse_config,     parse_env_file,     resolve_secret, )@@ -193,6 +194,14 @@ def test_secrets_resolve_from_dotenv_and_never_appear(write_file, unset_env, mon         assert SECRET not in text  +def test_a_secret_where_its_env_name_belongs_never_appears_in_the_error():+    with pytest.raises(ConfigError) as caught:+        parse_config({"server": {"token_env": SECRET}})+    assert "server.token_env" in str(caught.value) and "not an environment variable name" in str(caught.value)+    for text in (str(caught.value), str(caught.value.__cause__), repr(caught.value.__cause__)):+        assert SECRET not in text++ def test_parse_env_file(tmp_path):     path = tmp_path / ".env"     path.write_text('A=1\n\n# no\nB = "two words"\nC=plain # trailing comment\nnot a line\n1BAD=x\nD=\n')

How it was judged

Proven 1 test(s) fail on dev and pass with the fix: tests/test_config.py::test_a_secret_where_its_env_name_belongs_never_appears_in_the_error

Judged 24 Nov 2026, 04:49 UTC against dev at d0c0f66.

Teston devdev + patch
tests/test_config.py::test_a_secret_where_its_env_name_belongs_never_appears_in_the_errorfailedpassed
The other 14 tests in the run (14 with the same result on both trees)
tests/test_config.py::test_check_config_checks_named_filespassedpassed
tests/test_config.py::test_check_config_fails_on_missing_or_bad_filepassedpassed
tests/test_config.py::test_check_config_rejects_invalidpassedpassed
tests/test_config.py::test_config_is_immutablepassedpassed
tests/test_config.py::test_empty_config_is_all_defaultspassedpassed
tests/test_config.py::test_entries_commented_out_at_any_depth_read_as_emptypassedpassed
tests/test_config.py::test_full_configpassedpassed
tests/test_config.py::test_init_into_directory_then_checkpassedpassed
tests/test_config.py::test_init_writes_refuses_and_forcespassedpassed
tests/test_config.py::test_missing_config_raisespassedpassed
tests/test_config.py::test_parse_env_filepassedpassed
tests/test_config.py::test_secrets_resolve_from_dotenv_and_never_appearpassedpassed
tests/test_config.py::test_serve_refuses_invalid_configpassedpassed
tests/test_config.py::test_starter_loads_with_defaultspassedpassed