patch-cd
is a utility that modifies ChromeDriver binaries to prevent detection of automated browser control. The tool removes well-known DOM injection indicators that can reveal automation activities to websites.
The utility operates entirely in memory:
- Loads the ChromeDriver binary into memory
- Patches specific identifiers while preserving binary size
- Executes the modified binary directly from memory using
fexecve()
- No temporary files are written to disk, avoiding filesystem write permission requirements
These modifications hide automation indicators that websites commonly check for:
The in-memory execution approach is based on:
- In-Memory-Only ELF Execution (Without tmpfs)
- memfd_create(2) - Linux manual page
- fexecve(3) - Linux manual page
The core functionality (memfd_create
and fexecve
) is Linux-specific. However, for development on other platforms, the tool includes a fallback implementation using temporary files and the standard execve
syscall.
To compile for Linux when developing on MacOS or other systems:
docker run --rm --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/myapp -w /usr/src/myapp rust:1.86.0 cargo build --release