wpscanteam/wpscan · error · WPScan::Error::BrowserFailed
The browser was closed or failed before SAML authentication
Error message
The browser was closed or failed before SAML authentication could be completed (#{e.class}: #{e.message}). What it means
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.
Source
Thrown at lib/wpscan/browser_authenticator.rb:42
end
# Drives the interactive browser session and returns the resulting cookie jar.
# Translates Ferrum failures into BrowserFailed with a context-specific message.
def self.run_login_session(login_url)
browser = Ferrum::Browser.new(headless: false)
puts 'SAML authentication needed. Log in via the browser window that just opened, then press enter.'
browser.goto(login_url)
gets # Waits for user input
# Attempt an innocuous command to check if the browser is still responsive
browser.current_url
browser.cookies.all
rescue Ferrum::BinaryNotFoundError, Ferrum::EmptyPathError => e
raise WPScan::Error::BrowserFailed, chrome_not_found_message(e)
rescue Ferrum::Error => e
raise WPScan::Error::BrowserFailed,
'The browser was closed or failed before SAML authentication could be completed ' \
"(#{e.class}: #{e.message})."
ensure
browser.quit if browser&.process
end
def self.chrome_not_found_message(error)
'--expect-saml requires Chrome or Chromium to be installed and available on PATH ' \
'(install Chrome / Chromium, or point Ferrum at a binary via BROWSER_PATH). ' \
"Underlying error: #{error.message}"
end
def self.serialize_cookies(cookies)
cookies.map do |_name, cookie|
raise WPScan::Error::SAMLAuthenticationFailed if cookie.name.match?(COOKIE_DELIMITERS) ||
cookie.value.to_s.match?(COOKIE_DELIMITERS)
"#{cookie.name}=#{cookie.value}"View on GitHub (pinned to 62c9cef471)
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
Example fix
# before <user closes the Chrome window mid-login, then presses enter> # => BrowserFailed: The browser was closed or failed before SAML authentication could be completed (Ferrum::DeadBrowserError: Browser is dead) # after <leave the Chrome window open, finish login, press enter> # => cookies captured, scan proceeds
Defensive patterns
Strategy: try-catch
Validate before calling
# Cheap liveness preflight: make sure no stale chrome holds locks
system('pkill -f chrome.*remote-debugging') || true Try / catch
begin
cookies = WPScan::BrowserAuthenticator.run_login_session(login_url)
rescue WPScan::Error::BrowserFailed => e
if e.message.include?('closed or failed')
retry if (attempts += 1) < 2 # browser died; one clean retry after killing leftovers
end
raise
end Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- --expect-saml requires Chrome or Chromium to be installed an
- SAML authentication is required to access this resource. Ple
- SAML authentication needs an interactive terminal to wait fo
- The option #{opt.to_long} is required
- One of the following options is required: #{opt.to_long}, --
AI-assisted analysis of wpscanteam/wpscan@62c9cef471 (2026-08-21).
Data as JSON: /api/errors/1675773efaf1b102.
Report an issue: GitHub.