Skip to content

fix: restrict GitHub Actions wildcard permissions to current PR#4

Merged
shrwnsan merged 1 commit into
devfrom
fix/M-001-wildcard-permissions
Jan 8, 2026
Merged

fix: restrict GitHub Actions wildcard permissions to current PR#4
shrwnsan merged 1 commit into
devfrom
fix/M-001-wildcard-permissions

Conversation

@shrwnsan
Copy link
Copy Markdown
Owner

@shrwnsan shrwnsan commented Jan 7, 2026

Summary

  • Scope gh pr comment permissions to only the PR being reviewed
  • Replace wildcard * with specific PR number variable

Security Impact

Prevents compromised workflow token from commenting on arbitrary PRs.

Related

Resolves #2


🤖 Generated by Claude Code - GLM 4.7

Scope gh pr comment permissions to only the PR being reviewed
by using PR number variable instead of wildcard. Prevents
compromised workflow token from commenting on arbitrary PRs.

Resolves #2

Co-Authored-By: GLM <zai-org@users.noreply.github.com>
@shrwnsan
Copy link
Copy Markdown
Owner Author

shrwnsan commented Jan 7, 2026

Summary

This PR addresses a critical security vulnerability by restricting the GitHub Actions workflow's gh pr comment permission from a wildcard (*) to only the specific PR being reviewed (${{ github.event.pull_request.number }}). This is a focused, minimal security fix that follows security best practices by implementing the principle of least privilege.

Overall Assessment: ✅ Strong Approve

Key Strengths:

  • Minimal, focused change (1 line, 1 addition, 1 deletion)
  • Directly addresses a documented security issue (M-001)
  • Follows the principle of least privilege
  • Clear commit message and PR description
  • Properly links to related issue M-001: GitHub Actions Wildcard Permissions #2

Key Concerns:

  • None identified

Detailed Feedback

1. Understanding & Intent

What is this PR trying to accomplish?
Clear and well-defined. The PR restricts wildcard permissions in the GitHub Actions workflow to only allow commenting on the current PR being reviewed, preventing a compromised workflow token from commenting on arbitrary PRs.

Does the title and description clearly communicate the purpose?
Excellent. The title "fix: restrict GitHub Actions wildcard permissions to current PR" is precise and accurate. The description clearly explains the security impact and links to issue #2.

Are the changes scoped appropriately, or should this be split?
Perfectly scoped. This is a minimal, focused security fix that changes exactly what's needed.

Does the PR link to relevant issues/tickets?
Yes. The PR description and commit message both reference issue #2.


2. Code Quality Assessment

Architecture & Design

Is the solution well-architected?
Yes. The solution follows security best practices by implementing the principle of least privilege. Rather than allowing the workflow to comment on any PR, it restricts permission to only the PR currently being reviewed.

Are there any code smells or design issues?
None. The change is clean and follows existing patterns.

Code Correctness

Logic correctness:
Correct. The change from Bash(gh pr comment:*) to Bash(gh pr comment ${{ github.event.pull_request.number }}:*) properly scopes the permission to the specific PR number.

Edge cases:
Well-handled. The GitHub expression ${{ github.event.pull_request.number }} is the standard, reliable way to reference the current PR number in a workflow triggered by pull_request events.

Potential bugs:
No bugs identified. The syntax is correct and follows GitHub Actions best practices.

Security & Safety

Security concerns:
This change IMPROVES security. The change specifically addresses a documented security vulnerability (M-001) where a compromised workflow token could be used to comment on arbitrary PRs. By restricting the permission to only the current PR, the attack surface is significantly reduced.

Before: Bash(gh pr comment:*) - Allows commenting on ANY PR
After: Bash(gh pr comment ${{ github.event.pull_request.number }}:*) - Allows commenting ONLY on the current PR

This is a proper implementation of the principle of least privilege.


3. Testing Coverage

Are there tests for the new functionality?
⚠️ Not applicable. GitHub Actions workflows typically don't have automated tests. The change should be manually verified by ensuring the workflow runs successfully on a PR and the review comment is posted to the correct PR.

Do existing tests still pass?
N/A. This is a workflow configuration change, not code changes.


4. Documentation & Impact

Code documentation:
Adequate. The inline comment references the claude-code-action documentation, which is appropriate.

User-facing documentation:
No changes needed. This is an internal workflow change with no user-facing impact.


5. Performance & Scalability

No impact. This change has no performance or resource usage implications.


6. Maintainability & Readability

