Skip to content

Personal AI, On Personal Devices

Python

fix(ci): gate secret-bearing Claude workflows by author association (fixes #218) (#547)

Jon Saad-Falcon8ef1ab192804
diff --git a/.github/workflows/claude-issues.yml b/.github/workflows/claude-issues.yml
index 07680c8d..4b24c035 100644
--- a/.github/workflows/claude-issues.yml
+++ b/.github/workflows/claude-issues.yml
@@ -11,22 +11,33 @@ concurrency:
group: claude-issues-${{ github.event.issue.number || github.run_id }}
cancel-in-progress: true
+# Least-privilege: only what the issue-fixer job actually needs.
+# id-token (OIDC) is intentionally omitted — claude-code-action@v1 is passed
+# github_token directly, so OIDC is unused here.
permissions:
contents: write
pull-requests: write
issues: write
- id-token: write
jobs:
fix:
runs-on: ubuntu-latest
- timeout-minutes: 60
+ timeout-minutes: 15
+ # Security gate: this job reaches secrets.ANTHROPIC_API_KEY and holds a
+ # write-scoped GITHUB_TOKEN. `issues` / `issue_comment` are public,
+ # attacker-controllable events that run in the base-repo context with full
+ # secret access, so the human-triggered paths are restricted to actors with
+ # write-level association (OWNER / MEMBER / COLLABORATOR). This blocks
+ # external / first-time contributors from draining the API budget or
+ # creating branches/PRs, while leaving maintainer use unaffected.
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issues' &&
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association) &&
(contains(github.event.issue.labels.*.name, 'bug') ||
contains(github.event.issue.labels.*.name, 'autofix'))) ||
(github.event_name == 'issue_comment' &&
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) &&
!github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude') &&
github.actor != 'claude[bot]')
diff --git a/.github/workflows/claude-review.yml b/.github/workflows/claude-review.yml
index f12a01a2..580bb6c9 100644
--- a/.github/workflows/claude-review.yml
+++ b/.github/workflows/claude-review.yml
@@ -11,23 +11,33 @@ concurrency:
group: claude-review-${{ github.event.pull_request.number || github.event.issue.number || github.run_id }}
cancel-in-progress: true
+# Least-privilege: PR review only needs to post comments on the PR.
+# id-token (OIDC) is omitted — claude-code-action@v1 is passed github_token
+# directly, so OIDC is unused here.
permissions:
contents: read
pull-requests: write
issues: write
- id-token: write
jobs:
review:
runs-on: ubuntu-latest
timeout-minutes: 30
+ # Security gate: this job reaches secrets.ANTHROPIC_API_KEY. Both
+ # issue_comment and pull_request_review_comment are public,
+ # attacker-controllable events that run in the base-repo context with full
+ # secret access, so the @claude paths are restricted to actors with
+ # write-level association (OWNER / MEMBER / COLLABORATOR). External /
+ # first-time contributors cannot trigger the key; maintainers are unaffected.
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' &&
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude') &&
github.actor != 'claude[bot]') ||
(github.event_name == 'pull_request_review_comment' &&
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) &&
contains(github.event.comment.body, '@claude') &&
github.actor != 'claude[bot]')
steps: