CVE Watchtower

CVE-2026-82401gogs.io/gogs Argument Injection

NVD

Vulnerability Summary

Summary The `DiffBinary()` function in gogs/git-module passes user-controlled branch names to `git diff --full-index --binary <base> <head>` without `--end-of-options`. An attacker who pushes a branch named `--output=/path/to/target` can trigger arbitrary file writes on the server by creating a pull request. Details Root Cause `git-module/repo_diff.go:163-173` constructs the diff command as: ```go cmd := NewCommand("diff", "--full-index", "--binary", base, head) ``` When `head = "--output=/path/to/target"`, git interprets it as the `--output` option, writing diff content to an attacker-specified path. Data Flow 1. Attacker pushes branch named `--output=/tmp/pwned` via: `git update-ref 'refs/heads/--output=/tmp/pwned' HEAD && git push origin 'refs/heads/--output=/tmp/pwned'` 2. Attacker creates PR via compare URL: `/:owner/:repo/compare/main...--output=/tmp/pwned` 3. `ParseCompareInfo` at `route/repo/pull.go:462,470` parses `headRef = "--output=/tmp/pwned"` from URL 4. `RevParse("--output=/tmp/pwned")` at line 532 β€” succeeds (git rev-parse doesn't recognize `--output` as its own option, exits 0) 5. `MergeBase` with `--end-of-options` at line 664 β€” resolves the branch ref to a commit hash, succeeds 6. `headGitRepo.DiffBinary(meta.MergeBase, "--output=/tmp/pwned")` at line 716 7. Executes: `git diff --full-index --binary <hash> --output=/tmp/pwned` 8. Git writes the diff output to `/tmp/pwned` Why Gogs Doesn't Block This - Branch name validation: Gogs has NO branch name validation during push. The pre-receive hook checks only that the refname is non-empty. - `git check-ref-format`: Accepts `=` and `--` prefix in ref names. `--output=/tmp/pwned` is a valid git refname. - `RevParse` is not a guard: `git rev-parse` echoes unrecognized `--` flags back without error (exit 0), so it passes for malicious inputs. - `MergeBase` has `--end-of-options`: But this only protects the merge-base command itself β€” it correctly resolves the branch as a revision. The vulnerable `DiffBinary` call comes AFTER. Relationship to Existing Fixes GHSA-qf6p-p7ww-cwr9 added `--end-of-options` to `git rebase`, `git merge`, `git checkout`, and `git push` in `internal/database/pull.go`. The `git diff` command in `git-module/repo_diff.go:DiffBinary()` was NOT included in this fix. GHSA-cf29-q2mc-vf3j covers `git checkout` in git-module β€” this is a different function (`DiffBinary`) with a different primitive (file write vs flag injection). Impact - Arbitrary file write on server filesystem (any path writable by Gogs process user) - Content is partially attacker-controlled (git diff format β€” attacker controls file content in commits) - Requires authenticated user with write access to push branch + create PR - File content starts with `diff --git a/...` header, limiting direct RCE (not a valid script/key format) - Can overwrite/corrupt server files (DoS), or write to paths with loose format requirements Reproduction ```bash As repo owner/collaborator: git update-ref 'refs/heads/--output=/tmp/gogs_pwned' HEAD git push origin 'refs/heads/--output=/tmp/gogs_pwned:refs/heads/--output=/tmp/gogs_pwned' Create PR (or just visit compare URL): curl -X POST "http://gogs:3000/user/repo/compare/main...--output=/tmp/gogs_pwned" \ -H "Cookie: <session>" \ -d "title=test" Verify: ls -la /tmp/gogs_pwned # File exists with diff content ``` Recommended Fix Add `--end-of-options` before positional arguments in `DiffBinary()`: ```go cmd := NewCommand("diff", "--full-index", "--binary", "--end-of-options", base, head) ``` Also apply to `Pull()`, `Reset()`, and `RevParse()` in git-module for defense-in-depth.
Severity Level
CRITICAL(9.6)
Published Date
Nov 24, 2026
Last Modified
Nov 24, 2026
Exploitation Status
No confirmed exploitation yet
CVE Record Status
Reserved
This CVE ID is referenced in a public advisory, but the CVE Program has not published its official CVE Record yet. Full CVSS/CPE data from NVD will appear here once it does.
Root Weakness (CWE)
The product constructs a string for a command to be executed by a separate component, but it does not properly delimit the intended arguments, options, or switches within that string.
CVSS v3.1 Base Metrics — Score 9.6
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:H/A:H
Attack VectorNetwork
Attack ComplexityLow
Privileges RequiredLow
User InteractionNone
ScopeChanged
ConfidentialityNone
IntegrityHigh
AvailabilityHigh

Affected & Patched Versions

Affected Versions
  • gogs.io/gogs <= 0.14.3
Patched Versions
  • gogs.io/gogs 0.14.4

What to do

Plan remediation soon. No exploitation is confirmed yet, but the severity is critical.

  1. Check whether you run gogs.io/gogs and which version.
  2. Update to a patched version listed above, then confirm the new version.

Timeline

  • Nov 24, 2026Published
  • Nov 24, 2026Record last modified

Score, severity and exploitation changes are tracked from the day Watchtower started logging them.

Get notified about new gogs.io/gogs CVEsYou are reading CVE-2026-82401. Get an email when KEV listings, exploits or new CVEs match your stack.
Set up CVE alerts

Data last checked: Nov 25, 2026 03:02 UTC