Skip to content

Restrict /apply-optimize workflow to trusted authors - #33

Closed
ctorres100 wants to merge 1 commit into
SnailSploit:mainfrom
ctorres100:harden/apply-optimize-author-gate
Closed

ctorres100 wants to merge 1 commit into
SnailSploit:mainfrom
ctorres100:harden/apply-optimize-author-gate

Conversation

@ctorres100

Copy link
Copy Markdown

Summary

Harden .github/workflows/skill-optimize-apply.yml against a CI privilege-escalation path.

The workflow triggers on issue_comment and runs with contents: write + pull-requests: write, checks out the repo (fetch-depth: 0), and hands off to a third-party action (tesslio/skill-review-and-optimize) in apply mode. The only gate was:

if: github.event.issue.pull_request && contains(github.event.comment.body, '/apply-optimize')

On a public repo, any GitHub user can post a comment containing /apply-optimize, so any outsider could invoke this write-capable job.

Fix

Add an author_association check so only OWNER, MEMBER, or COLLABORATOR can trigger it:

if: >
  github.event.issue.pull_request &&
  contains(github.event.comment.body, '/apply-optimize') &&
  contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)

No behavior change for maintainers; external commenters can no longer start the job.

Notes / related findings (not in this PR)

While reviewing the repo I also noted, for separate follow-up:

  • convert_skills.py auto-runs pip install pyyaml on import, using bare pip — and yaml is never actually used in the script (dead dependency block).
  • python-publish.yml builds a package on release but the repo has no pyproject.toml/setup.py.

Happy to send these as their own PRs if wanted.

🤖 Generated with Claude Code

The skill-optimize-apply workflow triggers on issue_comment and runs with
contents:write and pull-requests:write. The only condition was that the
comment is on a PR and contains "/apply-optimize", so any GitHub user
could post that comment and invoke a write-capable job that checks out the
repo and runs a third-party action in apply mode.

Add an author_association gate so only OWNER, MEMBER, or COLLABORATOR can
trigger the job, closing the privilege-escalation path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ctorres100

Copy link
Copy Markdown
Author

Closing at author's request.

@ctorres100 ctorres100 closed this Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant