T09 · Insecure Skill Coding Practices
- Location
scripts/post_review.py:99- Finding
PR comments are posted without the required explicit user confirmation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/post_review.py:99-121
Related Requirement:SKILL.md:356-389
Vulnerability Type: Missing authorization/consent gate before an external write
Risk Level: HighVulnerable Code:
python # Show preview print("\n" + "="*60) print("代码检视意见预览") print("="*60) print(f"\n来源: {review_file}") print(f"总问题数: {meta.get('total_issues', 0)}") print(f"自动扫描: {meta.get('automated_count', 0)}") print(f"人工审查: {meta.get('manual_count', 0)}") print(f"将提交: {len(comments)} 条评论\n") for i, comment in enumerate(comments, 1): print(f"### 评论 #{i}") print(f"文件: {comment['path']} (行 {comment['position']})") print(f"严重程度: {comment['severity']}/10") print(f"类型: {comment['type']}") print(f"内容:\n{comment['body'][:500]}...") print() # Post individual comments only (no summary) print(f"\n正在提交 {len(comments)} 条评论...") for i, comment in enumerate(comments, 1): print(f"提交评论 #{i}...") post_comment( owner, repo, pr_number, token, comment["body"], comment.get("path"), comment.get("position") )Technical Analysis
The Skill specification says that posting comments is optional and must occur only after the user explicitly confirms the preview. The implementation does not enforce this control. Once invoked with valid arguments,
post_review.pydisplays the preview and immediately enters the posting loop.This is a time-of-authorization flaw: displaying intended changes does not establish consent to perform them. Because the check is absent from the executable boundary, an Agent that follows the documented invocation can perform external writes even when the user has not answered
yes.The script also reports that all comments were successfully posted without checking each
post_comment()return value, although this reporting defect is secondary to the missing confirmation gate....[truncated 1084 chars]
- Remediation
View remediation
Remediation Suggestions
- Add an explicit confirmation prompt after displaying the complete preview and before the first network request.
- Normalize the response and proceed only for an exact allowlist such as
yesor是; treat empty, malformed, or unrecognized input as denial. - Prefer separating preview and execution into distinct operations. For automation, require an explicit
--confirmflag supplied only after consent has been obtained outside the script. - Keep the posting function inaccessible until the authorization gate succeeds.
- Abort remaining submissions when a post fails, or clearly report per-comment success and failure rather than always claiming full success.
- Add tests proving that EOF,
no, empty input, and arbitrary text result in zero POST requests.
