Kestrel
대시보드로 돌아가기
CVE-2026-58271MEDIUM· 6.8MITRENVDGHSA대응게시일: 2026. 09. 21.수정일: 2026. 09. 22.

@sync-in/server vulnerable to TOTP Brute-Force via `POST /api/app/sync/register`

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
6.8medium

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도높음
필요 권한낮음
사용자 상호작용불필요
범위불변
영향
기밀성 영향높음
무결성 영향높음
가용성 영향없음
버전별 점수
CVSS 3.16.8MODERATE
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N

상세 설명

Affected component: Sync-in Server v2.3.0, POST /api/app/sync/register.

Required attacker capability: Valid login and password for a TOTP-enabled account with desktop sync permission.

Summary

POST /api/app/sync/register accepts credentials and a TOTP code to register a desktop sync client. In the vulnerable version, on a failed TOTP attempt, SyncClientsManager.register() called updateAccesses(user, ip, false), which hit a freeze branch that wrote passwordAttempts back unchanged. The counter never reached USER_MAX_PASSWORD_ATTEMPTS (10), so the account lockout gate never fired for repeated TOTP failures through this endpoint.

A successful TOTP guess registers a sync client and returns a {clientId, clientToken} pair, provided the account has the required desktop app permission and the registration payload is valid. The token can then be exchanged via POST /api/app/sync/auth/cookie for an authenticated session. While the guessed TOTP code is still valid, and because the attacker already knows the password, the attacker can also call POST /api/auth/2fa/disable to remove MFA.

Details

The endpoint is declared at sync.controller.ts line 71. @AuthTokenSkip() bypasses the bearer-token guard, so the route is reachable without any prior session:

text
1@Post(SYNC_ROUTE.REGISTER)
2@AuthTokenSkip()
3register(@Body() syncClientRegistrationDto: SyncClientRegistrationDto, @Req() req: FastifyRequest): Promise<SyncClientAuthRegistration> {
4 return this.syncClientsManager.register(syncClientRegistrationDto, req.ip)
5}

Inside SyncClientsManager.register(), after both the TOTP code and the recovery code are rejected, the handler fires a fire-and-forget access update and throws (sync-clients-manager.service.ts line 73):

text
1this.usersManager.updateAccesses(user, ip, false).catch((e: Error) => this.logger.error({ tag: this.register.name, msg: `${e}` }))
2throw new HttpException(authCode.message, HttpStatus.UNAUTHORIZED)

In the vulnerable version, updateAccesses() at users-manager.service.ts line 182 defaulted isAuthTwoFa to false:

text
1async updateAccesses(user: UserModel, ip: string, success: boolean, isAuthTwoFa = false) {
2 let passwordAttempts: number
3 if (!isAuthTwoFa && configuration.auth.mfa.totp.enabled && user.twoFaEnabled) {
4 passwordAttempts = user.passwordAttempts
5 } else {
6 passwordAttempts = success ? 0 : Math.min(user.passwordAttempts + 1, USER_MAX_PASSWORD_ATTEMPTS)
7 }
8 await this.usersQueries.updateUserOrGuest(user.id, {
9 ...
10 passwordAttempts: passwordAttempts,
11 isActive: user.isActive && passwordAttempts < USER_MAX_PASSWORD_ATTEMPTS
12 })
13}

When register() called updateAccesses(user, ip, false), isAuthTwoFa defaulted to false. The condition on line 184 evaluated to true when TOTP was enabled site-wide and the account had it active. The else branch with Math.min(user.passwordAttempts + 1, ...) was never reached. passwordAttempts was written back unchanged, and the lockout gate in validateUserAccess() at line 89 never fired for repeated TOTP failures through this endpoint.

