llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Go · gogs.io/gogs

GHSA-7CVR-7CFF-2MRG

LDAP login selects the local account by email while the directory identity is searched by uid: an unrelated directory entry whose uid attribute equals a victim's Gogs email authenticates as that account - including site admins

Sin parche publicado
Descargar PNG JSON
CVSS
—
medium
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición3 dDesde la divulgación, 18 nov 2026, 1:52 p. m.
Detección4 hDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de la severidad declarada por GHSA (media) y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. No hay versión corregida: aplique mitigaciones.
Bien priorizada, bien dormida.Nivel de alerta: llama mascando hierba.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
18 nov 26
22 nov 26
18 nov 26
19 nov 26
20 nov 26
21 nov 26
22 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-7CVR-7CFF-2MRG divulgada
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
GitHub

PVR Report - gogs/gogs - F-2177

## Suggested title
LDAP login selects the local account by email while the directory identity is searched by uid: an unrelated directory entry whose uid attribute equals a victim's Gogs email authenticates as that account - including site admins

## Affected package and versions
- Repository: gogs/gogs
- Product and version tested: Gogs v0.14.4, isolated same-tag instance (container i20265-gogs144, SQLite backend, http://127.0.0.1:3105)
- Affected subcomponents: internal/database/users.go (the email-branch account selection in Authenticate), internal/auth/ldap/config.go (the uid-filter directory search), and every entry that funnels into them - the web login form POST /user/login, API Basic auth on /api/v1/*, and git smart-HTTP

## Suggested severity
High - the attacker needs no victim credentials at all: a directory entry they control, whose uid attribute happens to be the victim's Gogs email string, plus their own directory password, yields the victim's full account, including site-admin accounts with instance-wide reach.

Description

### Summary
Two different string matchers decide one LDAP login in Gogs 0.14.4, and they do not have to agree on the same person. Account selection happens first, in the database layer: if the submitted login string contains an @, Gogs selects the local row with WHERE email = ?; otherwise it matches lower_name. Authentication happens second, in the LDAP layer: the provider searches the directory with the configured filter (uid=%s) for exactly one entry and binds with that entry's DN plus the submitted password. If the bind succeeds, Gogs returns the row it picked in step one. The directory entry that got authenticated and the local row that gets returned are never compared - there is no external id, and no check that they describe the same person. The consequence: any directory entry whose uid attribute contains another user's Gogs email (uid attributes in email or UPN form are a common enterprise convention) authenticates into that user's account. I verified this against a site-admin account: a zero-relation directory entry with uid=admin@corp logged in as the admin, with its session, its API Basic access and its git clone of a private repository all confirmed. The same mechanism worked for a non-admin victim account, and local accounts correctly rejected the mismatched login source.

### Preconditions
1. The instance has an LDAP authentication source configured (in my fixture, login_source id=1; account and directory are separate identities).
2. The directory contains an entry whose uid attribute is written in email or UPN form - a common enterprise convention - and that entry is controlled by the attacker (in my test: uid=victim@corp, or for the admin case uid=admin@corp, with the attacker holding that entry's password).
3. The victim is an existing account created through LDAP (user.login_source=1) whose Gogs email equals that uid string (for the admin case, the victim was the site admin gogsadm with email admin@corp.test).
4. The attacker holds no victim credentials and has no relationship to the victim.

### Steps to reproduce
1. Submit the login form as the attacker with the victim's email as the username and the attacker's directory password: POST /user/login with user_name=admin@corp, password=AtkPass#2026, login_source=1.
2. With the resulting session, open GET /admin and GET /admin/users to confirm admin reach, and read a private raw file: GET /gogsadm/priv/raw/master/SECRET.txt.
3. Repeat over API Basic: GET /api/v1/repos/gogsadm/priv with Basic admin@corp:AtkPass#2026.
4. Repeat over git: git clone http://admin%40corp:AtkPass%232026@127.0.0.1:3105/gogsadm/priv.git (credentials in URL form).
5. Run the same procedure with a non-admin victim: POST /user/login with user_name=victim@corp (an existing LDAP account, id=3) and the directory password of the entry holding that uid.
6. Control: try the same form against a local account (login_source=0, e.g. i20265root or root@i20265.test).
7. Control: try the web login with a wrong password.

### Observed evidence
Verbatim measurements from my run:

POST /user/login  user_name=admin@corp & password=AtkPass#2026 & login_source=1
-> 302  /
GET  /admin                    -> 200
GET  /admin/users              -> 200
GET  /gogsadm/priv/raw/master/SECRET.txt   -> 200  SECRET_I20265_PRIV_9f3a2c7d
     (session subject: gogsadm, id=2, is_admin=1)

GET  /api/v1/repos/gogsadm/priv   (Basic admin@corp:AtkPass#2026)
-> 200  (owner id=2, private=true)
git clone with the same credentials  -> rc=0
origin/master:SECRET.txt             -> SECRET.txt (plaintext secret file content)

uid=victim@corp   -> logs in as the existing victim account (id=3)

wrong password on the web login       -> 401
wrong password on git                 -> rc=128
local account + login_source=1 (i20265root / root@i20265.test)
                                      -> 422  (auth source mismatch - the
                                         login_source check works)

### Root cause
1. internal/database/users.go:65-73 - Authenticate lowercases the submitted login; if it contains an @, the account row is selected with WHERE email = ? (otherwise lower_name = ?). This is the account that will be returned on success.
2. :82-89 - the only additional condition is that the row's numeric login_source equals the selected source id; email equality with any directory attribute is never required.
3. :96-120 - for a non-local source, the code calls source.Provider.Authenticate(login, password) with the same submitted string. internal/auth/ldap/config.go:108-151 searches the directory with the configured filter ((uid=%s)) and requires exactly one entry, then binds with that entry's DN plus the submitted password (:223-229, :332-338). If the bind succeeds, :120 returns the database row selected earlier by email. The directory entry that was authenticated and the local row that is returned are never compared; there is no external_id column and no binding table in the schema.
4. The entry points all funnel into the same two matchers: the web login form, API Basic auth on /api/v1/*, and git smart-HTTP.

### Impact
A zero-relation directory entry takes over any account whose login_source is the LDAP source and whose email appears as some entry's uid attribute. In my measurement that included a site-admin account, with its admin panel, its private repositories over raw, API Basic and git, and therefore the ability to administer the instance. The mechanism is generic for any LDAP account on the instance; the admin case is simply the highest-value instance of it. The impact spans identity confusion and cross-account access on every entry point that accepts the credentials.

### Suggested fix
Make the row-selection key and the authentication key the same thing. After a successful LDAP bind, resolve the account through an immutable directory identifier - entryUUID, objectGUID or the entry DN - stored in a binding table (an external_id column with a unique index, or an external_login_user table keyed by login_source_id + external_id). On first binding, require a verified email match or an admin confirmation before attaching an existing account. Remove the "contains @ implies email" selection branch for external sources; if email-form logins must be supported for LDAP accounts, verify that the IdP-returned identity (the found entry's canonical uid and its mail attribute) matches the local row before accepting the login. Add a regression test: a zero-relation entry whose uid equals a victim's email must fail to log in (401/422), on the web form, on Basic and on git.

## Notes for the maintainers
I can provide the LDAP fixture (the directory tree, the Gogs login source configuration and the exact attribute values) to help you validate a fix. My internal rule mapping tags this as CWE-287 (improper authentication), CWE-639 (authorization bypass through user-controlled key) and CWE-863 (incorrect authorization). I would prefer coordinated disclosure with a 90-day timeline before public disclosure.

Versiones

Rangos afectados

Afectada Corregida Última
gogs.io/gogs< 0.15.0
v0.13.3
0.15.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
gogogs.io/gogs
Sin parche — — v0.13.3 afectada
Versiones corregidas0.15.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/gogs/gogs/security/advisories/GHSA-7cvr-7cff-2mrg

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.