You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(security): redact credentials from debug log output (#61)
nvbug 6025253
## Summary
- \`_req()\` logged full request/response bodies at \`debug\` level with
no redaction. With \`RUST_LOG=libredfish=debug\` enabled, plaintext
passwords were emitted to any log aggregation pipeline (Splunk, ELK,
Kubernetes pod logs, etc.)
- Add \`redact_sensitive_fields()\` — applies a once-compiled static
regex before the body reaches \`debug!()\`, replacing credential values
with \`[REDACTED]\` while preserving key names and all non-sensitive
fields
- Fix response log sites to redact **before** truncating — truncating
first could split a value string before its closing \`"\`, breaking the
regex match and leaking a password prefix
## Fields redacted
| Key | Operation |
|---|---|
| \`Password\` | \`create_user\`, \`change_password\`,
\`change_password_by_id\` |
| \`OldPassword\`, \`NewPassword\` | \`change_bios_password\`, HPE UEFI
password ops |
| \`CurrentUefiPassword\`, \`UefiPassword\` | NVIDIA DPU
\`Bios/Settings\` PATCH |
| \`ImportBuffer\` | Dell \`ImportSystemConfiguration\` fallback (XML
blob containing \`OldSetupPassword\`) |
## Design notes
- **Wire payload is never modified** — only the string passed to
\`debug!()\` is affected
- **Zero-cost fast path** — \`Cow::Borrowed\` returned unchanged when no
sensitive key is present (two \`str::contains\` checks, no regex)
- **Static regex** — compiled once via \`OnceLock\`, not on every
request
## Test plan
- [ ] \`cargo test network::tests\` — 10 unit tests covering each
redacted field, the fast path, wire-payload immutability, escaped
characters, and the truncation-ordering fix
- [ ] \`cargo test\` — full suite passes (12 integration tests)
---------
Signed-off-by: Martin Raumann <mraumann@nvidia.com>
assert!(!redacted.contains("old123"),"OldPassword value must be redacted");
835
+
assert!(!redacted.contains("new456"),"NewPassword value must be redacted");
836
+
// PasswordName is a slot name, not a secret — must NOT be redacted.
837
+
assert!(redacted.contains("AdministratorPassword"),"PasswordName value must not be redacted");
838
+
}
839
+
840
+
#[test]
841
+
fnnvidia_dpu_uefi_password_fields_are_redacted(){
842
+
let body = r#"{"Attributes":{"CurrentUefiPassword":"old_secret","UefiPassword":"new_secret"}}"#;
843
+
let redacted = redact_sensitive_fields(body);
844
+
assert!(!redacted.contains("old_secret"),"CurrentUefiPassword value must be redacted");
845
+
assert!(!redacted.contains("new_secret"),"UefiPassword value must be redacted");
846
+
assert!(redacted.contains("CurrentUefiPassword"),"key name must be preserved");
847
+
}
763
848
764
-
let big = "a".repeat(2000);
765
-
assert_eq!(truncate(&big,1500).len(),1500);
849
+
#[test]
850
+
fndell_import_buffer_xml_blob_is_redacted(){
851
+
let xml = r#"<SystemConfiguration><Component FQDD="BIOS.Setup.1-1"><Attribute Name="OldSetupPassword">my_uefi_pass</Attribute><Attribute Name="NewSetupPassword"></Attribute></Component></SystemConfiguration>"#;
0 commit comments