Fix dd-octo-sts trust policy for create-draft-release workflow#8356
Conversation
The `create_normal_draft_release` workflow was failing at the
"Get GitHub Token via dd-octo-sts" step with:
subject_pattern "repo:DataDog/dd-trace-dotnet:environment:publish-debug-symbols-env"
did not match "repo:DataDog/dd-trace-dotnet:ref:refs/heads/(master|hotfix/.+)"
The root cause is that the `_create_draft_release.yml` reusable workflow
specifies `environment: publish-debug-symbols-env` on the job (line 42),
which is required to access environment-scoped secrets for publishing
debug symbols. When a GitHub Actions job uses an environment, the OIDC
token's `sub` claim uses the format
`repo:{owner}/{repo}:environment:{env}` instead of
`repo:{owner}/{repo}:ref:{ref}`. The trust policy's `subject_pattern`
was matching against the ref-based format, so it never matched.
This fix:
- Changes `subject_pattern` to an exact `subject` match on the
environment-based subject (more secure than a pattern)
- Adds `environment: publish-debug-symbols-env` to `claim_pattern`
for defense in depth
- Retains `ref` and `job_workflow_ref` claim patterns to continue
enforcing the branch restriction (master|hotfix/*) via claims
See failed run: https://github.com/DataDog/dd-trace-dotnet/actions/runs/23446312090/job/68210958105
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
ah, very curious. I see that the environment is set on the workflow call. Totally missed that before, but the fix here seems good.
I cannot comment on the -f why that is desired. But the rest looks good to me!
Took the extra moment to test the changes on this branch:
❯ DDOCTOSTS_ID_TOKEN='{"actor":"zacharycmontoya","actor_id":"13769665","aud":"dd-octo-sts","base_ref":"","check_run_id":"68210958105","enterprise":"datadog-inc","enterprise_id":"42","environment":"publish-debug-symbols-env","environment_node_id":"EN_kwDOBhLL288AAAACVOYJxQ","event_name":"workflow_dispatch","exp":1974281238,"head_ref":"","iat":1774280938,"iss":"https://token.actions.githubusercontent.com","job_workflow_ref":"DataDog/dd-trace-dotnet/.github/workflows/_create_draft_release.yml@refs/heads/master","job_workflow_sha":"6f4edac7a7e43fac17e0450d4d25d96e0dbfde05","jti":"c58aadaf-9d8b-4320-9965-12c17629d100","nbf":1774280638,"ref":"refs/heads/master","ref_protected":"true","ref_type":"branch","repository":"DataDog/dd-trace-dotnet","repository_id":"101895131","repository_owner":"DataDog","repository_owner_id":"365230","repository_visibility":"public","run_attempt":"1","run_id":"23446312090","run_number":"7","runner_environment":"github-hosted","sha":"6f4edac7a7e43fac17e0450d4d25d96e0dbfde05","sub":"repo:DataDog/dd-trace-dotnet:environment:publish-debug-symbols-env","workflow":"Create normal draft release","workflow_ref":"DataDog/dd-trace-dotnet/.github/workflows/create_normal_draft_release.yml@refs/heads/master","workflow_sha":"6f4edac7a7e43fac17e0450d4d25d96e0dbfde05"}' \
dd-octo-sts check -s DataDog/dd-trace-dotnet -p self.github.create-draft-release
🔍 Checking repository and policy location...
Assuming repository path "/Users/christoph.hamsen/go/src/github.com/DataDog/dd-trace-dotnet"
Tip: Use --repo/-r to override.
✅ Policy is in a valid location.
Location: .github/chainguard/self.github.create-draft-release.sts.yaml
🔍 Checking policy file...
✅ Policy is valid
Permissions:
- actions: read
- contents: write
- issues: write
- statuses: read
🔍 Checking token...
⚠️ Fabricating a token out of claims.
This token will not work in production, but is suitable for testing.
✅ Supplied token is valid for policy
Matching claims:
- job_workflow_ref: DataDog/dd-trace-dotnet/.github/workflows/_create_draft_release.yml@refs/heads/master
- ref: refs/heads/master
- repository: DataDog/dd-trace-dotnet
- environment: publish-debug-symbols-env
- event_name: workflow_dispatch
looks good! :)
BenchmarksBenchmark execution time: 2026-03-23 19:11:31 Comparing candidate commit 38b4c6c in PR branch Found 9 performance improvements and 5 performance regressions! Performance is the same for 257 metrics, 17 unstable metrics.
|
Summary of changes
Fix the
dd-octo-ststrust policy that blocked the releaseReason for change
The
create_normal_draft_releaseworkflow was failing at the "Get GitHub Token via dd-octo-sts" step with:See failed run: https://github.com/DataDog/dd-trace-dotnet/actions/runs/23446312090/job/68210958105
Implementation details
The root cause is that the
_create_draft_release.ymlreusable workflow specifiesenvironment: publish-debug-symbols-envon the job, which is required to access environment-scoped secrets for publishing debug symbols. When a GitHub Actions job uses an environment, the OIDC token'ssubclaim uses the format:repo:{owner}/{repo}:environment:{env}repo:{owner}/{repo}:ref:{ref}.The trust policy's
subject_patternwas matching against the ref-based format, so it never matched.This fix:
subject_patternto an exactsubjectmatch on the environment-based subject (more secure than a pattern)environment: publish-debug-symbols-envtoclaim_patternfor defense in depthrefandjob_workflow_refclaim patterns to continue enforcing the branch restriction(master|hotfix/*)via claimsAdditionally, make sure the AAS trigger job if the
curlfails (by adding-f)Test coverage
I wish... we'll see how it goes next time
Other details
Need to make a fix on the AAS side too... incoming