T05 · Unauthorized Access and Privilege Escalation
- Location
references/deploy.md:63- Finding
GitHub Pages deployment permissions are granted at workflow scope
- Content
View full analysis
Vulnerability Details
File Location:
references/deploy.md:63-66
Vulnerability Type: Excessive CI/CD token permissions
Risk Level: Mediumyaml permissions: contents: read pages: write id-token: writeTechnical Analysis
The workflow grants
pages: writeandid-token: writeglobally. Consequently, both the build and deployment jobs inherit permissions intended only for the deployment operation.The build job executes
npm ciandnpm run docs:build. These operations can execute package lifecycle scripts, build plugins, and project-controlled JavaScript. If any such component is compromised, it can run while the job has access to the workflow's elevated GitHub token permissions and OIDC token request capability.GitHub Pages deployment legitimately requires these permissions, but they should be assigned only to the
deployjob. Granting them to the build job exceeds the minimum privileges necessary.Attack Path
- An attacker compromises a dependency, lifecycle script, build plugin, or project build script executed by the build job.
- The malicious code runs during
npm ciornpm run docs:build. - Because permissions are defined at workflow scope, the build job has
pages: writeandid-token: write. - The malicious process accesses the GitHub token or requests an OIDC identity token through the GitHub Actions OIDC endpoint.
- The attacker attempts to modify GitHub Pages deployment state or authenticate to an external service configured to trust the repository's GitHub OIDC identity.
Impact Assessment
A successful exploit could affect the repository's GitHub Pages deployment and potentially allow publication of attacker-controlled site content. If an external cloud provider trusts this workflow identity without sufficiently restrictive claims, the OIDC token could also provide access to associated cloud deployment resources. The issue does not inherently grant ...[truncated 71 chars]
- Remediation
View remediation
Remediation Suggestions
Apply least privilege at job scope:
yaml permissions: contents: read jobs: build: permissions: contents: read # Build steps... deploy: permissions: pages: write id-token: write environment: name: github-pages # Deployment steps...Additionally:
- Protect the
github-pagesenvironment with deployment approval and branch restrictions where appropriate. - Restrict cloud trust policies using repository, branch, workflow, and environment claims.
- Audit package lifecycle scripts and consider
npm ci --ignore-scriptswhen lifecycle scripts are unnecessary. - Ensure untrusted pull requests cannot execute a privileged deployment workflow.
- Protect the
