fix(security): fix command injection and authorization bypass vulnerabilities - #11
Merged
Lin-Jiong-HDU merged 2 commits intoMay 4, 2026
Conversation
…bilities Two HIGH severity vulnerabilities fixed: 1. Command injection in entrypoint.sh: quote heredoc delimiter to prevent premature variable expansion of attacker-controlled ISSUE_TITLE. Export `branch` so it is inherited at runtime. 2. Authorization bypass: add author_association check (OWNER/COLLABORATOR/ MEMBER) in GitHub Actions workflow, and server-side author allowlist validation via github.allowed_authors config (defense in depth). Also adds env value sanitization in runner.go to strip control characters and shell command substitution patterns from user-controlled fields. Closes #10 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Addresses two high-severity security findings by hardening the GitHub issue → webhook → Docker runner pipeline, preventing untrusted issue authors from triggering automation and reducing the risk of shell injection when propagating issue content into container execution.
Changes:
- Hardened runner script generation to prevent heredoc-time expansion and improved quoting around branch/title usage.
- Added server-side authorization via an optional GitHub author allowlist, wired from config through bootstrap to the usecase/controller.
- Added sanitization helpers for user-controlled values passed as container env vars, with accompanying tests.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
runner-image/entrypoint.sh |
Quotes heredoc delimiter and adjusts runtime env usage when generating the launcher script. |
internal/docker/runner.go |
Sanitizes selected task fields before injecting them into container environment variables. |
internal/docker/runner_test.go |
Adds tests covering sanitization behavior. |
.github/workflows/issue-webhook.yml |
Restricts workflow execution to issues opened by trusted author associations. |
domain/config.go |
Adds AllowedAuthors to GitHub config to support server-side allowlist. |
domain/errors.go |
Introduces ErrUnauthorized for authorization failures. |
usecase/task_usecase.go |
Enforces optional author allowlist in HandleWebhook. |
usecase/task_usecase_test.go |
Adds allowlist-related unit tests and updates constructor calls. |
api/controller/webhook_controller.go |
Maps ErrUnauthorized to HTTP 403. |
api/controller/webhook_controller_test.go |
Adds controller test for unauthorized author → 403 behavior. |
bootstrap/bootstrap.go |
Wires github.allowed_authors from config into the usecase constructor. |
Comment on lines
+50
to
+57
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| got := docker.SanitizeShellValue(tt.input) | ||
| if got != tt.expected { | ||
| t.Errorf("SanitizeShellValue(%q) = %q, want %q", tt.input, got, tt.expected) | ||
| } | ||
| }) |
| cd /workspace/repo | ||
| git config --global --add safe.directory /workspace/repo | ||
| claude -p "\$(cat /tmp/prompt.txt)" --dangerously-skip-permissions | ||
| claude -p "$(cat /tmp/prompt.txt)" --dangerously-skip-permissions |
Comment on lines
+26
to
+33
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
| got := docker.SanitizeEnvValue(tt.input) | ||
| if got != tt.expected { | ||
| t.Errorf("SanitizeEnvValue(%q) = %q, want %q", tt.input, got, tt.expected) | ||
| } | ||
| }) |
…d_authors The root-path launcher script hardcoded --dangerously-skip-permissions, ignoring the SKIP_PERMISSIONS setting. Add conditional logic consistent with the non-root path. Also add allowed_authors to config example and README. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Lin-Jiong-HDU
deleted the
feat/issue-10-fix-security-fix-command-injection-and-a
branch
May 4, 2026 03:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two HIGH severity security vulnerabilities identified in a security audit:
Command injection in
runner-image/entrypoint.sh: The heredoc delimiter was unquoted (<<SCRIPT), causing bash to expand variables at heredoc creation time. An attacker-controlledISSUE_TITLEcontaining$(...)or backticks would execute arbitrary commands inside Docker containers. Fixed by quoting the delimiter (<<'SCRIPT') and exportingbranchso it's inherited at runtime.Authorization bypass in
.github/workflows/issue-webhook.yml: The workflow only checked if the issue title ended with[claude bot]but did not verify the author's permissions. Any GitHub user could create an issue in a public repo to trigger the full automation pipeline. Fixed by addingauthor_associationcheck (OWNER/COLLABORATOR/MEMBER) and a server-side author allowlist (github.allowed_authorsconfig) as defense in depth.Changes
runner-image/entrypoint.sh: Quote heredoc delimiter, exportbranchinternal/docker/runner.go: AddSanitizeEnvValueandSanitizeShellValueto strip control chars and shell command substitution patterns from user-controlled env values.github/workflows/issue-webhook.yml: Addauthor_associationpermission checkdomain/config.go: AddAllowedAuthorstoGitHubConfigdomain/errors.go: AddErrUnauthorizedusecase/task_usecase.go: Author allowlist validation inHandleWebhookapi/controller/webhook_controller.go: Return 403 for unauthorized authorsbootstrap/bootstrap.go: WireAllowedAuthorsfrom configTest plan
go vet,go build,go test,golangci-lint run)Closes #10
🤖 Generated with Claude Code