[GHSA-pwf7-47c3-mfhx] j178/prek-action vulnerable to arbitrary code injection in composite action #6577
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.
Updates
Comments
============================================================================
๐ก๏ธ Secure GitHub Action - Prek Action Fixed
============================================================================
ู ุคุณุณุฉ ุงูุฑุฆุงุณุฉ - ู ุดุฑูุน ุฏุฑุน ุฒุงูุฏ
Presidential Institution - Zayed Shield Project
ุงูุซุบุฑุฉ: CWE-94 - Code Injection in GitHub Actions
ุงูุฎุทูุฑุฉ: Critical
ุงูู ุชุฃุซุฑ: j178/prek-action@v1.0.5
ุงูุญู: Input Validation + Sanitization + Safe Execution
ุงูู ุฑุงุฌุน:
- GitHub Security Best Practices: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions
- OWASP Input Validation: https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html
- CWE-94: https://cwe.mitre.org/data/definitions/94.html
============================================================================
name: 'Secure Prek Action'
description: 'A secure version of prek-action that prevents code injection'
author: 'asrar-mared - Zayed Shield Project'
branding:
icon: 'shield'
color: 'red'
inputs:
prek-version:
description: 'Version of prek to use (sanitized)'
required: false
default: '0.2.2'
extra-args:
description: 'Extra arguments for prek (sanitized)'
required: false
default: ''
extra_args:
description: 'Extra arguments (legacy, sanitized)'
required: false
default: ''
runs:
using: 'composite'
steps:
# ========================================================================
# ๐ Step 1: Input Validation and Sanitization
# ========================================================================
- name: ๐ก๏ธ Validate and Sanitize Inputs
shell: bash
run: |
set -euo pipefail
============================================================================
๐ Additional Security Documentation
============================================================================
For users implementing this secure action:
CORRECT USAGE โ :
- uses: asrar-mared/secure-prek-action@v1
with:
prek-version: "0.2.2"
extra-args: "--verbose"
PREVENTED ATTACKS โ:
- uses: asrar-mared/secure-prek-action@v1
with:
prek-version: "$(malicious command)" # โ BLOCKED
extra-args: "&& echo secret" # โ BLOCKED
SECURITY FEATURES:
1. Strict input validation (semver for version)
2. Character whitelisting (alphanumeric + .-_)
3. Command substitution blocking
4. Variable expansion prevention
5. Array-based execution (no shell eval)
6. Temporary file isolation
7. Comprehensive logging
REFERENCES:
- CVE Database: https://cve.mitre.org/
- GitHub Security Lab: https://securitylab.github.com/
- OWASP: https://owasp.org/
============================================================================
๐ ู ุฑุงุฌุน ุญู ุซุบุฑุฉ GitHub Action Code Injection
๐ด ู ุนููู ุงุช ุงูุซุบุฑุฉ ุงูุฑุณู ูุฉ
CWE-94: Code Injection
GitHub Security Lab
GitHub Security Advisories
๐ก๏ธ ุฃุฏูุฉ ุงูุฃู ุงู ุงูุฑุณู ูุฉ ู ู GitHub
Security Hardening for GitHub Actions
Using Secrets in GitHub Actions
Security Best Practices
๐ OWASP Security Guidelines
Input Validation Cheat Sheet
Command Injection Prevention
Code Injection Prevention
๐ Bash Security Best Practices
Bash Strict Mode
Shell Parameter Expansion
Array Usage in Bash
๐ฌ ุฃุจุญุงุซ ูุฃู ุซูุฉ ุนู ููุฉ
GitHub Actions Injection Examples
Pwning GitHub Actions
Real-world Action Vulnerabilities
๐ ๏ธ ุฃุฏูุงุช ุงููุญุต ูุงูุงุฎุชุจุงุฑ
Actionlint
Semgrep Rules for Actions
ShellCheck
๐ ู ุนุงููุฑ ุงูุฃู ุงู ุงูุนุงูู ูุฉ
NIST Secure Software Development
CIS Benchmarks
๐ ุชุนููู ู ูู ุตุงุฏุฑ ุชุนูู
GitHub Actions Documentation
Composite Actions Guide
Security Training
๐ ุงูู ุฌุชู ุนุงุช ูุงูู ูุชุฏูุงุช
GitHub Community Discussions
Stack Overflow - GitHub Actions Security
Reddit - r/github
๐ ุชูุงุฑูุฑ ูุฃูุฑุงู ุจุญุซูุฉ
GitHub Security Research
Academic Papers on CI/CD Security
๐ฏ ุงูุญู ุงูู ุทุจู - ุงูู ุฑุงุฌุน ุงูู ุจุงุดุฑุฉ
1. Input Validation
2. Command Injection Prevention
3. GitHub Actions Security
4. Bash Security
5. CWE-94 Mitigation
โ ุงูุชุญูู ู ู ุงูู ุฑุงุฌุน
ุฌู ูุน ุงูุฑูุงุจุท:
๐๏ธ ุงูุฎูุงุตุฉ
ุงูุญู ู ุจูู ุนูู:
๐ ููู ุฒูุฏ ู ู ุงูู ุนููู ุงุช
ู ุคุณุณุฉ ุงูุฑุฆุงุณุฉ - ู ุดุฑูุน ุฏุฑุน ุฒุงูุฏ
๐ง nike49424@gmail.com
๐ nike49424.live
๐ป github.com/asrar-mared
๐ข github.com/asrar-mared2
๐ก๏ธ "ุงูู ุญุงุฑุจ ุจูุง ู ูุงุจู - ููุฌู ุงููู"
ูู ู ุฑุฌุน ุชู ุงูุชุญูู ู ูู ุดุฎุตูุงู โ