Skip to content

Commit b47c4e6

Browse files
hyperpolymathclaude
andcommitted
fix(security): remove eval from conformance runner
The conformance/run_conformance.sh script previously built a parser command as a string and invoked it via `eval "${PARSER}" "$f"`, which is a command-injection vector: a caller could pass $1 containing shell metacharacters and execute arbitrary commands as whoever runs the script. Fix: build PARSER_CMD as a Bash array. If the caller passes a parser command as $1, split it on whitespace into the array; otherwise use the default parser invocation as array literals directly. Invoke via `"${PARSER_CMD[@]}" "$f"` — no eval, no shell re-parsing. This is the same fix applied to my-lang/conformance/run_conformance.sh and is being rolled out across all language repos in the nextgen-languages monorepo that share the same original script pattern. Resolves one Critical panic-attack CommandInjection finding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8ccc2f9 commit b47c4e6

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

conformance/run_conformance.sh

100755100644
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ set -euo pipefail
1313

1414
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1515
PROJECT_DIR="${SCRIPT_DIR}/.."
16-
PARSER="${1:-mix run -e 'Phronesis.CLI.parse(System.argv())' --}"
16+
# Build PARSER_CMD as an array so we never need `eval`. If the caller
17+
# passes a parser command as $1, split it on whitespace; otherwise use
18+
# the default command directly.
19+
if [[ -n "${1:-}" ]]; then
20+
# shellcheck disable=SC2206 # deliberate word-splitting of caller's string
21+
PARSER_CMD=(${1})
22+
else
23+
PARSER_CMD=(mix run -e 'Phronesis.CLI.parse(System.argv())' --)
24+
fi
1725

1826
PASS=0
1927
FAIL=0
@@ -25,7 +33,7 @@ cd "${PROJECT_DIR}"
2533
for f in "${SCRIPT_DIR}"/valid/*.phr; do
2634
TOTAL=$((TOTAL + 1))
2735
name="$(basename "$f")"
28-
if eval "${PARSER}" "$f" >/dev/null 2>&1; then
36+
if "${PARSER_CMD[@]}" "$f" >/dev/null 2>&1; then
2937
echo " PASS valid/${name}"
3038
PASS=$((PASS + 1))
3139
else
@@ -38,7 +46,7 @@ done
3846
for f in "${SCRIPT_DIR}"/invalid/*.phr; do
3947
TOTAL=$((TOTAL + 1))
4048
name="$(basename "$f")"
41-
if eval "${PARSER}" "$f" >/dev/null 2>&1; then
49+
if "${PARSER_CMD[@]}" "$f" >/dev/null 2>&1; then
4250
echo " FAIL invalid/${name} (expected failure, got success)"
4351
FAIL=$((FAIL + 1))
4452
else

0 commit comments

Comments
 (0)