{"record":{"id":"1675773efaf1b102","repo":"wpscanteam/wpscan","slug":"the-browser-was-closed-or-failed-before-saml-authe","errorCode":null,"errorMessage":"The browser was closed or failed before SAML authentication could be completed (#{e.class}: #{e.message}).","messagePattern":"The browser was closed or failed before SAML authentication could be completed \\(#(.+?): #(.+?)\\)\\.","errorType":"exception","errorClass":"WPScan::Error::BrowserFailed","httpStatus":null,"severity":"error","filePath":"lib/wpscan/browser_authenticator.rb","lineNumber":42,"sourceCode":"    end\n\n    # Drives the interactive browser session and returns the resulting cookie jar.\n    # Translates Ferrum failures into BrowserFailed with a context-specific message.\n    def self.run_login_session(login_url)\n      browser = Ferrum::Browser.new(headless: false)\n\n      puts 'SAML authentication needed. Log in via the browser window that just opened, then press enter.'\n      browser.goto(login_url)\n      gets # Waits for user input\n\n      # Attempt an innocuous command to check if the browser is still responsive\n      browser.current_url\n\n      browser.cookies.all\n    rescue Ferrum::BinaryNotFoundError, Ferrum::EmptyPathError => e\n      raise WPScan::Error::BrowserFailed, chrome_not_found_message(e)\n    rescue Ferrum::Error => e\n      raise WPScan::Error::BrowserFailed,\n            'The browser was closed or failed before SAML authentication could be completed ' \\\n            \"(#{e.class}: #{e.message}).\"\n    ensure\n      browser.quit if browser&.process\n    end\n\n    def self.chrome_not_found_message(error)\n      '--expect-saml requires Chrome or Chromium to be installed and available on PATH ' \\\n        '(install Chrome / Chromium, or point Ferrum at a binary via BROWSER_PATH). ' \\\n        \"Underlying error: #{error.message}\"\n    end\n\n    def self.serialize_cookies(cookies)\n      cookies.map do |_name, cookie|\n        raise WPScan::Error::SAMLAuthenticationFailed if cookie.name.match?(COOKIE_DELIMITERS) ||\n                                                         cookie.value.to_s.match?(COOKIE_DELIMITERS)\n\n        \"#{cookie.name}=#{cookie.value}\"","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/wpscanteam/wpscan/blob/62c9cef471de90095f6b42245a11d0f8172d19c9/lib/wpscan/browser_authenticator.rb#L24-L60","documentation":"WPScan::Error::BrowserFailed raised by the catch-all Ferrum::Error rescue in run_login_session (lib/wpscan/browser_authenticator.rb:41-44). Any Ferrum failure other than a missing binary - browser window closed by the user, dead browser process, CDP connection lost, navigation errors - is translated into this message with the original class and message appended. Note the flow deliberately pokes browser.current_url after your enter keypress to detect a browser that died during login.","triggerScenarios":"User closes the Chrome window before (or right after) pressing enter, causing Ferrum::DeadBrowserError on browser.current_url or browser.cookies.all; Chrome crashing (OOM-killed on small containers); DevTools/CDP protocol mismatch between an outdated ferrum gem and a very new Chrome; browser.goto(login_url) failing on a bad URL.","commonSituations":"Users closing the 'extra' window thinking it is a popup; CI containers with too little memory for a graphical Chrome; old ferrum versions paired with freshly auto-updated Chrome; zombie chrome processes from a previous failed run holding the profile lock.","solutions":["Keep the Chrome window open until after you have pressed enter in the terminal, then let the code close it","Kill stale instances and retry: pkill -f chrome; then re-run wpscan --expect-saml","Update the gems (gem update wpscan ferrum) so CDP commands match your installed Chrome version","Give the environment enough memory (graphical Chrome needs a few hundred MB) or run on a desktop machine"],"exampleFix":"# before\n<user closes the Chrome window mid-login, then presses enter>\n# => BrowserFailed: The browser was closed or failed before SAML authentication could be completed (Ferrum::DeadBrowserError: Browser is dead)\n\n# after\n<leave the Chrome window open, finish login, press enter>\n# => cookies captured, scan proceeds","handlingStrategy":"try-catch","validationCode":"# Cheap liveness preflight: make sure no stale chrome holds locks\nsystem('pkill -f chrome.*remote-debugging') || true","typeGuard":null,"tryCatchPattern":"begin\n  cookies = WPScan::BrowserAuthenticator.run_login_session(login_url)\nrescue WPScan::Error::BrowserFailed => e\n  if e.message.include?('closed or failed')\n    retry if (attempts += 1) < 2 # browser died; one clean retry after killing leftovers\n  end\n  raise\nend","preventionTips":["Keep the login window open until after pressing enter; the code closes Chrome itself via browser.quit","Give containers enough memory for a graphical Chrome session","Keep ferrum/wpscan updated so the CDP dialect matches the installed Chrome major version"],"tags":["saml","ferrum","chrome","cdp","browser-crash","wpscan","ruby"],"backgroundTag":"headless-browser-crashed","analyzedSha":"62c9cef471de90095f6b42245a11d0f8172d19c9","analyzedAt":"2026-08-21T17:10:47.902Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}