Skip to content

Commit 75bb7f0

Browse files
committed
fix: address Semgrep finding - pass action inputs through env, not inline
${{ inputs.x }} interpolated directly into a run: step's script body is a shell-injection risk (Semgrep flagged it): the value gets substituted as literal script text before the shell runs it, so a malicious input value could break out of the intended string and execute arbitrary commands. None of this action's current call sites pass attacker-controlled values, but it's a reusable composite action, so fixing the pattern itself rather than relying on today's callers being safe. Passes role-arn/role-session-name/aws-region through env: instead, so the shell treats them as data (env var expansion) rather than script text.
1 parent e95902f commit 75bb7f0

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

.github/actions/aws-oidc-assume-role/action.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ runs:
1717
steps:
1818
- name: Assume AWS role via OIDC
1919
shell: bash
20+
env:
21+
# Passed through env, not interpolated directly into the script body
22+
# below (${{ inputs.x }} inline in a run: step is a shell-injection
23+
# risk - a malicious input value becomes literal script text before
24+
# the shell ever runs it, rather than being treated as data).
25+
INPUT_ROLE_ARN: ${{ inputs.role-arn }}
26+
INPUT_ROLE_SESSION_NAME: ${{ inputs.role-session-name }}
27+
INPUT_AWS_REGION: ${{ inputs.aws-region }}
2028
run: |
2129
set -euo pipefail
2230
@@ -48,8 +56,8 @@ runs:
4856
# Action involved - just the OIDC token and the AWS CLI, both
4957
# already present on the runner.
5058
CREDS=$(aws sts assume-role-with-web-identity \
51-
--role-arn "${{ inputs.role-arn }}" \
52-
--role-session-name "${{ inputs.role-session-name }}" \
59+
--role-arn "$INPUT_ROLE_ARN" \
60+
--role-session-name "$INPUT_ROLE_SESSION_NAME" \
5361
--web-identity-token "$GITHUB_JWT" \
5462
--query 'Credentials' --output json)
5563
@@ -70,8 +78,8 @@ runs:
7078
echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"
7179
echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}"
7280
echo "AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}"
73-
echo "AWS_REGION=${{ inputs.aws-region }}"
74-
echo "AWS_DEFAULT_REGION=${{ inputs.aws-region }}"
81+
echo "AWS_REGION=${INPUT_AWS_REGION}"
82+
echo "AWS_DEFAULT_REGION=${INPUT_AWS_REGION}"
7583
} >> "$GITHUB_ENV"
7684
77-
echo "::notice::Assumed AWS role ${{ inputs.role-arn }}"
85+
echo "::notice::Assumed AWS role ${INPUT_ROLE_ARN}"

0 commit comments

Comments
 (0)