Skip to content

fix: zizmor issue: Resolve template injection vulnerabilities in podvm_mkosi.yaml#3103

Open
siddu-os wants to merge 1 commit into
confidential-containers:mainfrom
siddu-os:zizmor-fix-podvm-mkosi-template-injection
Open

fix: zizmor issue: Resolve template injection vulnerabilities in podvm_mkosi.yaml#3103
siddu-os wants to merge 1 commit into
confidential-containers:mainfrom
siddu-os:zizmor-fix-podvm-mkosi-template-injection

Conversation

@siddu-os
Copy link
Copy Markdown

@siddu-os siddu-os commented May 29, 2026

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.

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>
@siddu-os siddu-os requested a review from a team as a code owner May 29, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant