| description | Guidance for developing CodeQL queries targeting GitHub Actions workflows |
|---|
This prompt provides guidance for developing CodeQL queries targeting GitHub Actions workflows. For common query development patterns and best practices, see query_development.prompt.md.
- Import
actionsfor GitHub Actions AST nodes and predicates - Common imports:
Workflow,Job,Step,Uses,Run,Event - Use
DataFlowfor tracking data flow through workflow steps - Import security-related predicates for Actions-specific vulnerabilities
- Workflows:
WorkflowImplfor workflow files - Actions:
CompositeActionImplfor composite action definitions - Jobs:
JobImplfor job definitions - Steps:
StepImplfor individual steps,RunsImplfor runs configuration - Events:
EventImpl,OnImplfor workflow triggers - Expressions:
ExpressionImplfor${{ }}expression syntax - Inputs/Outputs:
InputsImpl,OutputsImpl,InputImplfor input/output definitions - Environment:
EnvImplfor environment variable definitions - Values:
ScalarValueImplfor scalar string values - Text Components:
StringTextComponent,StringInterpolationComponentfor string content
- Triggers: Event-based workflow triggers and conditions
- Jobs: Job dependencies, parallelism, and strategy matrices
- Steps: Sequential step execution within jobs
- Contexts:
github,env,secrets,inputscontexts - Expressions:
${{ }}expression syntax and evaluation - Conditional execution:
ifconditions on jobs and steps
- Action usage:
step.getUses().getAction() = "actions/checkout" - Script execution:
step.getRun().getScript()for shell commands - Environment variables: Access to
envcontext and variables - Secret usage:
secrets.TOKENand secret handling - Matrix strategies: Job matrix configurations
- Artifact handling: Upload/download artifact patterns
- Cache usage: Cache action patterns
- Track data flow between steps and jobs
- Environment variable propagation
- Secret exposure through echo or logs
- Input/output parameter flow between actions
- Context variable usage across workflow
- Script injection: Unsanitized user input in shell commands
- Secret exposure: Secrets logged or exposed in output
- Privilege escalation: Excessive permissions or token scope
- Supply chain attacks: Untrusted action usage
- Code injection: Dynamic script generation with user input
- Information disclosure: Sensitive data in logs or artifacts
- Workflow poisoning: Malicious workflow modifications
- Container vulnerabilities: Unsafe container image usage
- Expression injection:
${{ github.event.issue.title }}in scripts - Secret leakage: Secrets used in contexts that log them
- Untrusted input: PR content used in workflow execution
- Permissions abuse: Overly broad
GITHUB_TOKENpermissions - Third-party actions: Unverified or malicious marketplace actions
- Environment pollution: Malicious environment variable injection
- Artifact poisoning: Untrusted artifacts affecting subsequent jobs
- GitHub context: Repository, event, actor information
- Runner context: Operating system, architecture details
- Environment context: Environment variables and secrets
- Job context: Job status and outputs
- Steps context: Previous step outcomes and outputs
- Strategy context: Matrix strategy variables
- Inputs context: Workflow dispatch and reusable workflow inputs
- Check for proper input sanitization in shell scripts
- Verify minimal required permissions for workflows
- Validate third-party action versions and sources
- Ensure secrets are not logged or exposed
- Check for proper error handling in custom actions
- Verify artifact security and integrity
- Review workflow trigger conditions for safety