Skip to content

[INC-56036] avoid stack overflow in secrets scanner by splitting scan and validate#921

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
akim.sadaoui/incident-56036/fix-stack-overflow
Jun 16, 2026
Merged

[INC-56036] avoid stack overflow in secrets scanner by splitting scan and validate#921
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
akim.sadaoui/incident-56036/fix-stack-overflow

Conversation

@MikaYuoadas

Copy link
Copy Markdown
Contributor

Summary

Scanner::scan_with_options(validate_matches=true) (introduced in f51ffceb [SDS] Implement SDS supporting rules) triggers a stack overflow inside dd-sds when scanning very large monorepos. In prod, code-workload-runner-secrets has been crashing ~40-75k tasks/day on Datadog dogfood orgs since the v0.8.5 cut on 2026-05-29.

Switch find_secrets back to the pre-v0.8.5 pattern: scan() to collect matches, then validate_matches() as a separate step (which uses the bounded rayon thread pool internally).

The two paths are equivalent for plain validators. They differ for the new is_supporting_rule HTTP match-pairing feature: cross-rule template-variable resolution (a supporting rule's match feeding $PARAM placeholders in a primary rule's validator URL) only fires inside scan_with_options. The corresponding test is marked #[ignore] until the underlying recursion is fixed upstream in dd-sds.

Incident: https://app.datadoghq.com/incidents/56036

Test plan

  • cargo test --workspace — 487 passed, 2 ignored.
  • Reproduced the crash on the full dd-source monorepo with the staging configuration before the fix (fatal runtime error: stack overflow, aborting).
  • After the fix, full dd-source scan (894k files) completes in ~140s with identical results to the pre-regression v0.8.4 baseline (515 files with secrets, 1020 total).

`Scanner::scan_with_options(validate_matches=true)` overflows the stack
inside dd-sds on large inputs. Switch `find_secrets` back to `scan()`
followed by a separate `validate_matches()` call until the recursion is
fixed upstream.

Refs: incident-56036
Copilot AI review requested due to automatic review settings June 16, 2026 15:34
@MikaYuoadas
MikaYuoadas requested a review from a team as a code owner June 16, 2026 15:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR mitigates dd-sds stack overflows encountered when scanning very large repositories by changing the secrets scanning flow in crates/secrets to decouple match collection from validation.

Changes:

  • Replace Scanner::scan_with_options(validate_matches=true) with Scanner::scan() followed by an explicit Scanner::validate_matches() call (when validation is enabled).
  • Mark the supporting-rule match-pairing test as ignored, documenting the known regression until dd-sds is patched upstream.

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

@MikaYuoadas
MikaYuoadas requested a review from a team June 16, 2026 16:07

@isabella-garza-datadog isabella-garza-datadog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM as a short term fix while we work on resolving the root cause in dd-sds

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.

4 participants