Skip to content

Live account login fails when IB Key (mobile 2FA) is enabled #111

@nbopardi

Description

@nbopardi

Summary

Accounts with IB Key (mobile 2FA) enabled cannot connect. After SRP authentication completes, the IB server enters a second-factor challenge loop sending type-530 keepalive messages while waiting for IB Key approval on the user's mobile device (notification is never received). ibx has no mechanism to participate in this challenge, so the post-auth phase times out with "Never received data start after auth" (gateway.rs:592).

Current State

Aspect Status
SRP auth (username + password) Worksdo_srp completes, session token obtained
Soft token challenge (farm-level 35=S) Worksdo_soft_token responds to farm auth challenges (gateway.rs:188)
IB Key 2FA (login-level) Not supported — server sends NS keepalives (type 530), ibx loops until timeout
Paper accounts (no 2FA) Works — full connection including all farms

What Happens

  1. SRP authentication succeeds, NS_CONNECT_RESPONSE (type 523) is received
  2. Port type change is sent, server acknowledges
  3. Instead of NS_FIX_START (type 525), server sends repeated type-530 messages — these are keepalives while IB waits for the user to approve the login on their mobile IB Key app (mobile notification never received)
  4. The post-auth loop in gateway.rs:540–594 doesn't recognize these as a 2FA challenge and logs them as "Post-auth msg type=530"
  5. After the loop exhausts its iterations, it returns "Never received data start after auth"

What Was Tried

  • Adding FLAG_SOFT_TOKEN to connection flags — server rejects; SOFT_TOKEN (xyz.rs:14) is for farm-level XYZ auth challenges, not the initial login 2FA gate
  • Proactively sending a SOFT_TOKEN init — server rejects this as well

What's Needed

IB Key 2FA is a server-side push notification flow. The server waits for the user to tap "approve" in the IB Key mobile app. ibx needs to:

  1. Detect the 2FA-pending state (type-530 keepalives after NS_CONNECT_RESPONSE but before NS_FIX_START)
  2. Active the push notification to the user
  3. Wait with periodic keepalive responses until the user approves (or a configurable timeout)
  4. Resume normal post-auth flow once NS_FIX_START arrives

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions