Test what a fork pull request can do on this Gitea #89

Closed
opened 2026-11-11 22:02:56 +00:00 by Claude · 3 comments
Owner

Part of #87

Question

On this Gitea instance and version, what actually happens when an account with no write access opens a pull request from a fork?

Record, from a real test with an outsider account:

  • Does any workflow start without approval? Is there an approval step, and does it repeat for later pull requests from the same fork?
  • Do repository or organisation Actions secrets reach the run?
  • Is the job token read-only?
  • Which runner labels can the fork's workflow file reach?
  • What happens when the fork edits a workflow file?

Context

Gitea's documentation says fork pull request runs need approval, but an earlier test here saw a fork Build start with no approval step (the tester may have had write access, so it proved nothing for outsiders). The documentation does not state that secrets are withheld. Needs the maintainer and a throwaway account without access.

Part of #87 ## Question On this Gitea instance and version, what actually happens when an account with no write access opens a pull request from a fork? Record, from a real test with an outsider account: - Does any workflow start without approval? Is there an approval step, and does it repeat for later pull requests from the same fork? - Do repository or organisation Actions secrets reach the run? - Is the job token read-only? - Which runner labels can the fork's workflow file reach? - What happens when the fork edits a workflow file? ## Context Gitea's documentation says fork pull request runs need approval, but an earlier test here saw a fork Build start with no approval step (the tester may have had write access, so it proved nothing for outsiders). The documentation does not state that secrets are withheld. Needs the maintainer and a throwaway account without access.
Claude added the
Wayfinder
Task
label 2026-11-11 22:02:56 +00:00
Claude added a new dependency 2026-11-11 22:03:13 +00:00
Defame1297 was assigned by Claude 2026-11-13 14:45:12 +00:00
Author
Owner

Test checklist for the maintainer (2026-11-13)

Facts an agent could read without credentials: the instance reports Gitea 28.0.0; the repository is readable anonymously; the sign-up page answers (not proof that registration is open).

The agent cannot do the rest: it needs an account with no access to the organisation or the repository. Use a throwaway account, not a collaborator, not an org member, not an instance admin.

PR A: an innocent change (approval behaviour)

  1. As the outsider: fork the repository, change one word in README.md on a branch, open a pull request against main.
  2. Record: do Lint and Build start by themselves, or is there an approval banner or button? Is Molecule shown as skipped?
  3. If approval was asked: approve as the maintainer, then push a second commit to the same pull request. Is approval asked again?

PR B: a second pull request from the same fork

  1. Open a second pull request from another branch of the same fork. Is approval asked again, or is the fork now trusted?

PR C: the fork controls the workflow files

  1. On a new fork branch, add .gitea/workflows/probe.yml (below) and add a step - run: echo EDITED-BY-FORK as the first step of lint.yml. Open a pull request.
  2. Record:
    • Does Fork probe run at all (a new workflow file from a fork)?
    • Does the Lint log show EDITED-BY-FORK (head version of the workflow used)?
    • The PRESENT / empty line for each of the four names.
    • The HTTP code of each write probe (201 is a write that worked; 403/404 is refused).
    • Does the molecule job get picked up by the kamino-molecule runner, or stay waiting?
name: Fork probe
on: # yamllint disable-line rule:truthy
  pull_request:
permissions:
  contents: write
  issues: write
  pull-requests: write
  packages: write
jobs:
  docker:
    runs-on: kamino-docker
    container:
      image: git.rkdr.net/mortis/ci:0.2.15@sha256:32b6b44640b0864266fdabb37f7c9d1c8e83834753e63f69af9c0c8a1cc67eb1
    steps:
      - name: Secrets present? (names only, never values)
        env:
          PACKAGE_PUSH_USER: ${{ secrets.PACKAGE_PUSH_USER }}
          PACKAGE_PUSH_TOKEN: ${{ secrets.PACKAGE_PUSH_TOKEN }}
          RENOVATE_BOT_TOKEN: ${{ secrets.RENOVATE_BOT_TOKEN }}
          JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          for n in PACKAGE_PUSH_USER PACKAGE_PUSH_TOKEN RENOVATE_BOT_TOKEN JOB_TOKEN; do
            if [ -n "$(printenv "$n")" ]; then echo "$n: PRESENT"; else echo "$n: empty"; fi
          done
      - name: Job token write probes
        env:
          JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          API: ${{ github.api_url }}/repos/${{ github.repository }}
          PR: ${{ github.event.pull_request.number }}
        run: |
          python3 - <<'EOF'
          import json, os, urllib.error, urllib.request
          api, pr, tok = os.environ["API"], os.environ["PR"], os.environ["JOB_TOKEN"]
          def probe(label, path, body):
              req = urllib.request.Request(api + path, method="POST", data=json.dumps(body).encode(),
                  headers={"Authorization": "token " + tok, "Content-Type": "application/json"})
              try:
                  code = urllib.request.urlopen(req).status
              except urllib.error.HTTPError as err:
                  code = err.code
              print(f"{label}: HTTP {code}")
          probe("comment on the PR (issues write)", f"/issues/{pr}/comments", {"body": "fork probe: the job token can write"})
          probe("create a branch (contents write)", "/branches", {"new_branch_name": "probe/fork-token", "old_branch_name": "main"})
          EOF
  molecule:
    runs-on: kamino-molecule
    steps:
      - run: echo "reached kamino-molecule as $(id -un) on $(hostname)"

The probe prints no secret value and passes context values through env: only. If the branch probe returns 201, it created probe/fork-token in this repository.

Clean up

  1. Close the three pull requests, cancel any waiting run, delete probe/fork-token if it exists, delete the probe comment, then delete the fork and the throwaway account.

Report back

Paste the observations for steps 2, 3, 4 and 6 here or into the session; the resolution comment is written from them.

## Test checklist for the maintainer (2026-11-13) Facts an agent could read without credentials: the instance reports Gitea `28.0.0`; the repository is readable anonymously; the sign-up page answers (not proof that registration is open). The agent cannot do the rest: it needs an account with **no** access to the organisation or the repository. Use a throwaway account, not a collaborator, not an org member, not an instance admin. ### PR A: an innocent change (approval behaviour) 1. As the outsider: fork the repository, change one word in `README.md` on a branch, open a pull request against `main`. 2. Record: do Lint and Build start by themselves, or is there an approval banner or button? Is Molecule shown as skipped? 3. If approval was asked: approve as the maintainer, then push a second commit to the same pull request. Is approval asked again? ### PR B: a second pull request from the same fork 4. Open a second pull request from another branch of the same fork. Is approval asked again, or is the fork now trusted? ### PR C: the fork controls the workflow files 5. On a new fork branch, add `.gitea/workflows/probe.yml` (below) and add a step `- run: echo EDITED-BY-FORK` as the first step of `lint.yml`. Open a pull request. 6. Record: - Does `Fork probe` run at all (a new workflow file from a fork)? - Does the Lint log show `EDITED-BY-FORK` (head version of the workflow used)? - The `PRESENT` / `empty` line for each of the four names. - The HTTP code of each write probe (`201` is a write that worked; `403`/`404` is refused). - Does the `molecule` job get picked up by the `kamino-molecule` runner, or stay waiting? ```yaml name: Fork probe on: # yamllint disable-line rule:truthy pull_request: permissions: contents: write issues: write pull-requests: write packages: write jobs: docker: runs-on: kamino-docker container: image: git.rkdr.net/mortis/ci:0.2.15@sha256:32b6b44640b0864266fdabb37f7c9d1c8e83834753e63f69af9c0c8a1cc67eb1 steps: - name: Secrets present? (names only, never values) env: PACKAGE_PUSH_USER: ${{ secrets.PACKAGE_PUSH_USER }} PACKAGE_PUSH_TOKEN: ${{ secrets.PACKAGE_PUSH_TOKEN }} RENOVATE_BOT_TOKEN: ${{ secrets.RENOVATE_BOT_TOKEN }} JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | for n in PACKAGE_PUSH_USER PACKAGE_PUSH_TOKEN RENOVATE_BOT_TOKEN JOB_TOKEN; do if [ -n "$(printenv "$n")" ]; then echo "$n: PRESENT"; else echo "$n: empty"; fi done - name: Job token write probes env: JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }} API: ${{ github.api_url }}/repos/${{ github.repository }} PR: ${{ github.event.pull_request.number }} run: | python3 - <<'EOF' import json, os, urllib.error, urllib.request api, pr, tok = os.environ["API"], os.environ["PR"], os.environ["JOB_TOKEN"] def probe(label, path, body): req = urllib.request.Request(api + path, method="POST", data=json.dumps(body).encode(), headers={"Authorization": "token " + tok, "Content-Type": "application/json"}) try: code = urllib.request.urlopen(req).status except urllib.error.HTTPError as err: code = err.code print(f"{label}: HTTP {code}") probe("comment on the PR (issues write)", f"/issues/{pr}/comments", {"body": "fork probe: the job token can write"}) probe("create a branch (contents write)", "/branches", {"new_branch_name": "probe/fork-token", "old_branch_name": "main"}) EOF molecule: runs-on: kamino-molecule steps: - run: echo "reached kamino-molecule as $(id -un) on $(hostname)" ``` The probe prints no secret value and passes context values through `env:` only. If the branch probe returns `201`, it created `probe/fork-token` in this repository. ### Clean up 7. Close the three pull requests, cancel any waiting run, delete `probe/fork-token` if it exists, delete the probe comment, then delete the fork and the throwaway account. ### Report back Paste the observations for steps 2, 3, 4 and 6 here or into the session; the resolution comment is written from them.
Author
Owner

Resolution (2026-11-13)

Tested live on Gitea 28.0.0, runner v5.1.0, with an outsider account that has no access to the organisation or the repository. Evidence: pull requests #109 (README edit) and #110 (probe workflow plus an edited lint.yml), runs 3658 to 3667.

