pull_request_target reads secrets, and that is the point and the danger

A workflow triggered by pull_request from a fork has no secrets, deliberately. pull_request_target runs in the context of the base repository and does have them.

# safe: runs the fork's code with NO secrets
on: pull_request

# dangerous: has secrets, and MUST NOT check out the fork's code
on: pull_request_target
jobs:
  label:
    steps:
      - uses: actions/github-script@v3    # no checkout at all
        with:
          script: |
            github.issues.addLabels({ ... })

Combining pull_request_target with actions/checkout pointed at the pull request head is the specific mistake, and it hands every secret in the repository to anyone who can open a pull request. It is a documented footgun that appeared in a great many published workflows during 2020. The legitimate uses are labelling, commenting and triage — anything that acts on the metadata rather than on the code.