bug: setup_forge has ~6 other anonymous curl checks for user/repo existence, all fail with 403 on locked-down forgejos #582
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#582
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
lib/forge-setup.shuses unauthenticated curl calls to check whether users and repos exist before creating them. Grep forcurl -sf --max-time 5in that file surfaces at least these unauthenticated calls:On a forgejo with
FORGEJO__service__REQUIRE_SIGNIN_VIEW=true(the stock disinto compose setup), all of these return HTTP 403 regardless of whether the user/repo actually exists. Init then treats the 403 as "does not exist" and tries to create the resource. In most cases the creation call uses basic auth or a token and succeeds or safely fails, but:disinto-admin→ forgejo CLI errors withCommand error: CreateUser: user already exists [name: disinto-admin]→ init abortsReproduction
REQUIRE_SIGNIN_VIEW=truebin/disinto init <repo-url> --yesa second time (first time created users, so they now exist)Environment
REQUIRE_SIGNIN_VIEW=trueFix
Add
-H "Authorization: token ${FORGE_TOKEN:-}"to every user/repo-existence curl call inlib/forge-setup.sh. Example one-liner patch I used to complete the init run during my experiment:More broadly, consider auditing every
curl -sfcall inlib/*-setup.shscripts and establishing a helper wrapper (likeforgejo_api_get/forgejo_api_head) that always attaches the token. This would prevent the same bug from being reintroduced in future additions.Related
Sister issue: the reachability check on line 53 (filed separately). Both are instances of the same pattern — unauthenticated API calls that assume forgejo's default (unprotected) config.
Context
Discovered while running
bin/disinto initas an idempotency experiment on harb-dev-box. Patched locally to complete the run. Part of a cluster of ~9 init bugs found in that session.