From 8876893c59db141ae90f124bc394371f5b0dcd24 Mon Sep 17 00:00:00 2001 From: Arun Kumar Thiagarajan Date: Wed, 25 Mar 2026 09:05:17 +0530 Subject: [PATCH] fix(security): validate JSON input in gstack-review-log gstack-review-log appends its argument directly to a JSONL file with no validation. Malformed or crafted input could corrupt the review log or inject arbitrary content. Fix: validate input is parseable JSON via python3 before appending. Reject with exit 1 and stderr message if invalid. --- bin/gstack-review-log | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/gstack-review-log b/bin/gstack-review-log index d7235bc3..0ebc162c 100755 --- a/bin/gstack-review-log +++ b/bin/gstack-review-log @@ -6,4 +6,13 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" eval "$("$SCRIPT_DIR/gstack-slug" 2>/dev/null)" GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}" mkdir -p "$GSTACK_HOME/projects/$SLUG" -echo "$1" >> "$GSTACK_HOME/projects/$SLUG/$BRANCH-reviews.jsonl" + +# Validate: input must be parseable JSON (reject malformed or injection attempts) +INPUT="$1" +if ! printf '%s' "$INPUT" | python3 -c "import json,sys; json.load(sys.stdin)" 2>/dev/null; then + # Not valid JSON — refuse to append + echo "gstack-review-log: invalid JSON, skipping" >&2 + exit 1 +fi + +echo "$INPUT" >> "$GSTACK_HOME/projects/$SLUG/$BRANCH-reviews.jsonl"