CICD-375 · Untrusted PR isolation
Encyclopedia · Advanced security and compliance · All snippets
Previous · CICD-374 · Next · CICD-376
1. Where it fits
- Placement As a standalone GitHub PR verification workflow.
- Prerequisites reviewed policies, a short-lived CI identity, and synthetic or approved test inputs.
- Platforms github-actions.
2. Copy the snippet
yaml
name: Unprivileged PR tests
on: [pull_request]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- run: git diff --check HEAD^ HEAD3. How it works
The PR workflow runs with read-only source access and checkout avoids retaining credentials. Keep hosted runner and secret boundaries independent of any fork-supplied code.
A fork check runs without the privileged release path.
flowchart TD N1["Repository event"] N2["Fork pull request"] N1 --> N2 N3["Protected merge"] N1 --> N3 N4["Read-only check"] N2 --> N4 N5["Trusted release workflow"] N3 --> N5 N6["Verification evidence"] N4 --> N6 N7["Scoped publishing access"] N5 --> N7
4. Verify the result
Use a disposable hosted runner without secrets. Verify fork PRs cannot reach protected environments or privileged runners.
Validation syntax-validated (YAML parse). Status definitions.