fix: zizmor issue: Resolve template injection vulnerabilities in podvm_mkosi.yaml#3103
Open
siddu-os wants to merge 1 commit into
Open
Conversation
Move all template expressions from inline usage to environment variables to prevent code injection attacks. This fixes 6 template injection vulnerabilities identified by zizmor security scanner. Changes: - Move inputs.registry to REGISTRY environment variable (lines 174, 221) - Move inputs.arch to ARCH environment variable (line 178) - Move inputs.image_tag to IMAGE_TAG environment variable (lines 183, 184) - Add REGISTRY, ARCH, and IMAGE_TAG to env block for proper sanitization All template expressions are now properly sanitized by GitHub Actions through environment variables instead of direct inline usage. Verified with: zizmor .github/workflows/podvm_mkosi.yaml Result: No findings to report Signed-off-by: siddaram-sonnagi <siddaram.sonnagi@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes 6 template injection vulnerabilities identified by zizmor security scanner.
Problem:
The workflow was directly interpolating user-controlled inputs (inputs.registry, inputs.arch, and inputs.image_tag) into shell commands without proper sanitization. This creates a security risk where malicious input containing shell meta characters could potentially be used for command injection attacks.
Vulnerable code locations:
Line 174: image=${{ inputs.registry }}/podvm-generic-fedora - Direct interpolation in shell variable
Line 178: image=${image}-${{ inputs.arch }} - Direct interpolation in shell variable
Line 183: if [ -n "${{ inputs.image_tag }}" ] && [ "${{ inputs.image_tag }}" != "${tag}" ] - Direct interpolation in conditional (2 occurrences)
Line 184: oras push "${image}:${{ inputs.image_tag }}" - Direct interpolation in oras command
Line 221: echo "image=${{ inputs.registry }}/podvm-docker-image-${arch}:${tag}" - Direct interpolation in output variable
Solution
Following GitHub Actions security best practices, all template expressions have been moved to environment variables in the env: block. GitHub Actions automatically escapes environment variable values, preventing injection attacks.
Changes made:
Added env: block to the "Upload the qcow2 with oras" step with:
REGISTRY: ${{ inputs.registry }}
ARCH: ${{ inputs.arch }}
IMAGE_TAG: ${{ inputs.image_tag }}
Replaced all direct template expressions with environment variable references:
${{ inputs.registry }} → ${REGISTRY} (2 occurrences)
${{ inputs.arch }} → ${ARCH} (1 occurrence)
${{ inputs.image_tag }} → ${IMAGE_TAG} (3 occurrences)
Testing:
Workflow syntax is valid
No functional changes to the workflow behavior
Security vulnerabilities are resolved (verified with zizmor: "No findings to report")
References:
Zizmor Documentation: https://docs.zizmor.sh/audits/#template-injection
Reference PR: #2641
Security Impact:
This change eliminates potential command injection vulnerabilities while maintaining the same functionality. The workflow will continue to work exactly as before, but with improved security posture.