From 76d5f903ccc569c6e28875629ebc513da9a32f34 Mon Sep 17 00:00:00 2001 From: "hf-security-analysis[bot]" <265538906+hf-security-analysis[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:35:58 +0000 Subject: [PATCH] fix(ci): harden workflow design flagged on #15046 --- .github/workflows/issue_labeler.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/issue_labeler.yml b/.github/workflows/issue_labeler.yml index 2fd7faea1693..522eafa66a71 100644 --- a/.github/workflows/issue_labeler.yml +++ b/.github/workflows/issue_labeler.yml @@ -23,9 +23,25 @@ jobs: HF_TOKEN: ${{ secrets.ISSUE_LABELER_HF_TOKEN }} ISSUE_TITLE: ${{ github.event.issue.title }} ISSUE_BODY: ${{ github.event.issue.body }} + ALLOWED_LABELS: ${{ vars.ISSUE_LABELER_ALLOWED_LABELS }} run: | LABELS=$(python utils/label_issues.py) - echo "labels=$LABELS" >> "$GITHUB_OUTPUT" + # Treat LLM output as untrusted: parse, validate against allowlist, emit single-line JSON + SANITIZED=$(printf '%s' "$LABELS" | python -c ' + import json, os, sys + try: + data = json.load(sys.stdin) + except Exception: + data = [] + allowed = [l.strip() for l in os.environ.get("ALLOWED_LABELS", "").split(",") if l.strip()] + out = [] + if isinstance(data, list): + for l in data: + if isinstance(l, str) and l and "\n" not in l and "\r" not in l and (not allowed or l in allowed) and l not in out: + out.append(l) + print(json.dumps(out) if out else "") + ') + echo "labels=$SANITIZED" >> "$GITHUB_OUTPUT" - name: Apply labels if: steps.get-labels.outputs.labels != '' env: