# How to Disable WebRTC and WebGL in Zendriver for Privacy

> Enhance privacy by disabling WebRTC and WebGL in Zendriver. Learn how to block IP leaks and canvas fingerprinting using simple config settings for secure browsing.

- Repository: [CDP Driver/zendriver](https://github.com/cdpdriver/zendriver)
- Tags: how-to-guide
- Published: 2026-02-27

---

**Use the `Config` class in [`zendriver/core/config.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/config.py) to set `disable_webrtc=True` and `disable_webgl=True`, which automatically injects the necessary Chromium flags to block IP leaks and canvas fingerprinting.**

Zendriver, the open-source Python library for browser automation built on top of Chrome DevTools Protocol (CDP), provides built-in privacy controls to prevent WebRTC IP leaks and WebGL fingerprinting. The `Config` object handles these settings through dedicated boolean attributes that translate into specific Chrome command-line arguments when the browser launches.

## Understanding WebRTC and WebGL Privacy Risks

**WebRTC** (Web Real-Time Communication) can expose your local and public IP addresses even when using a proxy or VPN, creating a significant privacy vulnerability. **WebGL** (Web Graphics Library) enables websites to fingerprint your device through unique graphics rendering characteristics, allowing tracking across sessions.

Zendriver addresses both vectors through its configuration system, eliminating the need to manually construct complex Chrome flag strings.

## Configuration Options in Zendriver

The privacy controls reside in the `Config` class located at [`zendriver/core/config.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/config.py). These settings are processed during the `Config.__call__` method, which converts the configuration into launch arguments for the Chromium process.

### WebRTC Settings

By default, Zendriver already protects against WebRTC leaks. The `disable_webrtc` attribute defaults to `True`, automatically appending the flags `--webrtc-ip-handling-policy=disable_non_proxied_udp` and `--force-webrtc-ip-handling-policy` to the browser launch command.

This default behavior ensures that WebRTC traffic is blocked unless explicitly allowed, preventing IP address exposure even if you forget to configure privacy settings manually.

### WebGL Settings

Unlike WebRTC, **WebGL is enabled by default** (`disable_webgl=False`). To prevent canvas fingerprinting and reduce attack surface, you must explicitly set this attribute to `True`. When enabled, Zendriver injects `--disable-webgl` and `--disable-webgl2` flags to completely disable both versions of the WebGL API.

## Implementation Methods

You can configure these privacy settings through three approaches, depending on your specific requirements and coding style.

### Using Config Constructor Parameters

The recommended approach uses the `Config` constructor parameters for clarity and maintainability. This method leverages Zendriver's built-in validation and flag generation.

```python
from zendriver.core.config import Config
from zendriver.core.browser import Browser

# Disable both WebRTC (already True by default) and WebGL

config = Config(disable_webrtc=True, disable_webgl=True)

# Create browser instance with privacy configuration

browser = await Browser.create(config=config)

```

This configuration automatically translates into the following Chrome flags: `--webrtc-ip-handling-policy=disable_non_proxied_udp`, `--force-webrtc-ip-handling-policy`, `--disable-webgl`, and `--disable-webgl2`.

### Manual Chrome Flags

For advanced use cases requiring fine-grained control, you can manually append arguments using `Config.add_argument()`. Note that this method bypasses Zendriver's dedicated privacy attributes but achieves the same result.

```python
from zendriver.core.config import Config
from zendriver.core.browser import Browser

config = Config()

# Manually inject WebRTC privacy flags

config.add_argument("--webrtc-ip-handling-policy=disable_non_proxied_udp")
config.add_argument("--force-webrtc-ip-handling-policy")

# Manually disable WebGL

config.add_argument("--disable-webgl")
config.add_argument("--disable-webgl2")

browser = await Browser.create(config=config)

```

Be aware that `Config.add_argument` rejects arguments that interfere with internal settings such as `headless` or `no-sandbox`, as enforced in [`zendriver/core/config.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/config.py) lines 31-48.

### Direct Browser Arguments

You can also pass arguments directly through the `browser_args` parameter in the `Config` constructor. This approach is useful when migrating from other browser automation libraries or when managing argument lists dynamically.

```python
from zendriver.core.config import Config
from zendriver.core.browser import Browser

privacy_flags = [
    "--webrtc-ip-handling-policy=disable_non_proxied_udp",
    "--force-webrtc-ip-handling-policy",
    "--disable-webgl",
    "--disable-webgl2",
]

config = Config(browser_args=privacy_flags)
browser = await Browser.create(config=config)

```

All three methods result in identical Chromium launch configurations. The first approach using dedicated attributes is preferred for readability and maintainability.

## Summary

- **WebRTC is disabled by default** in Zendriver through `disable_webrtc=True`, preventing IP address leaks via the flags `--webrtc-ip-handling-policy=disable_non_proxied_udp` and `--force-webrtc-ip-handling-policy`.
- **WebGL requires explicit disabling** by setting `disable_webgl=True` in the `Config` constructor, which injects `--disable-webgl` and `--disable-webgl2` flags.
- The `Config` class in [`zendriver/core/config.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/config.py) handles flag generation automatically, while `Browser.create` in [`zendriver/core/browser.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/browser.py) consumes these settings during browser launch.
- Manual flag injection via `add_argument()` or `browser_args` provides alternative implementation paths for advanced use cases.

## Frequently Asked Questions

### Does Zendriver disable WebRTC by default?

Yes, Zendriver automatically disables WebRTC by setting `disable_webrtc=True` by default in the `Config` constructor. This prevents IP address leakage by automatically appending `--webrtc-ip-handling-policy=disable_non_proxied_udp` and `--force-webrtc-ip-handling-policy` to the Chrome launch arguments. You only need to explicitly set this parameter if you want to enable WebRTC for specific use cases.

### What Chrome flags does Zendriver use to disable WebGL?

When you set `disable_webgl=True` in the `Config` object, Zendriver automatically injects two specific Chromium flags: `--disable-webgl` and `--disable-webgl2`. These flags completely disable both versions of the Web Graphics Library API, preventing canvas fingerprinting and reducing the browser's attack surface. The flag generation occurs in the `Config.__call__` method located in [`zendriver/core/config.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/config.py).

### Can I enable WebRTC if needed for specific use cases?

Yes, you can enable WebRTC by explicitly setting `disable_webrtc=False` when constructing the `Config` object. However, this is generally not recommended for privacy-focused automation tasks, as it exposes your local and public IP addresses even when using proxies. If your application requires WebRTC functionality, ensure you understand the privacy implications and consider using additional network-level protections to mitigate IP leakage risks.

### Where are the privacy settings defined in the source code?

The privacy settings are defined in [`zendriver/core/config.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/config.py). The `disable_webrtc` and `disable_webgl` attributes are declared in the constructor (lines 49-52), stored as instance variables (lines 100-101), and translated into Chrome arguments in the `__call__` method (lines 221-227). The `Browser.create` method in [`zendriver/core/browser.py`](https://github.com/cdpdriver/zendriver/blob/main/zendriver/core/browser.py) (lines 84-100) consumes this configuration when launching the Chromium process.