Summary
A code injection flaw in Postiz's GitHub Actions workflow for building and publishing PR Docker images allowed arbitrary command execution during the Docker build process.
Any unauthenticated user could open a pull request from a fork with a malicious Dockerfile.dev, execute attacker-controlled code in CI, and exfiltrate a highly privileged GITHUB_TOKEN with write-all permissions.
Affected context
The vulnerability occurs in the .github/workflows/pr-docker-build.yml GitHub Actions workflow used to build and publish Docker images for pull requests.
It affects repositories where:
- The PR build workflow is automatically triggered for forks
- The workflow uses a privileged
GITHUB_TOKENwith broad write-all permissions - Docker build contexts or Dockerfiles are taken directly from untrusted pull request changes without isolation
In this setup, the Docker build step becomes an execution environment for attacker-supplied instructions from the PR.
Exploit preconditions
- Attack surface: GitHub Actions CI pipeline, specifically the PR Docker build workflow.
- Required access: Ability to create a public fork and open a pull request against the target repository (no prior authentication to the upstream project required beyond a standard GitHub account).
- Trigger point: Automated execution of
.github/workflows/pr-docker-build.ymlon the malicious PR, building the modifiedDockerfile.dev. - Why exploitation is possible: The workflow trusted Docker build instructions from the PR branch while exposing a highly privileged
GITHUB_TOKENin the same job context, enabling injected build steps to run arbitrary commands and access secrets.
Why this happens
This issue stems from treating untrusted pull request content as trusted build instructions in a privileged CI environment.
The PR-controlled Dockerfile.dev is effectively code that is executed by the Docker build process, and the workflow configuration allowed this execution to occur with access to a powerful GITHUB_TOKEN.
This maps to CWE-94: Improper Control of Code Generation (Code Injection), where dynamically supplied instructions (here, Dockerfile directives and build-time commands) from an untrusted source are executed without sufficient isolation or reduction of privileges, enabling attackers to run arbitrary code in the CI runner.
Potential impact
- Exfiltration of the CI job's
GITHUB_TOKENwith write-all permissions - Unauthorized creation, modification, or deletion of repository contents (branches, tags, releases)
- Tampering with source code, workflows, or release artifacts to introduce backdoors or supply-chain implants
- Manipulation of issues, pull requests, and repository settings accessible via the token
- Potential compromise of dependent repositories or automation that trusts artifacts from the affected project
General mitigation guidance
Effective mitigation focuses on separating untrusted PR code from privileged CI contexts and reducing token power:
- Use least-privilege tokens for CI workflows, limiting scopes to read-only where possible and disabling write-all for PR-triggered jobs.
- Configure GitHub Actions so that fork-based pull requests run in a restricted context, e.g., using
pull_request_targetcarefully or dedicated workflows that do not expose sensitive secrets. - Avoid building or executing Dockerfiles or scripts directly from untrusted PR branches in jobs that have access to sensitive secrets; use pinned, trusted Dockerfiles and static build definitions.
- Introduce manual approval or additional checks before running workflows that require elevated privileges or write access to the repository.
- Apply a defense-in-depth approach by segmenting workflows: one pipeline for untrusted PR validation (no secrets, no write access) and another for maintainers with elevated privileges.
How teams detect issues like this
Detection revolves around analyzing CI configuration and monitoring unusual CI behavior:
- Perform static analysis of workflow files (
.github/workflows/*.yml) to detect patterns where: - PR-triggered jobs use broadly scoped
GITHUB_TOKENor custom secrets - Docker builds or scripts are sourced directly from PR branches without restriction
- During code review, flag workflows that:
- Combine untrusted PR inputs with high-privilege tokens
- Run arbitrary build commands or shell steps based on PR-controlled files
- Use policy enforcement (e.g., GitHub branch protection and organization-wide Action policies) to require:
- Low-privilege tokens for PR workflows
- Approval gates for workflows that can push code or publish artifacts
- Monitor CI logs and audit trails for:
- Unexpected network exfiltration attempts from build steps
- Suspicious pushes or force-pushes originating from CI accounts