Readability:
Excellent. The change is clear and self-documenting. The use of ${{ github.event.pull_request.number }} is a standard GitHub Actions pattern that clearly indicates the current PR number.

Extensibility:
Good. The pattern used here can be applied to other permissions if needed (e.g., if other wildcard permissions exist, they should be similarly restricted).


7. Specific Line-by-Line Feedback

What's Done Well

.github/workflows/claude-code-review.yml:56

  • Security-conscious approach: The change directly addresses a documented security vulnerability
  • Minimal change: Only modifies what's necessary, reducing risk
  • Standard GitHub Actions syntax: Uses the appropriate ${{ github.event.pull_request.number }} expression
  • Consistent formatting: Maintains the existing YAML structure and quoting
  • Clear intent: The permission string clearly shows it's scoped to a specific PR

Commit message:

  • Conventional commit format: Follows "fix:" prefix convention
  • Descriptive: Clearly explains what and why
  • References issue: Links to M-001: GitHub Actions Wildcard Permissions #2 for context
  • Co-authored-by: Properly attributes contributions

PR description:

  • Clear summary: Explains the change concisely
  • Security impact: Explicitly states the security benefit
  • Related issue: Links to M-001: GitHub Actions Wildcard Permissions #2
  • Appropriate detail: Provides enough context without being verbose

Action Items

Required Before Merge

None. This PR is ready to merge.

Recommended Improvements

None. This is a well-crafted security fix.

Optional Considerations

  1. Future audit: Consider checking if there are other wildcard permissions in the repository that could be similarly restricted for security
  2. Documentation: If this repository has security guidelines, consider documenting this pattern (restricting wildcard permissions to specific resources) as a best practice

Verdict

This PR is well-crafted and ready to merge. The change is minimal, focused, and directly addresses a documented security vulnerability. The implementation follows GitHub Actions best practices and the principle of least privilege. Excellent work on identifying and fixing this security issue!


Reviewed by: Droid - GLM 4.7

@shrwnsan
Copy link
Copy Markdown
Owner Author

shrwnsan commented Jan 8, 2026

Approved. Solid security fix—restricts GitHub Actions wildcard permissions to the current PR only.

Strengths:

  • Correctly implements principle of least privilege
  • One-line change, minimal scope
  • Uses standard GitHub Actions syntax
  • Clear commit message linking to issue M-001: GitHub Actions Wildcard Permissions #2
  • Follows conventional commit format

No issues identified. Ready to merge.


Reviewed by: Amp Code

@shrwnsan shrwnsan merged commit c0da703 into dev Jan 8, 2026
1 check failed
@shrwnsan shrwnsan deleted the fix/M-001-wildcard-permissions branch January 8, 2026 03:33
@shrwnsan
Copy link
Copy Markdown
Owner Author

shrwnsan commented Jan 8, 2026

Merge Successful

Summary: PR merged to dev

Changes:

  • Restricted GitHub Actions wildcard permissions to only the current PR being reviewed
  • Replaced wildcard * with specific PR number variable ${{ github.event.pull_request.number }}
  • Prevents compromised workflow token from commenting on arbitrary PRs

Issues resolved: #2


🤖 Generated by Claude Code - GLM 4.7

shrwnsan added a commit that referenced this pull request Jan 10, 2026
Scope gh pr comment permissions to only the PR being reviewed
by using PR number variable instead of wildcard. Prevents
compromised workflow token from commenting on arbitrary PRs.

Resolves #2

Co-authored-by: GLM <zai-org@users.noreply.github.com>
shrwnsan added a commit that referenced this pull request Jan 11, 2026
…etchgqc#43)

* fix: restrict GitHub Actions wildcard permissions to current PR (#4)

Scope gh pr comment permissions to only the PR being reviewed
by using PR number variable instead of wildcard. Prevents
compromised workflow token from commenting on arbitrary PRs.

Co-authored-by: GLM <zai-org@users.noreply.github.com>

* feat: add global .env file support (#8)

Add support for ~/.agentbox/.env that loads before project-specific
.env files. This enables centralized configuration for API keys and
custom inference endpoints across all projects.

Changes:
- Load ~/.agentbox/.env first, then PROJECT_DIR/.env
- Project env vars override global vars (Docker's last-wins behavior)
- Add log message for discoverability when global .env is loaded
- Document global .env usage in README with examples

Co-authored-by: GLM <zai-org@users.noreply.github.com>
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.

M-001: GitHub Actions Wildcard Permissions

1 participant