Skip to content

Commit 7545bd3

Browse files
author
超渡法師
committed
fix(agentcore/kiro): prevent argument injection in run.sh
Remove the --* flag promotion loop that allowed untrusted prompt content to be interpreted as kiro-cli options. The prompt is now passed as a positional argument after a -- end-of-options separator, ensuring it is always treated as text regardless of content. Extra flags can still be supplied via the KIRO_EXTRA_FLAGS env var (operator-controlled, trusted channel). Closes #1080
1 parent be722b3 commit 7545bd3

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

agentcore/runtimes/kiro/run.sh

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,17 @@ else
4040
exec kiro-cli login --use-device-flow
4141
fi
4242

43-
# Parse args: ACTION [--flags...] "prompt"
43+
# Parse args: ACTION "prompt"
44+
# Note: Extra flags are sourced from KIRO_EXTRA_FLAGS env var (operator-controlled)
45+
# rather than from argv, to prevent argument injection from untrusted prompts.
4446
ACTION="${1:-interactive}"
4547
shift 2>/dev/null || true
46-
47-
EXTRA_FLAGS=()
48-
PROMPT_PARTS=()
49-
for arg in "$@"; do
50-
if [[ "$arg" == --* ]]; then
51-
EXTRA_FLAGS+=("$arg")
52-
else
53-
PROMPT_PARTS+=("$arg")
54-
fi
55-
done
56-
PROMPT="${PROMPT_PARTS[*]}"
48+
PROMPT="$*"
5749

5850
cd "$HOME"
5951

6052
case "$ACTION" in
6153
interactive) exec kiro-cli ;;
62-
chat) exec kiro-cli chat --no-interactive --trust-all-tools "${EXTRA_FLAGS[@]}" "$PROMPT" ;;
63-
*) exec kiro-cli "$ACTION" "${EXTRA_FLAGS[@]}" "$PROMPT" ;;
54+
chat) exec kiro-cli chat --no-interactive --trust-all-tools ${KIRO_EXTRA_FLAGS:-} -- "$PROMPT" ;;
55+
*) exec kiro-cli "$ACTION" ${KIRO_EXTRA_FLAGS:-} -- "$PROMPT" ;;
6456
esac

0 commit comments

Comments
 (0)