Skip to content

fix: prevent template injection in webhook_image workflow#3101

Merged
wainersm merged 1 commit into
confidential-containers:mainfrom
rafsal-rahim:zizmor-check-v1
Jun 1, 2026
Merged

fix: prevent template injection in webhook_image workflow#3101
wainersm merged 1 commit into
confidential-containers:mainfrom
rafsal-rahim:zizmor-check-v1

Conversation

@rafsal-rahim

Copy link
Copy Markdown
Contributor

This PR fixes 3 template injection vulnerabilities in the webhook_image.yaml workflow identified by the zizmor security audit tool.

Problem
The workflow was directly interpolating user-controlled inputs (inputs.image_tags and inputs.registry) into shell commands without proper sanitization. This creates a security risk where malicious input containing shell metacharacters could potentially be used for command injection attacks.

Vulnerable code locations:

Line 76: tags="${{ inputs.image_tags }}" - Direct interpolation in shell variable
Line 83: IMG="${{ inputs.registry }}/peer-pods-webhook:${t}" - Direct interpolation in make command
Line 89: IMG=${{ inputs.registry }}/peer-pods-webhook:latest - Direct interpolation in make command
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 "Build and push image" step with:
IMAGE_TAGS: ${{ inputs.image_tags }}
REGISTRY: ${{ inputs.registry }}
Replaced all direct template expressions with environment variable references:
${{ inputs.image_tags }} → ${IMAGE_TAGS}
${{ inputs.registry }} → ${REGISTRY}
Testing
Workflow syntax is valid
No functional changes to the workflow behavior
Security vulnerabilities are resolved
References
Zizmor Documentation: https://docs.zizmor.sh/audits/#template-injection

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.

Created with help of Bob

@rafsal-rahim
rafsal-rahim requested a review from a team as a code owner May 27, 2026 14:26

@mkulke mkulke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for addressing this, could we also make sure workflow is checked by the existing zizmor ci jobs? we seem to have a gap here.

@stevenhorsman stevenhorsman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

Move template expressions to environment variables to fix 3 template
injection vulnerabilities identified by zizmor security audit.

- Add env block with IMAGE_TAGS and REGISTRY variables
- Replace direct ${{ inputs.* }} usage with environment variable references

Reference: https://docs.zizmor.sh/audits/#template-injection

Signed-off-by: Rafsal-Rahim <rafsal.rahim@ibm.com>

@wainersm wainersm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rafsal-rahim !

@wainersm
wainersm merged commit 640508a into confidential-containers:main Jun 1, 2026
25 of 26 checks passed
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.

4 participants