Error when calling createComment with markdown in body
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- github, github-actions, javascript, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 5k
- Fork
- 586
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di actions/github-script
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
actions/github-script#728 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
actions/github-script#727 · 1 reazione ·
-
{ Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
actions/github-script#724 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
actions/github-script#714 · 1 commento · 4 reazioni ·
-
Immutable releases Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
actions/github-script#706 · 1 commento · 14 reazioni ·