The freeze was designed for the web login flow, where a correct password at POST /api/auth/login produces a partial session and the counter should be preserved until POST /api/auth/2fa/login/verify completes. That route calls authProvider2FA.verify(body, req, true), which passes isAuthTwoFa=true into updateAccesses() and correctly increments on 2FA failure. The register() endpoint reused updateAccesses() for an outright TOTP rejection while passing the default isAuthTwoFa=false, triggering the freeze incorrectly.

The same freeze also applied to logUser() (users-manager.service.ts line 69), called by both POST /api/auth/login and POST /api/auth/token. On a wrong password for a 2FA-enabled account, updateAccesses(user, ip, false) was called without an isAuthTwoFa argument, so the freeze fired and passwordAttempts was preserved rather than incremented.

PoC

First, create a test account with TOTP MFA enabled and desktop sync permission. Then run the following:

poc_totp_bruteforce.py

bash
1$ python3 poc_totp_bruteforce.py --url http://192.168.16.132:8080 --user mfatest --password 'Str0ngP@ss99!' --concurrency 4 --batch 100

Example output:

text
1[*] Target : http://192.168.16.132:8080
2[*] Account : mfatest
3[*] Concurrency : 4
4
5[*] Step 1: Confirming credentials and 2FA status...
6[+] Credentials valid, 2FA active.
7
8[*] Step 2: Brute-forcing TOTP codes (4 workers)...
9 Ranges: W0=000000-250000, W1=250000-500000, W2=500000-750000, W3=750000-1000000
10 [W2] 1,100 total | 11.3 req/s | retries: 0
11 <snip>
12 [W1] 195,400 total | 11.0 req/s | retries: 0
13
14[*] Step 3: Results
15 Total attempts : 195,907
16 Time elapsed : 17769.5s (296.2min)
17 Average RPS : 11.0
18
19[+] VALID TOTP CODE FOUND : 026961
20[+] clientId : 13951b88-03d4-4854-8a29-cd8921d73d82
21[+] clientToken : c92ef5ca-7432-44d0-8a94-56398bfe4117
22
23[*] Step 4: Confirming access and attempting to disable 2FA...
24 [+] Authenticated as : mfatest (id=3, role=1)
25 passwordAttempts : 0
26 [+] 2FA DISABLED. Account 'mfatest' now accessible with password alone.

Measured observations:

  • No account lockout was observed across 195,907 failed TOTP attempts in this test against the vulnerable version.
  • The clientToken was exchanged for an authenticated session.
  • MFA was disabled via POST /api/auth/2fa/disable while the guessed TOTP code was still valid and because the attacker already knew the account password.

Impact

An attacker who already knows valid credentials for a TOTP-enabled account with desktop sync permission can brute-force the second factor through POST /api/app/sync/register without triggering account lockout.

With drift: 1, 3 of 1,000,000 six-digit codes are valid per 30-second window (p = 3/1,000,000), giving an expected 333,333 attempts to find a valid code.

At 3 r/s, measured against a default single-worker deployment:

Success probabilityAttemptsTime at 3 r/s
50%231,04921.4 h
90%767,52871.1 h
95%998,57792.5 h
99%1,535,056142.1 h
Expected (mean)333,33330.9 h

Deployments with server.workers > 1 may allow higher throughput, depending on CPU capacity and other bottlenecks. Throughput is heavily influenced by server-side password verification cost, worker count, database latency, and deployment limits, not only by the attacker's network speed.

Remediation

Add && success to the freeze condition at users-manager.service.ts line 184:

text
1// Before
2if (!isAuthTwoFa && configuration.auth.mfa.totp.enabled && user.twoFaEnabled) {
3
4// After
5if (!isAuthTwoFa && configuration.auth.mfa.totp.enabled && user.twoFaEnabled && success) {

The freeze still applies when a password succeeds but 2FA is pending, which was its intended purpose. A failed TOTP at register() and a failed password at login/token both fall through to the increment path, restoring lockout after 10 failures.

For defense-in-depth, apply an IP and/or account-based rate limiter to POST /api/app/sync/register and other pre-auth credential endpoints.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.