Skip to content

Commit 9a7f9f7

Browse files
committed
fix: restrict Claude workflow to trusted actors
Add author_association checks to prevent untrusted users from triggering @claude with write permissions. Only OWNER, MEMBER, and COLLABORATOR can now invoke the on-demand Claude workflow.
1 parent 7dc6b04 commit 9a7f9f7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/claude.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ on:
1212

1313
jobs:
1414
claude:
15+
# Only allow trusted actors (OWNER, MEMBER, COLLABORATOR) to trigger Claude with write permissions
1516
if: |
16-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
17+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
18+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
19+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
20+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
21+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
22+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)) ||
23+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
24+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association))
2025
runs-on: ubuntu-latest
2126
permissions:
2227
contents: write # Allow creating branches/commits
@@ -47,4 +52,3 @@ jobs:
4752
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
4853
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
4954
# claude_args: '--allowed-tools Bash(gh pr:*)'
50-

0 commit comments

Comments
 (0)