Secure Actions and Runner Isolation
Separate execution trust from repository trust
A workflow executes code, not merely reviews text. A fork pull request may contain untrusted source, metadata and workflow inputs. Avoid giving untrusted code access to privileged tokens, secrets, persistent workspaces or internal networks. Review the event policy and effective permissions, not just the workflow filename.
Choose a narrow workflow
For a metadata-only demonstration, do not check out contributor code. The inactive workflow below grants no token permissions, passes a PR title as environment data and prints a fixed message without exposing that title. It does not approve or merge anything. Hosted event scheduling and actual permissions are not tested.
name: Metadata checkon: [pull_request]permissions: {}jobs: inspect: runs-on: ubuntu-latest steps: - env: PR_TITLE: ${{ github.event.pull_request.title }} shell: bash run: | if [ -n "$PR_TITLE" ]; then printf "%s\n" "Title present" else printf "%s\n" "Title empty" fiPin and review dependencies
Use reviewed actions pinned to full commit SHAs where supported. A pin fixes the referenced revision but does not certify its safety; review source and transitive dependencies and maintain an update process. A privileged base-context event such as pull_request_target must not be combined with execution of untrusted PR code. Check current event restrictions and platform policy.
Isolate runners
A self-hosted runner may retain files or reach sensitive resources across jobs. Use isolated, disposable environments for untrusted work with restricted network access and no privileged credentials. Separate untrusted validation from trusted release jobs; treat artifacts crossing the boundary as untrusted until independently verified. Isolation is layered, not guaranteed by a runner label.
Practice
Inspect the YAML in the fixture. Predict fixed output for an empty and a nonempty title, including multiline punctuation. The local Bash test never evaluates the title as code. Compare the mock runner policy for a disposable runner and a privileged persistent runner. Static YAML checks do not validate hosted security or prove isolation.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Secure Actions and Runner Isolation — knowledge check
Reason about repository trust, security controls and incident response.
How should an untrusted PR title be handled?
What does pinning an action to a full SHA establish?
Why separate untrusted checks from release jobs?
What risk can persistent self-hosted runners introduce?
Does valid YAML prove workflow security?