Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/add-asset-to-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ on:
workflow_dispatch:
inputs:
packagesUrl:
description: 'URL for `packages.tar.gz` to add to release'
description: "URL for `packages.tar.gz` to add to release"
required: true
releaseVersion:
description: 'Version to add the assets to'
description: "Version to add the assets to"
required: true

jobs:
add-assets-to-release:
runs-on: ubuntu-8-core-latest
permissions:
contents: write
id-token: write
steps:
- name: Get GitHub Token via dd-octo-sts
id: generate-token
uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4
with:
scope: DataDog/dd-trace-php
policy: self.add-asset-to-gh-release

- run: |
curl -L -o packages.tar.gz $PACKAGES_URL
tar -xvzf packages.tar.gz
Expand All @@ -22,4 +32,4 @@ jobs:
env:
PACKAGES_URL: ${{ inputs.packagesUrl }}
RELEASE: ${{ inputs.releaseVersion }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
12 changes: 10 additions & 2 deletions .github/workflows/auto_add_pr_to_miletone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ jobs:
contents: read
pull-requests: write # need to modify existing PR
issues: write # need to potentially create a new milestone
id-token: write

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: '7.0.101'
dotnet-version: "7.0.101"

- name: Get GitHub Token via dd-octo-sts
id: generate-token
uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4
with:
scope: DataDog/dd-trace-php
policy: self.auto-add-pr-to-milestone

- name: "Assign to vNext Milestone"
run: ./github-actions-helpers/build.sh AssignPullRequestToMilestone
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
PullRequestNumber: "${{ github.event.pull_request.number }}"
12 changes: 10 additions & 2 deletions .github/workflows/auto_check_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
permissions:
contents: read
pull-requests: write # need to add a comment to a PR
id-token: write

steps:
- name: Checkout
Expand All @@ -18,11 +19,18 @@ jobs:

- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: '7.0.101'
dotnet-version: "7.0.101"

- name: Get GitHub Token via dd-octo-sts
id: generate-token
uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4
with:
scope: DataDog/dd-trace-php
policy: self.auto-check-snapshots

- name: "Check Snapshots"
run: ./github-actions-helpers/build.sh SummaryOfSnapshotChanges
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
PullRequestNumber: "${{ github.event.pull_request.number }}"
TargetBranch: "${{ github.base_ref }}"
15 changes: 11 additions & 4 deletions .github/workflows/auto_label_prs.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
name: Label PRs

on:
- pull_request
- pull_request

jobs:
add-labels:

runs-on: ubuntu-24.04
permissions:
contents: read
issues: write # Update labels on PRs (might not be necessary, but we call the UpdateIssue API so...)
pull-requests: write # Update labels on PRs
id-token: write

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: '7.0.101'
dotnet-version: "7.0.101"

- name: Get GitHub Token via dd-octo-sts
id: generate-token
uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4
with:
scope: DataDog/dd-trace-php
policy: self.auto-label-prs
Comment on lines +23 to +28
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict STS token minting on pull_request workflows

This workflow now mints a write-scoped STS token during pull_request runs and then hands it to code from the checked-out PR (./github-actions-helpers/build.sh), which means forked PRs can execute attacker-controlled code with stronger permissions than the default fork token model. With secrets.GITHUB_TOKEN, fork PRs are read-only by default, but self.auto-label-prs grants issues: write and pull_requests: write, so a malicious fork can exfiltrate or abuse that token to mutate PR metadata in the base repo; the same pattern also appears in auto_check_snapshots.yml.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

@lloeki lloeki May 13, 2026

Choose a reason for hiding this comment

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

Good callout.

@bwoebi the problem here seems to be the need to checkout, which makes it depend on untrusted repo code that could leverage the token for mischief.

Contrast with this one which doesn't clone: https://github.com/DataDog/dd-trace-rb/blob/master/.github/workflows/pull-request-labeler.yml

That said, this is moot if external contributor PRs don't run this CI workflow (which I think it doesn't?)


- name: "Add labels"
run: ./github-actions-helpers/build.sh AssignLabelsToPullRequest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
PullRequestNumber: "${{ github.event.pull_request.number }}"
Loading