Skip to content

Commit 07d9cf8

Browse files
committed
security: fix shell injection in GitHub Actions release workflow
Moved all github context interpolation from run: blocks to env: variables. Specifically: - github.event_name and github.event.inputs.version in version extraction - steps.version.outputs.VERSION in multiple run: blocks Uses intermediate env: variables so user-controlled input is never directly interpolated in shell scripts. Flagged by Semgrep static analysis (run-shell-injection).
1 parent 032420a commit 07d9cf8

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@ jobs:
4444
4545
- name: Extract version from tag
4646
id: version
47+
env:
48+
EVENT_NAME: ${{ github.event_name }}
49+
INPUT_VERSION: ${{ github.event.inputs.version }}
4750
run: |
48-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49-
VERSION="${{ github.event.inputs.version }}"
51+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
52+
VERSION="$INPUT_VERSION"
5053
else
5154
VERSION=${GITHUB_REF#refs/tags/}
5255
fi
5356
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
5457
echo "Building version: $VERSION"
5558
5659
- name: Update version in Info.plist
60+
env:
61+
VERSION: ${{ steps.version.outputs.VERSION }}
5762
run: |
58-
VERSION=${{ steps.version.outputs.VERSION }}
5963
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $VERSION" Info.plist
6064
UPDATED_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" Info.plist)
6165
if [ "$UPDATED_VERSION" != "$VERSION" ]; then
@@ -77,8 +81,9 @@ jobs:
7781
make sign-only-release
7882
7983
- name: Verify distribution files
84+
env:
85+
VERSION: ${{ steps.version.outputs.VERSION }}
8086
run: |
81-
VERSION=${{ steps.version.outputs.VERSION }}
8287
if [ ! -f "dist/SAM-${VERSION}.dmg" ]; then
8388
echo "ERROR: DMG not found"
8489
exit 1
@@ -93,9 +98,8 @@ jobs:
9398
- name: Update appcast.xml
9499
env:
95100
SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }}
101+
VERSION: ${{ steps.version.outputs.VERSION }}
96102
run: |
97-
VERSION=${{ steps.version.outputs.VERSION }}
98-
99103
# Create temporary file for private key
100104
TEMP_KEY_FILE=$(mktemp)
101105
echo "$SPARKLE_PRIVATE_KEY" > "$TEMP_KEY_FILE"
@@ -108,8 +112,9 @@ jobs:
108112
rm -f "$TEMP_KEY_FILE"
109113
110114
- name: Commit and push appcast changes
115+
env:
116+
VERSION: ${{ steps.version.outputs.VERSION }}
111117
run: |
112-
VERSION=${{ steps.version.outputs.VERSION }}
113118
git config user.name "GitHub Actions"
114119
git config user.email "actions@github.com"
115120

0 commit comments

Comments
 (0)