Skip to content

Commit ed9d09f

Browse files
fix: prevent script injection by using environment variables
Fix GitHub Actions script injection vulnerability by using intermediate environment variables instead of direct interpolation of github context data in run steps. Changes: - updater/action.yml: Use env vars for inputs.name, inputs.path, inputs.changelog-entry, inputs.pr-strategy, and inputs.post-update-script - sentry-cli/integration-test/action.yml: Use env vars for github.action_path and inputs.path This prevents potential code injection attacks where untrusted input could be executed as shell commands. Fixes: https://linear.app/getsentry/issue/VULN-1100 Fixes: https://linear.app/getsentry/issue/DI-1657
1 parent fb91df3 commit ed9d09f

2 files changed

Lines changed: 30 additions & 17 deletions

File tree

sentry-cli/integration-test/action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ runs:
1616
steps:
1717
- name: Run tests
1818
shell: pwsh
19+
env:
20+
ACTION_PATH: ${{ github.action_path }}
21+
TEST_PATH: ${{ inputs.path }}
1922
run: |
20-
Import-Module -Name ${{ github.action_path }}/action.psm1 -Force
21-
Invoke-Pester -Output Detailed '${{ inputs.path }}'
23+
Import-Module -Name "$env:ACTION_PATH/action.psm1" -Force
24+
Invoke-Pester -Output Detailed "$env:TEST_PATH"

updater/action.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,54 +73,64 @@ runs:
7373

7474
- name: Validate dependency name
7575
shell: pwsh
76+
env:
77+
DEPENDENCY_NAME: ${{ inputs.name }}
7678
run: |
7779
# Validate that inputs.name contains only safe characters
78-
if ('${{ inputs.name }}' -notmatch '^[a-zA-Z0-9_\./@\s-]+$') {
79-
Write-Output "::error::Invalid dependency name: '${{ inputs.name }}'. Only alphanumeric characters, spaces, and _-./@ are allowed."
80+
if ("$env:DEPENDENCY_NAME" -notmatch '^[a-zA-Z0-9_\./@\s-]+$') {
81+
Write-Output "::error::Invalid dependency name: '$env:DEPENDENCY_NAME'. Only alphanumeric characters, spaces, and _-./@ are allowed."
8082
exit 1
8183
}
82-
Write-Output "✓ Dependency name '${{ inputs.name }}' is valid"
84+
Write-Output "✓ Dependency name '$env:DEPENDENCY_NAME' is valid"
8385
8486
- name: Validate dependency path
8587
shell: pwsh
88+
env:
89+
DEPENDENCY_PATH: ${{ inputs.path }}
8690
run: |
8791
# Validate that inputs.path contains only safe characters (including # for CMake dependencies)
88-
if ('${{ inputs.path }}' -notmatch '^[a-zA-Z0-9_\./#-]+$') {
89-
Write-Output "::error::Invalid dependency path: '${{ inputs.path }}'. Only alphanumeric characters and _-./# are allowed."
92+
if ("$env:DEPENDENCY_PATH" -notmatch '^[a-zA-Z0-9_\./#-]+$') {
93+
Write-Output "::error::Invalid dependency path: '$env:DEPENDENCY_PATH'. Only alphanumeric characters and _-./# are allowed."
9094
exit 1
9195
}
92-
Write-Output "✓ Dependency path '${{ inputs.path }}' is valid"
96+
Write-Output "✓ Dependency path '$env:DEPENDENCY_PATH' is valid"
9397
9498
- name: Validate changelog-entry
9599
shell: pwsh
100+
env:
101+
CHANGELOG_ENTRY: ${{ inputs.changelog-entry }}
96102
run: |
97103
# Validate that inputs.changelog-entry is either 'true' or 'false'
98-
if ('${{ inputs.changelog-entry }}' -notin @('true', 'false')) {
99-
Write-Output "::error::Invalid changelog-entry value: '${{ inputs.changelog-entry }}'. Only 'true' or 'false' are allowed."
104+
if ("$env:CHANGELOG_ENTRY" -notin @('true', 'false')) {
105+
Write-Output "::error::Invalid changelog-entry value: '$env:CHANGELOG_ENTRY'. Only 'true' or 'false' are allowed."
100106
exit 1
101107
}
102-
Write-Output "✓ Changelog-entry value '${{ inputs.changelog-entry }}' is valid"
108+
Write-Output "✓ Changelog-entry value '$env:CHANGELOG_ENTRY' is valid"
103109
104110
- name: Validate pr-strategy
105111
shell: pwsh
112+
env:
113+
PR_STRATEGY: ${{ inputs.pr-strategy }}
106114
run: |
107115
# Validate that inputs.pr-strategy is either 'create' or 'update'
108-
if ('${{ inputs.pr-strategy }}' -notin @('create', 'update')) {
109-
Write-Output "::error::Invalid pr-strategy value: '${{ inputs.pr-strategy }}'. Only 'create' or 'update' are allowed."
116+
if ("$env:PR_STRATEGY" -notin @('create', 'update')) {
117+
Write-Output "::error::Invalid pr-strategy value: '$env:PR_STRATEGY'. Only 'create' or 'update' are allowed."
110118
exit 1
111119
}
112-
Write-Output "✓ PR strategy value '${{ inputs.pr-strategy }}' is valid"
120+
Write-Output "✓ PR strategy value '$env:PR_STRATEGY' is valid"
113121
114122
- name: Validate post-update-script
115123
if: ${{ inputs.post-update-script != '' }}
116124
shell: pwsh
125+
env:
126+
POST_UPDATE_SCRIPT: ${{ inputs.post-update-script }}
117127
run: |
118128
# Validate that inputs.post-update-script contains only safe characters
119-
if ('${{ inputs.post-update-script }}' -notmatch '^[a-zA-Z0-9_\./#\s-]+$') {
120-
Write-Output "::error::Invalid post-update-script path: '${{ inputs.post-update-script }}'. Only alphanumeric characters, spaces, and _-./# are allowed."
129+
if ("$env:POST_UPDATE_SCRIPT" -notmatch '^[a-zA-Z0-9_\./#\s-]+$') {
130+
Write-Output "::error::Invalid post-update-script path: '$env:POST_UPDATE_SCRIPT'. Only alphanumeric characters, spaces, and _-./# are allowed."
121131
exit 1
122132
}
123-
Write-Output "✓ Post-update script path '${{ inputs.post-update-script }}' is valid"
133+
Write-Output "✓ Post-update script path '$env:POST_UPDATE_SCRIPT' is valid"
124134
125135
- name: Validate authentication inputs
126136
shell: pwsh

0 commit comments

Comments
 (0)