Skip to content

Commit 5816589

Browse files
mmckyclaude
andauthored
security: gate the \translate-resync trigger on commenter trust (all 3 languages) (#586)
The issue_comment clause checked only that the comment body contained the magic string. issue_comment workflows run in default-branch context with full access to secrets, so on a public repo any GitHub account could comment \translate-resync on a merged PR and spend Anthropic credits and runner minutes, repeatedly. The clause now also requires the comment to be on a pull request (plain issues raise the same event) and its author to be an OWNER, MEMBER or COLLABORATOR. Adds permissions: contents: read — the action authenticates with QUANTECON_SERVICES_PAT, so the ambient GITHUB_TOKEN never needs write. Applied identically to the zh-cn, fa and fr sync workflows. Ports the shape from QuantEcon/action-translation#192. Triggers, paths filters, inputs and the @v0 pin are unchanged. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 21299db commit 5816589

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

.github/workflows/sync-translations-fa.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,22 @@ on:
1414

1515
jobs:
1616
sync:
17+
# The issue_comment path requires all three: a comment on a PR (not a bare
18+
# issue), the command, and a trusted author — otherwise any account could
19+
# fire a secrets-bearing run (Anthropic spend plus the PAT) from any comment.
1720
if: >
1821
(github.event_name == 'pull_request' && github.event.pull_request.merged == true) ||
19-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '\translate-resync'))
22+
(github.event_name == 'issue_comment' &&
23+
github.event.issue.pull_request &&
24+
contains(github.event.comment.body, '\translate-resync') &&
25+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
2026
runs-on: ubuntu-latest
2127

28+
# The action authenticates with QUANTECON_SERVICES_PAT; the ambient
29+
# GITHUB_TOKEN is unused beyond checkout, so keep it read-only.
30+
permissions:
31+
contents: read
32+
2233
steps:
2334
- uses: actions/checkout@v7
2435
with:

.github/workflows/sync-translations-fr.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,22 @@ on:
1414

1515
jobs:
1616
sync:
17+
# The issue_comment path requires all three: a comment on a PR (not a bare
18+
# issue), the command, and a trusted author — otherwise any account could
19+
# fire a secrets-bearing run (Anthropic spend plus the PAT) from any comment.
1720
if: >
1821
(github.event_name == 'pull_request' && github.event.pull_request.merged == true) ||
19-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '\translate-resync'))
22+
(github.event_name == 'issue_comment' &&
23+
github.event.issue.pull_request &&
24+
contains(github.event.comment.body, '\translate-resync') &&
25+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
2026
runs-on: ubuntu-latest
2127

28+
# The action authenticates with QUANTECON_SERVICES_PAT; the ambient
29+
# GITHUB_TOKEN is unused beyond checkout, so keep it read-only.
30+
permissions:
31+
contents: read
32+
2233
steps:
2334
- uses: actions/checkout@v7
2435
with:

.github/workflows/sync-translations-zh-cn.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,22 @@ on:
1414

1515
jobs:
1616
sync:
17+
# The issue_comment path requires all three: a comment on a PR (not a bare
18+
# issue), the command, and a trusted author — otherwise any account could
19+
# fire a secrets-bearing run (Anthropic spend plus the PAT) from any comment.
1720
if: >
1821
(github.event_name == 'pull_request' && github.event.pull_request.merged == true) ||
19-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '\translate-resync'))
22+
(github.event_name == 'issue_comment' &&
23+
github.event.issue.pull_request &&
24+
contains(github.event.comment.body, '\translate-resync') &&
25+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
2026
runs-on: ubuntu-latest
2127

28+
# The action authenticates with QUANTECON_SERVICES_PAT; the ambient
29+
# GITHUB_TOKEN is unused beyond checkout, so keep it read-only.
30+
permissions:
31+
contents: read
32+
2233
steps:
2334
- uses: actions/checkout@v7
2435
with:

0 commit comments

Comments
 (0)