National Cyber Warfare Foundation (NCWF)login

selenium-stealth for hiding browser automation signals during authorized web testing


0 user ratings
2026-10-03 21:26:54
milo
Red Team (CNA)
"selenium-stealth

selenium-stealth is a Python library that masks the automation fingerprints of Selenium-driven Chrome/Chromium, letting authorized testers and researchers run bot-detection-resistant browser automation in sanctioned environments.








Tooldiprajpatra/selenium-stealth — Python package that patches Selenium's Chrome/Chromium driver to suppress common automation-detection signals
CategoryBrowser anti-detection / automation fingerprint masking
Primary UseReducing bot-detection friction for Selenium automation during authorized testing, scraping of systems you are permitted to access, and defensive research into fingerprinting
Safe UseEducational and documentary analysis for authorized professionals: use only against systems you own or have written permission to test, in labs and sanctioned assessments
Telemetry NoteThe tool only alters client-side JavaScript properties (navigator.webdriver, languages, vendor, platform, WebGL metadata); server-side heuristics like IP reputation, timing analysis, and TLS fingerprinting still produce detectable anomalies defenders can log

selenium-stealth is a compact Python package by diprajpatra that exists to solve a very specific annoyance: vanilla Selenium sessions are trivially fingerprinted by anti-bot products. The README describes it bluntly as an attempt to make Python Selenium "more stealthy," positioning itself as the Python answer to the well-known JavaScript plugin puppeteer-extra-plugin-stealth by berstend. With roughly 740 stars on GitHub and an MIT license, it occupies a durable niche: the operator who wants a pip install-grade shim rather than a hand-rolled pile of JavaScript evasions copy-pasted from Stack Overflow.


Scope is worth noting up front. The package currently supports only Selenium driving Chrome/Chromium, not Firefox or other engines. That constraint follows from how the tool works internally: it is applied as a wrapper around an existing webdriver driver object, injecting JavaScript and Chrome-specific options into a session you have already constructed. The README's own example shows the pattern clearly — build webdriver.ChromeOptions(), set excludeSwitches to enable-automation and useAutomationExtension to False, launch the driver, then pass it to the stealth() function for the deeper fingerprint patching.


The stealth() signature is where the real engineering lives. It accepts user_agent, languages, vendor, platform, webgl_vendor, renderer, fix_hairline, and run_on_insecure_origins, each with sensible defaults such as a desktop Chrome/83 user agent string, Google Inc. as vendor, Win32 as platform, and Intel Iris OpenGL Engine as the WebGL renderer. These parameters map directly onto the browser properties that fingerprinting scripts interrogate — navigator.webdriver, navigator.languages, navigator.vendor, navigator.platform, and the WebGL UNMASKED_VENDOR_WEBGL/UNMASKED_RENDERER_WEBGL queries that leak the true GPU string of the host machine.


Internally, the package can be understood as a Python re-implementation of the evasion suite that made puppeteer-extra-plugin-stealth famous. Each evasion targets one leaky API surface: the navigator.webdriver flag that ChromeDriver sets to true, the missing Chrome runtime objects headless builds expose, hairline-feature rendering quirks (fix_hairline addresses a CSS rendering difference that headless Chrome exhibits), and the WebGL vendor/renderer pair that a real desktop GPU would report. By overriding these with plausible, internally consistent values, the package aims to make an automated session look like an ordinary human-driven browser.


The README backs its claims with visual evidence rather than marketing copy. It links before/after screenshots from bot.sannysoft.com — a well-known public bot-detection test page — showing vanilla Selenium failing a grid of red detections in both headless and headful modes, and selenium-stealth sessions passing the same grid. The author also enumerates three headline capabilities: passing "all public bot tests," enabling Selenium to complete Google account login without immediate automation blocks, and helping maintain a normal-looking reCAPTCHA v3 score. That last point is particularly relevant to readers thinking about risk-based scoring rather than binary detection.


