The pull_request event runs a workflow from the base branch with a read-only token and no access to secrets for forked pull requests. The pull_request_target event exists to give maintainers a way to run trusted automation on fork PRs: it evaluates the workflow file from the base branch and grants the full repository secrets and a writable GITHUB_TOKEN.
The vulnerability appears when such a workflow explicitly checks out the pull request head, for example actions/checkout with ref: ${{ github.event.pull_request.head.sha }}, and then runs anything from that tree, including a build script, a linter configured by a checked-in config file, or a dependency install that executes lifecycle scripts. Any fork author can then exfiltrate every repository secret.
If untrusted code must be built, use pull_request and accept the reduced permissions, or split the job: build in an unprivileged pull_request workflow, upload artifacts, and process them in a separate workflow_run workflow that never checks out fork code. GitHub documents this pattern explicitly as the keep-your-actions-secure guidance.