security(homecore-migrate): redact secret value from malformed secrets.yaml error#1089
Merged
Conversation
…l error (secret-leak)
`read_secrets` wrapped serde_yaml's parse error into `MigrateError::YamlParse {
source }`. serde_yaml's message for a typed-tag coercion failure embeds the
offending scalar verbatim, e.g. `invalid value: string "<the-secret-value>"`.
That error propagates out of `read_secrets`, is `?`-returned by the
`InspectSecrets` CLI path in main.rs, and printed to stderr by anyhow — leaking
a secret value despite the CLI's deliberate `<redacted>` design.
Fix: secrets.yaml parse failures now map to a new redacting variant
`MigrateError::SecretsParse { path, line, column }` that carries only the file
path and a coarse location (from `serde_yaml::Error::location()`), never the
scalar content. Other (non-secret) YAML files keep `YamlParse`.
Pinned by `secrets::tests::malformed_secrets_error_never_contains_secret_value`
(asserts the rendered error AND its full #[source] chain never contain the
secret value; fails on the old `YamlParse` path) plus
`malformed_secrets_error_reports_location` (still fail-closed + locatable).
ADR-165 secret-handling rule: a secret value must never appear in output.
Co-Authored-By: claude-flow <ruv@ruv.net>
Note the secrets.yaml error-redaction fix and the review's clean dimensions (read-only source / no traversal / no panic / fail-closed versioning / no injection) in ADR-165 §2.4, bump the test-evidence count 19→21 in §2.6, and add an [Unreleased] Security entry to CHANGELOG. Co-Authored-By: claude-flow <ruv@ruv.net>
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.
homecore-migrate security review (ADR-165) — completes the HOMECORE / HA stack sweep
Final crate in the Home-Assistant compatibility stack review (core · api · automation · recorder · assist · migrate).
One real finding — secret-leak (Grade A)
A malformed
secrets.yamlwhose offending scalar fails a typed-tag coercion (e.g.port: !!int <value>) produced aserde_yamlerror that embeds the scalar verbatim —invalid value: string "<the-secret-value>". Wrapped intoMigrateError::YamlParse, it propagated out ofread_secrets, was?-returned by theInspectSecretsCLI path, and printed to stderr by anyhow — leaking a secret value despite the CLI's deliberate<redacted>design (which only ever prints keys).Fix:
secrets.yamlparse failures map to a dedicated redacting variantMigrateError::SecretsParse { path, line, column }— file path + coarseserde_yaml::Error::location()only, never the scalar. Other (non-secret) YAML keepsYamlParse.Pinned by
secrets::tests::malformed_secrets_error_never_contains_secret_value— asserts the rendered error and its full#[source]chain never contain the value and that it is still the structuredSecretsParse(fail-closed). Observed leak on old code:... invalid value: string "s3cr3t_TOKEN_VALUE" ...; passes on the fix. Plusmalformed_secrets_error_reports_location(still locatable).Dimensions confirmed clean (with evidence)
main.rsprints keys as<key> = <redacted>;MissingField/Iopaths surface the path, never content.fs::write/fs::remove/fs::create/File::create/OpenOptionsanywhere in the crate; P1 reads source and writes nothing. Re-runs idempotent; HA source never touched.../absolute escape.!inputblueprint tags, deep nesting, anchors: every malformed input errors, never panics. Allunwrap/expectare#[cfg(test)].minor_versionhard-errors.Validation
cargo test -p homecore-migrate --no-default-features→ 21 passed, 0 failed (+2 pins, 19→21)cargo test --workspace --no-default-features→ GREEN (exit 0, no failures)python archive/v1/data/proof/verify.py→ VERDICT: PASS, hashf8e76f21…46f7aunchanged (off the signal proof path)🤖 Generated with claude-flow