Anti-CDP-Detection Stealth Layer
Why
When stealth-runner starts a Chromium process via CDP, the browser exposes:
navigator.webdriver === true (deadly fingerprint)
window.chrome differences from real Chrome
- Permissions API behaving differently
- Plugin/MimeType arrays incomplete
- WebGL renderer string identifying as automation
Modern bot-detection (Cloudflare, DataDome, etc.) checks ALL of these in milliseconds and blocks the session before any user action.
Acceptance Criteria
API Spec
from survey.anti_detection.cdp_stealth import StealthPatcher
patcher = StealthPatcher(
preset="aggressive", # "minimal", "standard", "aggressive"
custom_webgl_renderer="Intel Iris OpenGL Engine",
)
# Apply at browser launch
await patcher.attach(cdp_client)
# All subsequent page loads are stealth-patched
await page.goto("https://heypiggy.com/")
Patch List (Inspired by puppeteer-extra-plugin-stealth)
evasions/chrome.app — Adds Chrome browser object
evasions/chrome.csi — Fixes Chrome csi() timing API
evasions/chrome.loadTimes — Fixes chrome.loadTimes() API
evasions/chrome.runtime — Adds Chrome runtime stubs
evasions/iframe.contentWindow — Fixes iframe inheritance
evasions/media.codecs — Standard codec support strings
evasions/navigator.hardwareConcurrency — Matches real CPU count
evasions/navigator.languages — Sets to ["en-US", "en"]
evasions/navigator.permissions — Fixes notifications API
evasions/navigator.plugins — Restores plugin array
evasions/navigator.vendor — Sets to "Google Inc."
evasions/navigator.webdriver — Hides webdriver flag
evasions/sourceurl — Strips puppeteer signatures
evasions/user-agent-override — Matches platform
evasions/webgl.vendor — Spoofs GPU vendor strings
evasions/window.outerdimensions — Fixes window size mismatch
Implementation Notes
Reference Implementation
JavaScript: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth
Port these JS evasions to Python (they're ~50 LOC each):
# Example: navigator.webdriver patch
WEBDRIVER_PATCH = """
() => {
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
});
}
"""
await cdp.send("Page.addScriptToEvaluateOnNewDocument", {
"source": WEBDRIVER_PATCH
})
Testing
Use bot detection test pages:
Dependencies
- No new packages — all patches are JS strings injected via CDP
Related
- Required for deployment on protected sites
- Optional for HeyPiggy (may already work without)
- Required if FunCaptcha or Cloudflare Turnstile appear
Labels
enhancement, priority-high, anti-detection, stealth
Anti-CDP-Detection Stealth Layer
Why
When stealth-runner starts a Chromium process via CDP, the browser exposes:
navigator.webdriver === true(deadly fingerprint)window.chromedifferences from real ChromeModern bot-detection (Cloudflare, DataDome, etc.) checks ALL of these in milliseconds and blocks the session before any user action.
Acceptance Criteria
survey-cli/survey/anti_detection/cdp_stealth.pynavigator.webdrivertoundefinedwindow.chrometo match real Chromenavigator.pluginsandnavigator.mimeTypesnavigator.permissions.query(notifications fix)document.$cdc_*andwindow.$cdc_*markersPage.addScriptToEvaluateOnNewDocument)API Spec
Patch List (Inspired by puppeteer-extra-plugin-stealth)
evasions/chrome.app— Adds Chrome browser objectevasions/chrome.csi— Fixes Chromecsi()timing APIevasions/chrome.loadTimes— Fixeschrome.loadTimes()APIevasions/chrome.runtime— Adds Chrome runtime stubsevasions/iframe.contentWindow— Fixes iframe inheritanceevasions/media.codecs— Standard codec support stringsevasions/navigator.hardwareConcurrency— Matches real CPU countevasions/navigator.languages— Sets to ["en-US", "en"]evasions/navigator.permissions— Fixes notifications APIevasions/navigator.plugins— Restores plugin arrayevasions/navigator.vendor— Sets to "Google Inc."evasions/navigator.webdriver— Hides webdriver flagevasions/sourceurl— Strips puppeteer signaturesevasions/user-agent-override— Matches platformevasions/webgl.vendor— Spoofs GPU vendor stringsevasions/window.outerdimensions— Fixes window size mismatchImplementation Notes
Reference Implementation
JavaScript: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth
Port these JS evasions to Python (they're ~50 LOC each):
Testing
Use bot detection test pages:
Dependencies
Related
Labels
enhancement,priority-high,anti-detection,stealth