wtf( )unctionsystem design, drawn
← all problemsSupply ChainHard

A pull request from a stranger, with your secrets

A workflow comments the bundle size on every pull request, including ones from forks. To read repository secrets and post a comment it uses the trigger that runs with full write permissions.

The checkout step refuses to fetch a fork's pull request under that trigger now, so somebody set the opt-out flag — otherwise there was nothing to measure. The build is running a stranger's code with the repository's own credentials again, and the line that permits it is one input in a file nobody rereads.

Split the job so untrusted code never runs with the privileges.
Components — tap one, then tap a slot on the diagram
!The unsafe-checkout opt-out is enabled, so a fork's pull request runs with the write token and secrets.

Boundaries, outermost first: Has secrets: Post the comment (needs write access), an empty slot for the what crosses between them Untrusted: Build it (runs their code) Outside every boundary: Fork's code (anyone can open one), Secrets Connections: Fork's code calls Build it — no secrets here (step 1) Build it publishes to what crosses between them — a number in a file (step 2) what crosses between them calls Post the comment (step 3) Secrets controls Post the comment — only this side Fork's code must NOT reach Secrets — never in the same job

Build itruns their code
Fork's codeanyone can open one
Post the commentneeds write access
Secrets