@@ -78,6 +78,10 @@ inputs:
7878 description : " Additional arguments to pass to cagent run"
7979 required : false
8080 default : " "
81+ trusted-bot-app-id :
82+ description : " GitHub App ID of a trusted bot that can bypass comment-based auth checks (e.g., for self-review triggers)"
83+ required : false
84+ default : " "
8185 add-prompt-files :
8286 description : " Comma-separated list of files to append to the prompt (e.g., 'AGENTS.md,CLAUDE.md')"
8387 required : false
@@ -190,10 +194,12 @@ runs:
190194 shell : bash
191195 env :
192196 ACTION_PATH : ${{ github.action_path }}
193- # Get author_association from comment events (the main risk)
194- COMMENT_ASSOCIATION : ${{ github.event.comment.author_association }}
197+ TRUSTED_BOT_APP_ID : ${{ inputs.trusted-bot-app-id }}
195198 DEBUG : ${{ inputs.debug }}
196199 run : |
200+ # Read comment fields directly from the event payload (cannot be overridden by workflow env vars)
201+ COMMENT_ASSOCIATION=$(jq -r '.comment.author_association // empty' "$GITHUB_EVENT_PATH")
202+
197203 # Only enforce auth for comment-triggered events
198204 # This prevents abuse via /commands while allowing PR-triggered workflows to run
199205 if [ -z "$COMMENT_ASSOCIATION" ]; then
@@ -202,6 +208,20 @@ runs:
202208 exit 0
203209 fi
204210
211+ # Allow a trusted GitHub App bot to bypass auth (e.g., auto-triage posts /review).
212+ # Verified via user type + app ID from the event payload to prevent spoofing.
213+ if [ -n "$TRUSTED_BOT_APP_ID" ]; then
214+ COMMENT_USER_TYPE=$(jq -r '.comment.user.type // empty' "$GITHUB_EVENT_PATH")
215+ COMMENT_APP_ID=$(jq -r '.comment.performed_via_github_app.id // empty' "$GITHUB_EVENT_PATH")
216+
217+ if [ "$COMMENT_USER_TYPE" = "Bot" ] && [ "$COMMENT_APP_ID" = "$TRUSTED_BOT_APP_ID" ]; then
218+ COMMENT_USER_LOGIN=$(jq -r '.comment.user.login // empty' "$GITHUB_EVENT_PATH")
219+ echo "ℹ️ Skipping auth check (trusted bot: $COMMENT_USER_LOGIN, app_id: $COMMENT_APP_ID)"
220+ echo "authorized=bot" >> $GITHUB_OUTPUT
221+ exit 0
222+ fi
223+ fi
224+
205225 echo "Using comment author_association: $COMMENT_ASSOCIATION"
206226
207227 # Allowed roles (hardcoded for security - cannot be overridden)
0 commit comments