Skip to content

v2.16.4

Latest

Choose a tag to compare

@hramezani hramezani released this 03 Dec 10:41
Immutable release. Only release title and notes can be modified.

Highlights

This patch release hardens how the secrets sources read files from secrets_dir, and fixes several cases where a lower-priority source, or input that should have been rejected, could set a value in the CLI source, CliApp and the GCP Secret Manager source. These issues were reported by Anthropic's OSS Scanner.

Hardening

  • The secrets sources read exactly the file they checked (#1189). SecretsSettingsSource and NestedSecretsSettingsSource checked that a secret file stays inside secrets_dir on one path but then read another, so in some cases a file outside secrets_dir could still be loaded despite the fixes in 2.14.2 and 2.16.3. Paths are now resolved strictly and the resolved path is read; on POSIX, files are opened below secrets_dir without following symlinks.
  • secrets_dir_max_size is enforced on the bytes actually read by NestedSecretsSettingsSource (#1189). The limit was only checked in an earlier pass, so a file that grew after that check was read whole.
  • The nested secrets walk is bounded (#1189). Hidden entries now count toward the 10,000-entry limit, and link chains longer than the OS follows are skipped, so a crafted tree can no longer stall loading.
  • CliApp.run honors hide_input_in_errors on pydantic dataclasses (#1185). Validation errors showed the rejected input, which could include secrets.
  • A nested AliasPath CLI option can no longer set sibling fields (#1185). The option's value is now required to be a single JSON value.

Behavior changes

  • An explicit empty CLI argument (--x '' or --x=) is kept as an empty value when env_ignore_empty=True, instead of falling back to the environment or the default (#1185). For a non-string field this now fails validation.
  • A value for a nested AliasPath-only CLI option that isn't a single JSON value raises SettingsError (#1185).
  • With case_sensitive=False, the GCP Secret Manager source uses an exactly named secret over its case variants, as documented. The mapping also lists each secret once, under its lower-cased name (#1186).
  • Settings(_env_prefix=...), _case_sensitive, _env_nested_delimiter, _env_prefix_target and _env_nested_max_split now apply to NestedSecretsSettingsSource, as they already did to SecretsSettingsSource (#1189).
  • In SecretsSettingsSource, a broken or unresolvable link now warns that it "could not be resolved" instead of raising AssertionError, and a link pointing outside secrets_dir warns that it "resolves outside" it. Hidden entries count toward NestedSecretsSettingsSource's 10,000-entry limit (#1189).

Bug fixes

CLI

  • CliApp.run with a plain model or dataclass no longer lets environment, dotenv or secrets values override a CLI or init value that equals a nested default (#1185).

GCP Secret Manager

  • With case_sensitive=False and env_nested_delimiter, a differently cased secret no longer overrides the exactly named one for nested fields (#1186).
  • A secret that is listed but can't be read is treated as unset for nested fields, as it already was for top-level ones, instead of setting the field to None. A listed secret with no latest version no longer makes Settings() fail with KeyError in case-sensitive mode (#1188).

Secrets

  • NestedSecretsSettingsSource reads secret files named with the prefix passed to Settings() (#1189).

Credits

Reported by Anthropic's OSS Scanner (ANT-2026-03GATVJT, ANT-2026-KXOQMCIZ, ANT-2026-QBDWOPPZ, ANT-2026-Q9SXL4RQ, ANT-2026-J8TUO8VX, ANT-2026-KEND8WE6, ANT-2026-AR6U1329, ANT-2026-0SIM76GZ, ANT-2026-KCDOIFJQ, ANT-2026-WTKAUT7V, ANT-2026-1HJFYVIH).

All changes

What's Changed

  • Fix CLI source and CliApp precedence and input handling issues by @hramezani in #1185
  • Prefer exact GCP secret names in case-insensitive lookups by @hramezani in #1186
  • Skip unreadable GCP secrets when loading nested fields by @hramezani in #1188
  • Harden secrets directory loading by @hramezani in #1189

Full Changelog: v2.16.3...v2.16.4