Question Answer
Does a workflow start without approval? No. Every run is created held ("Blocked by required conditions"), with no runner assigned and no step executed.
The approval step An "Approve all workflows" button on the pull request; one click releases every held run of that push.
Does approval repeat? Yes, for every push. A second commit to an already approved pull request was held again. A second pull request from the same fork was therefore not tested separately.
Do Actions secrets reach the run? No. PACKAGE_PUSH_USER, PACKAGE_PUSH_TOKEN and RENOVATE_BOT_TOKEN were all empty in the fork's own workflow.
Is the job token read-only? Yes for what was probed. The token is present, but posting a comment on the pull request and creating a branch both returned HTTP 403, although the fork's workflow asked for contents, issues, pull-requests and packages: write.
Which runner labels can the fork reach? Both, once approved. The fork's job on kamino-docker ran in the ci image, and its job on kamino-molecule ran on the host executor as gitea-runner.
What happens when the fork edits a workflow file? The fork's version is what runs. The step added to lint.yml executed, and the new probe.yml was registered as a fourth run. Both were held for approval like the rest.

What follows

  • The approval click is the only boundary. After it, the fork's code runs on both runner labels, including the root-equivalent host executor. The if: guard in molecule.yml skipped the repository's own Molecule job but did nothing to stop the fork's own job on the same label.
  • An approver must read the workflow diff of every push, not only the first: approval is per push and the head's workflow files are the ones used.
  • The earlier observation in the molecule.yml header (a fork Build starting at once, 2026-11-08) does not hold for an outsider; it belongs with the other stale claims.
  • The claim in lint.yml that the job token is read-only for a fork pull request is now verified for issues and contents.

Not tested

  • Whether approval stops being asked once the account has had a pull request merged (needs a merge to main).
  • Package writes with the job token (requested in permissions:, never exercised).
  • Whether the job token can read anything private in the organisation.
  • An account with read-only collaborator access, as opposed to no access.

Side effects

None in this repository: both write probes were refused, so no branch and no comment were created. Left for the maintainer: close #109 and #110 (three runs of #109 are still held), then delete the fork and the throwaway account.

## Resolution (2026-11-13) Tested live on Gitea `28.0.0`, runner `v5.1.0`, with an outsider account that has no access to the organisation or the repository. Evidence: pull requests #109 (README edit) and #110 (probe workflow plus an edited `lint.yml`), runs 3658 to 3667. | Question | Answer | |---|---| | Does a workflow start without approval? | **No.** Every run is created held ("Blocked by required conditions"), with no runner assigned and no step executed. | | The approval step | An "Approve all workflows" button on the pull request; one click releases every held run of that push. | | Does approval repeat? | **Yes, for every push.** A second commit to an already approved pull request was held again. A second pull request from the same fork was therefore not tested separately. | | Do Actions secrets reach the run? | **No.** `PACKAGE_PUSH_USER`, `PACKAGE_PUSH_TOKEN` and `RENOVATE_BOT_TOKEN` were all empty in the fork's own workflow. | | Is the job token read-only? | **Yes for what was probed.** The token is present, but posting a comment on the pull request and creating a branch both returned HTTP 403, although the fork's workflow asked for `contents`, `issues`, `pull-requests` and `packages: write`. | | Which runner labels can the fork reach? | **Both, once approved.** The fork's job on `kamino-docker` ran in the `ci` image, and its job on `kamino-molecule` ran on the host executor as `gitea-runner`. | | What happens when the fork edits a workflow file? | **The fork's version is what runs.** The step added to `lint.yml` executed, and the new `probe.yml` was registered as a fourth run. Both were held for approval like the rest. | ### What follows - The approval click is the only boundary. After it, the fork's code runs on both runner labels, including the root-equivalent host executor. The `if:` guard in `molecule.yml` skipped the repository's own Molecule job but did nothing to stop the fork's own job on the same label. - An approver must read the workflow diff of every push, not only the first: approval is per push and the head's workflow files are the ones used. - The earlier observation in the `molecule.yml` header (a fork Build starting at once, 2026-11-08) does not hold for an outsider; it belongs with the other stale claims. - The claim in `lint.yml` that the job token is read-only for a fork pull request is now verified for issues and contents. ### Not tested - Whether approval stops being asked once the account has had a pull request merged (needs a merge to `main`). - Package writes with the job token (requested in `permissions:`, never exercised). - Whether the job token can read anything private in the organisation. - An account with read-only collaborator access, as opposed to no access. ### Side effects None in this repository: both write probes were refused, so no branch and no comment were created. Left for the maintainer: close #109 and #110 (three runs of #109 are still held), then delete the fork and the throwaway account.
Author
Owner

Review of the map (2026-11-17).

Partly superseded by Establish how fork approval behaves on this server's Gitea version: approval is asked on every push only for an account with no merged pull request here and no Actions write access; after a first merged pull request Gitea runs the fork's pushes unapproved. This answers the first "Not tested" line from the source at the server's tag, not from a live test.

Review of the map (2026-11-17). Partly superseded by [Establish how fork approval behaves on this server's Gitea version](https://git.rkdr.net/Mortis/Kamino/issues/204): approval is asked on every push only for an account with no merged pull request here and no Actions write access; after a first merged pull request Gitea runs the fork's pushes unapproved. This answers the first "Not tested" line from the source at the server's tag, not from a live test.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: Mortis/Kamino#89