Skip to content

Commit c0e6d9a

Browse files
fix(workflow): prevent shell injection in grace_period_minutes input
inputs.grace_period_minutes is a free-text string that was previously interpolated directly into the shell script body, allowing a crafted value (e.g. "1 $(malicious)") to execute arbitrary commands. Fix: - Assign the input to GRACE_PERIOD_INPUT env var so it never reaches the script body as a template expression. - Validate with ^[0-9]+$ before use; emit a ::warning:: and skip the flag if the value is non-numeric. - Build the argument as a bash array (GRACE_ARGS) so the flag name and value are always passed as two separate quoted tokens, eliminating word-splitting and command-substitution risks. Signed-off-by: SachinduNethmin <108050026+Sachindu-Nethmin@users.noreply.github.com>
1 parent e54db43 commit c0e6d9a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

.github/workflows/auto-close.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,25 @@ jobs:
5353
- name: Run auto-close
5454
env:
5555
GITHUB_TOKEN: ${{ github.token }}
56+
GRACE_PERIOD_INPUT: ${{ inputs.grace_period_minutes }}
5657
run: |
5758
DRY_RUN_FLAG=""
5859
if [ "${{ inputs.dry_run }}" = "true" ]; then
5960
DRY_RUN_FLAG="--dry-run"
6061
fi
6162
62-
GRACE_FLAG=""
63-
if [ -n "${{ inputs.grace_period_minutes }}" ]; then
64-
GRACE_FLAG="--grace-period-minutes ${{ inputs.grace_period_minutes }}"
63+
GRACE_ARGS=()
64+
if [[ -n "$GRACE_PERIOD_INPUT" ]]; then
65+
if [[ "$GRACE_PERIOD_INPUT" =~ ^[0-9]+$ ]]; then
66+
GRACE_ARGS=("--grace-period-minutes" "$GRACE_PERIOD_INPUT")
67+
else
68+
echo "::warning::grace_period_minutes must be a positive integer; ignoring value '$GRACE_PERIOD_INPUT'"
69+
fi
6570
fi
6671
6772
./simili-cli auto-close \
6873
--repo "${{ github.repository }}" \
6974
--config .github/simili.yaml \
7075
--verbose \
7176
$DRY_RUN_FLAG \
72-
$GRACE_FLAG
77+
"${GRACE_ARGS[@]}"

0 commit comments

Comments
 (0)