Skip to content

ci: harden GitHub Actions against supply chain attacks#4607

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
ci/harden-gha-supply-chain
Mar 26, 2026
Merged

ci: harden GitHub Actions against supply chain attacks#4607
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
mainfrom
ci/harden-gha-supply-chain

Conversation

@kakkoyun

Copy link
Copy Markdown
Member

What does this PR do?

Adds persist-credentials: false to all 56 actions/checkout steps across 22 workflow files and the test-apps.cue CUE template (which regenerates test-apps.yml). Also adds explicit permissions: blocks to 6 workflows that were inheriting repo defaults, and fixes two stale/missing version comments.

Motivation

actions/checkout defaults to persist-credentials: true, which stores GITHUB_TOKEN in .git/config as http.https://github.com/.extraheader for the lifetime of the job. Any subsequent step — including third-party actions — can read that credential and use it to push code, create releases, or access private repos. This is the primary vector used in the tj-actions/changed-files supply chain attack.

Setting persist-credentials: false eliminates this residual credential exposure. The one workflow that performs a git push (sync-cue-actions.yml) now injects credentials via git remote set-url scoped only to that step.

Reviewer's Checklist

  • New code is free of linting errors. You can check this by running make lint locally.
  • All generated files are up to date (test-apps.yml regenerated from test-apps.cue).
  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Add `persist-credentials: false` to all 56 actions/checkout steps across
22 workflow files and the test-apps.cue template (regenerated test-apps.yml).
This prevents GITHUB_TOKEN from being stored in .git/config after checkout,
eliminating the primary vector used in supply chain attacks like the
tj-actions/changed-files incident.

sync-cue-actions.yml still performs a git push; it now injects credentials
via `git remote set-url` scoped only to that step rather than persisting
them for all subsequent steps.

Also add explicit `permissions:` blocks to 6 workflows that were inheriting
repo defaults, and fix two stale/missing version comments on checkout steps.
@kakkoyun
kakkoyun requested a review from darccio March 26, 2026 11:26
@kakkoyun
kakkoyun marked this pull request as ready for review March 26, 2026 11:26
@kakkoyun
kakkoyun requested review from a team as code owners March 26, 2026 11:26
Add inline // vX.Y.Z comments to the three pinned action uses: lines in
test-apps.cue. The Makefile generation step now post-processes cue export
output with a Python one-liner that reads those comments and appends them
as # vX.Y.Z annotations in the generated YAML, matching the convention
used in all handwritten workflow files.

Extend sync-cue-actions.yml to also extract the version comment from
Dependabot's test-apps.yml update and sync it back into the test-apps.cue
comment, so the annotation stays correct after each Dependabot bump.
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Mar 26, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.04% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 868ecd2 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter

pr-commenter Bot commented Mar 26, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-26 12:23:00

Comparing candidate commit 868ecd2 in PR branch ci/harden-gha-supply-chain with baseline commit ee1fdc0 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 218 metrics, 6 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.71%. Comparing base (ee1fdc0) to head (868ecd2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

see 265 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The previous sed used an address pattern /${action}@/ to scope the
substitution, but action names like actions/checkout contain literal
slashes that break both GNU and BSD sed's address parsing. Replace it
with an inline match in the substitute expression using | as delimiter,
which handles slashes in action names correctly.

Verified with a local Dependabot simulation: SHA and version comment
in test-apps.cue both update correctly after a Dependabot bump.
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