The reCAPTCHA v3 claim deserves unpacking, because it frames what the tool does and does not achieve. reCAPTCHA v3 does not show a challenge; it emits a continuous trust score derived from behavioral signals, fingerprint consistency, and environmental heuristics. A fresh headless Chrome with navigator.webdriver=true and an Intel renderer string mismatched against its user agent tanks that score. selenium-stealth fixes the environmental layer, which is why the README says it helps maintain a normal score — but behavioral signals like mouse trajectories and typing cadence remain your responsibility.


Installation is a single standard step, and the usage example in the README is non-weaponized boilerplate: pip install selenium-stealth, then construct a Chrome driver with ChromeOptions() and hand it to stealth(). Notably, the example navigates only to the public test page bot[.]sannysoft[.]com, which is a reasonable way to verify your configuration in a lab before pointing automation anywhere else. For authorized engagements, that test-first workflow is good hygiene: validate the fingerprint locally, then proceed against systems where you have permission.


Defensively, this package is worth studying even if you never use it, because it is effectively a catalogue of what automated traffic looks like before remediation. If your WAF rules or bot-mitigation product rely primarily on navigator.webdriver, static user-agent checks, or the enable-automation switch, selenium-stealth neutralizes all three in one call. Detection programs should therefore weight harder-to-forge signals: TLS/JA3 fingerprints of the automation stack, IP and ASN reputation, request timing distributions, and behavioral telemetry, none of which this package touches.


The tool's limitations are the mirror image of its design. It patches the browser environment, not the network path, so a datacenter IP running a perfectly spoofed Chrome profile will still stand out. The default user agent string hardcodes Chrome/83, which is dated; a careful operator overrides user_agent with a current string, and must keep platform, languages, and WebGL values consistent with it — an Intel Iris OpenGL Engine renderer paired with a Win64 agent, as the defaults do, is exactly the kind of cross-check fingerprinters love. Consistency across parameters matters more than any single value.


There is also a maintenance consideration. The project is a single-author effort with a Travis CI badge from an earlier era, no topic tags, and no published roadmap. Anti-bot vendors iterate constantly, and any fixed evasion suite gradually rots as new leaks are discovered — navigator.webdriver was the low-hanging fruit years ago, but modern collectors inspect hundreds of properties, including Chrome runtime internals and font enumeration. Treat this package as a solid baseline layer to be combined with current ChromeDriver versions and your own testing, not a turnkey invisibility cloak.


In an authorized workflow, the legitimate use cases are concrete: regression-testing your own web application behind aggressive bot mitigation, conducting sanctioned scraping of services whose terms you have permission to operate under, researching how fingerprinting scripts behave, and building realistic red-team browser automation in scoped engagements. The README's framing — "we can't let the cats win" — is playful, but the professional reality is that anti-bot bypass is only as legitimate as the authorization behind it; absent permission, the same fingerprint masking serves fraud, and that line is on the operator.


All that said, selenium-stealth remains a clean, minimal, MIT-licensed example of browser-fingerprint engineering. Reading its source is educational in itself: it shows precisely which navigator and WebGL surfaces anti-bot vendors probe, how a Python package injects JavaScript into a Selenium driver, and how far environmental spoofing gets you before behavioral and network-layer detection takes over. For defenders, it doubles as a checklist of client-side signals that should never be trusted alone; for authorized testers, it is a low-friction way to keep legitimate automation from being mistaken for careless scripting.



Official project repository for diprajpatra/selenium-stealth.

Download Tool

Educational analysis for authorized security professionals. Use only in controlled, authorized environments.






Source: OffensiveSec
Source Link: https://www.offsecblog.com/2026/10/selenium-stealth-for-hiding-browser.html


Comments
new comment
Nobody has commented yet. Will you be the first?
 
Forum
Red Team (CNA)



Copyright 2012 through 2026 - National Cyber Warfare Foundation - All rights reserved worldwide.