Chatwoot v4.19.1 - High: 8.1 - Remote - MFA bypass - SSO sign-in returns before the MFA gate
Chatwoot's SSO sign-in returns before the password path's MFA check. A valid sso_auth_token produces a full session for an MFA-enrolled user with no TOTP challenge, and skips enforced MFA enrolment on the same account. The password path on that account is gated, which is the control.
Class: Authentication bypass (MFA) Reach: Remote, holder of a valid SSO token
Chatwoot v4.19.1 - caab07a8
| ID | no CVE yet |
| Class | Authentication bypass (MFA) |
| Reach | Remote (any valid sso_auth_token) |
| CWE | CWE-287 / CWE-304 |
| CVSS | High: 8.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N |
| Product | Chatwoot |
| Affected | v4.19.1 caab07a8f00032d5205b5a5d7e2eb0ba2f3d2d82 |
| Auth | a valid SSO token for the target user |
| License | GNU Affero GPL v3.0 |
| Lab | loopback Docker compose; Postgres, Redis, Puma, Sidekiq |
The precondition matters and it is why the score is not higher: the token is the thing the attacker must already hold. The bug is that holding it is enough. TOTP exists to stop exactly the case where the first factor is compromised, and on this path it is never asked for.
| Privilege | Method / sink | Recon / integrity / availability | Lab-proven or inferred |
|---|---|---|---|
| Sign in as an MFA-enrolled user with no TOTP | POST /auth/sign_in {email, sso_auth_token} | Integrity (session) | Lab-proven. 200 plus usable headers |
| Skip enforced MFA enrolment | same path for a user with no second factor | Integrity (policy) | Lab-proven. 200, no mfa_setup_required |
| Reach any API the user can reach | GET /api/v1/profile and beyond | Depends on the user | Lab-proven for profile |
| Obtain the token | OAuth callback, generate_sso_link, or an intercepted redirect | Recon | Inferred; the token is minted into a URL and lives five minutes |
| Escalate to super-admin tooling | the user's role | Depends on the user | Not tested |
| Use an expired or random token | Mfa::TokenService / Redis lookup | n/a | Closed: lab returns 401 for a wrong token |
Stays closed on this leftover
| Axis | Method / sink | Why it is closed |
|---|---|---|
| Integrity | Password login without TOTP | password_pre_auth_intercepted? returns 206 mfa_required |
| Integrity | Password login without enrolment | 206 mfa_setup_required |
| Integrity | Forged SSO token | Redis-backed token lookup; 401 |
| Integrity | SAML users in enforced accounts | mfa_enforcement_applies? exempts saml deliberately |
| Recon | Session without a token | The SSO branch requires params[:sso_auth_token].present? |
The sessions controller is a sequence of early returns:
def create
return handle_mfa_setup_verification if mfa_setup_verification_request?
return handle_mfa_verification if mfa_verification_request?
return handle_sso_authentication if sso_authentication_request?
return if password_pre_auth_intercepted?
super
end
password_pre_auth_intercepted? is the only caller of the MFA gate:
def password_pre_auth_intercepted?
user = find_user_for_authentication
return false unless user
if user.mfa_enabled?
handle_mfa_required(user)
return true
end
...
if user.mfa_enforcement_pending?
handle_mfa_setup_required(user)
return true
end
...
end
handle_sso_authentication returns two lines earlier. It calls authenticate_resource_with_sso_token, which calls create_token, sign_in and render_create_success directly. Nothing between the token check and the session asks about otp_required_for_login?.
The enforcement guard does exist, but it is wired to the wrong callback: MfaEnforcementGuard runs if: :authenticate_by_access_token?, so it covers token-authenticated API requests, not a fresh SSO login. mfa_enforcement_applies? also exempts only saml, which confirms that OAuth providers were meant to be in scope.
Wrong turns: I first expected the SSO path to 403 through the guard, and wrote the PoC to look for that. It returns 200 with access-token, client and uid headers. The lab now asserts the session is usable by calling GET /api/v1/profile and matching the email in the body, so a 200 that does not actually authenticate would fail.
python3 chatwoot-sso-mfa-bypass-Abraxas-Labs.py
or:
cd lab
./run.sh
One tenant with enforce_mfa = true and three administrators sharing a password: control@ (password login, MFA enrolled), oauth@ (OAuth provider, MFA enrolled), pending@ (OAuth provider, no MFA). run.sh mints the two SSO tokens with rails runner immediately before the PoC runs, because they expire after five minutes.
IOC control_password status=206 mfa_required=True
IOC control_pending_password status=206 mfa_setup_required=True
IOC control_bad_sso_token status=401
IOC mfa_enrolled_user_sso status=200 token_issued=true profile_status=200
IOC mfa_pending_user_sso status=200 enrolment_skipped=true profile_status=200
SUCCESS CHATWOOT-F5-SSO-MFA-BYPASS account=1 enforce_mfa=True control_password_mfa_required=true control_enrolment_required=true sso_mfa_enrolled_user_session=true sso_enrolment_skipped=true SSO-BYPASSES-MFA
run.sh tears the stack down on exit.
Run the MFA decision before the SSO branch, or inside handle_sso_authentication after the token resolves the user:
return handle_mfa_required(user) if user.mfa_enabled?
return handle_mfa_setup_required(user) if user.mfa_enforcement_pending?
Both paths should converge on sign_in_mfa_user after the second factor. The guard's authenticate_by_access_token? condition is the reason this slipped through, so the check belongs on the user, not on the callback that happens to run.
caab07a8f00032d5205b5a5d7e2eb0ba2f3d2d82devise_overrides/sessions_controller.rbdevice_verification_guard.rbmfa_enforcement_guard.rbGNU Affero GPL v3.0. See LICENSE. Loopback lab only. No warranty.
Abraxas Labs [email protected]