Error when calling createComment with markdown in body
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 冷清
- 技術堆疊
- github, github-actions, javascript, typescript
研究方向
Reproduce the workflow step using actions/github-script@v9.0.0 and github.rest.issues.createComment with the shown nested Markdown and code fences, then inspect the action's script evaluation and comment request path. Done means the exact body creates a comment without the SyntaxError, including its backticks and pickle text.
由索引模型根據 Issue 內容生成。
描述
Describe the bug
The following error is thrown:
Error: Unhandled error: SyntaxError: Unexpected identifier 'pickle'
To Reproduce
Steps to reproduce the behavior:
run the following action step:
- name: Create comment
uses: actions/github-script@v9.0.0
with:
github-token: ${{ inputs.github-token }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### 1. **Arbitrary Code Execution via `pickle.loads()` on Untrusted Input** (`test01.py`)
**Severity: CRITICAL**
The file `test01.py` takes user input directly and passes it to `pickle.loads()`. This is a well-known **Remote Code Execution (RCE)** vulnerability. An attacker can craft a malicious pickle payload that executes arbitrary system commands upon deserialization.
Additionally, `pickle.loads()` expects `bytes`, but `input()` returns a `str` in Python 3, so this code will also raise a **`TypeError`** at runtime.
**File: `test01.py`**
```python
# Current (vulnerable and broken):
import pickle
data = input("Enter serialized data: ")
obj = pickle.loads(data)
```
**Suggested fix:**
```python
import json
data = input("Enter serialized data: ")
obj = json.loads(data)
```
If `pickle` is absolutely required (not recommended with untrusted input), at minimum fix the type error and restrict allowed classes:
```python
import pickle
import io
ALLOWED_CLASSES = {
# explicitly list allowed classes here
}
class RestrictedUnpickler(pickle.Unpickler):
def find_class(self, module, name):
if (module, name) in ALLOWED_CLASSES:
return ALLOWED_CLASSES[(module, name)]
raise pickle.UnpicklingError(f"Forbidden class: {module}.{name}")
data = input("Enter serialized data: ")
obj = RestrictedUnpickler(io.BytesIO(data.encode('latin-1'))).load()
```
`
})
Expected behavior
No error and comment is created.
Desktop (please complete the following information):
- OS: Ubuntu 22.04
- Runner 2.331.0
Additional context
The markdown text is actually a dynamic response generated by a LLM, hence no way to modify the markdown contents.
- 主要語言
- TypeScript
- 星號
- 5k
- 分支
- 586
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
actions/github-script 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 48/100
actions/github-script#728 ·
-
難度 3/5 1-2 天 新手友好度 52/100
actions/github-script#727 · 1 個 reaction ·
-
{ 未關閉
難度 5/5 一週以上 新手友好度 10/100
actions/github-script#724 ·
-
難度 3/5 1-2 天 新手友好度 55/100
actions/github-script#714 · 1 則留言 · 4 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 48/100
actions/github-script#706 · 1 則留言 · 14 個 reaction ·
查看 actions/github-script 的全部 Issue
相似的 Issue
-
blocklist removal
難度 2/5 1-3 小時 新手友好度 65/100
MetaMask/eth-phishing-detect#296544 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
pastelsky/bundlephobia#1122 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 75/100