Skip to content

[fix] Redact secret value from validation error messages#917

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
akim.sadaoui/fix-secrets-validation-error-leak
May 29, 2026
Merged

[fix] Redact secret value from validation error messages#917
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
akim.sadaoui/fix-secrets-validation-error-leak

Conversation

@MikaYuoadas
Copy link
Copy Markdown
Contributor

What

Validation error messages stored in the SARIF output could include the secret being validated:

  • HttpError messages from reqwest include the full validation URL, which may contain the secret as a query parameter.
  • UnknownResponseType messages included body_prefix (first bytes of the response body), which may echo the secret back from the validation endpoint.

Why

Logging these messages verbatim leaks the secret. Even outside of logs, the messages end up in the SARIF datadogSecretValidationErrors property, which downstream consumers may log or store.

How

Added a redact_secret(message, secret) helper that replaces the matched secret value with [REDACTED]. The SecretValidationStatus::from(status, secret) constructor now takes the matched value (already available via match_value on RuleMatch) and applies redaction to both error message types before storing them.

Copilot AI review requested due to automatic review settings May 29, 2026 09:56
@MikaYuoadas MikaYuoadas requested a review from a team as a code owner May 29, 2026 09:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Redacts secret values from validation error messages stored in SARIF output, preventing leakage via HttpError URLs or UnknownResponseType body prefixes.

Changes:

  • Replaced From<&MatchStatus> impl with SecretValidationStatus::from(status, match_value) taking the matched secret.
  • Added redact_secret helper applied to HttpError.message and UnknownResponseType.body_prefix.
  • Updated caller in scanner.rs to pass sds_match.match_value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/secrets/src/model/secret_result.rs Adds redaction helper and threads match_value into validation status conversion.
crates/secrets/src/scanner.rs Passes the matched secret value to the new constructor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@datadog-prod-us1-4
Copy link
Copy Markdown

datadog-prod-us1-4 Bot commented May 29, 2026

🎯 Code Coverage (details)
Patch Coverage: 68.97%
Overall Coverage: 85.44% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 64c0f4c | Docs | Datadog PR Page | Give us feedback!

Validation error messages could include the secret being validated:

- HttpError messages from reqwest include the full validation URL, which
  may contain the secret as a query parameter.
- UnknownResponseType messages included body_prefix, which may echo the
  secret back from the validation endpoint response.

Replace the matched secret value with [REDACTED] in both error message types.
@MikaYuoadas MikaYuoadas force-pushed the akim.sadaoui/fix-secrets-validation-error-leak branch from 80bb09e to 64c0f4c Compare May 29, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants