CVE-2026-20779: Gitea: TOTP TOCTOU race on web 2FA paths + missing replay check on Basic-Auth `X-Gitea-OTP` surface
I’m reporting two related TOTP one-time-use defects in Gitea that survive the CVE-2021-45331 fix. The 2018 fix (PR #3878) introduced the TwoFactor.LastUsedPasscode field and added an in-memory inequality check on the web 2FA login path. That check works correctly in the single-request case, but it leaves two follow-up gaps:
A TOCTOU race on the web surfaces (Defect 1). The read-validate-check-save sequence against the
two_factorrow is not atomic. Two parallel submissions of the same passcode each load their own in-memory copy whereLastUsedPasscodestill holds the prior value; both pass the inequality check, both authenticate, and both then write the same new value back. Net effect: the same OTP redeems for two independent logged-in sessions.No
LastUsedPasscodecheck at all on the Basic-Auth API surface (Defect 2).services/auth/basic.gocallstwofa.ValidateTOTP(...)forX-Gitea-OTPwithout ever reading or writingLastUsedPasscode. The same six-digit code is replayable for the fulltotp.Validateacceptance window (~60–90 s with the defaultSkew=1). This is a clean RFC 6238 §5.2 violation independent of timing, shaped identically to the pre-CVE-2021-45331 behaviour but scoped to the API / Git-over-HTTPS basic-auth path instead of the web form.
Both defects post-date the 2018 fix; neither is referenced in any published Gitea advisory I could find. I’m filing this as a follow-up to CVE-2021-45331, not a duplicate.
References
- blog.gitea.com/release-of-1.26.3-and-1.26.4
- github.com/advisories/GHSA-gx3v-q759-g323
- github.com/go-gitea/gitea/commit/99f8b3d9a1d32f4c39828e07971455a18191e0b9
- github.com/go-gitea/gitea/pull/38151
- github.com/go-gitea/gitea/releases/tag/v1.26.3
- github.com/go-gitea/gitea/security/advisories/GHSA-gx3v-q759-g323
- nvd.nist.gov/vuln/detail/CVE-2026-20779
Code Behaviors & Features
Detect and mitigate CVE-2026-20779 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →