From 500994039bb0a673e0a7ca5295441f7568ff673f Mon Sep 17 00:00:00 2001 From: A <6723574+louisgv@users.noreply.github.com> Date: Fri, 13 Feb 2026 20:16:10 +0000 Subject: [PATCH] fix: validate SLACK_WEBHOOK format to prevent command injection SLACK_WEBHOOK was embedded directly in heredocs at three locations, allowing potential command injection if the env var contained shell metacharacters. Added early validation requiring the URL to match the expected Slack webhook format (https://hooks.slack.com/...). Also stopped leaking the full webhook URL into prompt text. Fixes #992 Agent: security-auditor --- .claude/skills/setup-agent-team/security.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.claude/skills/setup-agent-team/security.sh b/.claude/skills/setup-agent-team/security.sh index e96af3c0b..eeb83668b 100644 --- a/.claude/skills/setup-agent-team/security.sh +++ b/.claude/skills/setup-agent-team/security.sh @@ -24,6 +24,12 @@ if [[ -n "${SPAWN_ISSUE}" ]] && [[ ! "${SPAWN_ISSUE}" =~ ^[0-9]+$ ]]; then exit 1 fi +# Validate SLACK_WEBHOOK format to prevent injection via heredoc expansion +if [[ -n "${SLACK_WEBHOOK}" ]] && [[ ! "${SLACK_WEBHOOK}" =~ ^https://hooks\.slack\.com/ ]]; then + echo "WARNING: SLACK_WEBHOOK does not match expected format (https://hooks.slack.com/...), disabling" >&2 + SLACK_WEBHOOK="" +fi + if [[ "${SPAWN_REASON}" == "issues" ]] && [[ -n "${SPAWN_ISSUE}" ]]; then # Workflow passed raw event_name — detect mode from issue labels if gh issue view "${SPAWN_ISSUE}" --repo OpenRouterTeam/spawn --json labels --jq '.labels[].name' 2>/dev/null | grep -q '^team-building$'; then @@ -712,7 +718,7 @@ if [ -n "\${SLACK_WEBHOOK}" ] && [ "\${SLACK_WEBHOOK}" != "NOT_SET" ]; then -d '{"text":":shield: Review+scan cycle complete: N PRs reviewed (X merged, Y flagged, Z closed-stale), K branches cleaned, J issues re-flagged, S scan findings (F issues filed). See https://github.com/OpenRouterTeam/spawn/pulls"}' fi \`\`\` -(The SLACK_WEBHOOK env var is: ${SLACK_WEBHOOK:-NOT_SET}) +(SLACK_WEBHOOK is configured: $(if [ -n "${SLACK_WEBHOOK}" ]; then echo "yes"; else echo "no"; fi)) ## Workflow