anthropics / anthropics/claude-code-action

claude-user-request.txt is written from the unsanitized trigger comment, so hidden content bypasses sanitizeContent

Đang mở
#1,779 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug p2
Ngôn ngữ chính
TypeScript
Star
8.9k
Fork
2.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

**Type:** bug / prompt-injection hardening
**Severity:** medium-high
**Area:** `src/create-prompt/index.ts`, consumed by `base-action/src/run-claude-sdk.ts`
**Effort:** small

## Summary

The prompt wraps the trigger comment in `sanitizeContent` (`src/create-prompt/index.ts` around lines 577 and 710) and tells the model that block is the only source of instructions. But `extractUserRequestFromContext` (around lines 910-918) runs `extractUserRequest` on the **raw** `eventData.commentBody` / `githubData.contextData.body`, and the result is written unsanitized to `claude-user-request.txt` (around lines 973-978). `base-action/src/run-claude-sdk.ts` (around lines 45-83) then sends that file as a second `text` block of the same user message.

So everything `docs/security.md` says is stripped (HTML comments, invisible characters, image alt text, hidden attributes) reaches the model anyway through the second block. `allowed_non_write_users` explicitly supports untrusted trigger authors.

## Reproduction

Trigger comment:

```
@claude summarize this issue please ![ALT-TEXT-PAYLOAD](https://github.com/user-attachments/assets/x) ok
```

Running the real `createPrompt` with `RUNNER_TEMP` pointed at a scratch directory:

```
trigger_comment block in claude-prompt.txt (sanitized):
"@claude summarize this issue please ![](https://github.com/user-attachments/assets/x) ok"
claude-user-request.txt (2nd content block):
"summarize this issue please ![ALT-TEXT-PAYLOAD](...) ok"
```

Every marker (`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.