<!-- source: https://deepwiki.com/qhkm/zeptoclaw/8.3-web-tools -->

# Web Tools

- .github/workflows/ci.yml
- .github/workflows/e2e.yml
- .github/workflows/release.yml
- install.sh
- src/runtime/bubblewrap.rs
- src/runtime/firejail.rs
- src/runtime/landlock.rs
- src/tools/screenshot.rs
- src/tools/web.rs

## Purpose and Scope

This page documents the web access tools that enable the agent to search the internet, fetch URL content, and capture screenshots of web pages. These tools provide read-only network access with comprehensive SSRF (Server-Side Request Forgery) protection and DNS pinning to prevent access to internal or private network resources.

For general tool system architecture and execution pipeline, see [Tool System Architecture](/qhkm/zeptoclaw/3.4-tool-system-architecture). For other built-in tools, see [Built-in Tools Reference](/qhkm/zeptoclaw/8.2-built-in-tools-reference).

**Sources:** [src/tools/web.rs1-50](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/web.rs#L1-L50) [src/tools/screenshot.rs1-56](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/screenshot.rs#L1-L56)

## Available Web Tools

All web tools implement defense-in-depth SSRF protection to prevent access to localhost, private IP ranges, and DNS rebinding attacks.

**Sources:** [src/tools/web.rs108-124](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/web.rs#L108-L124) [src/tools/screenshot.rs184-204](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/screenshot.rs#L184-L204)

## Web Search Tool Architecture

```

```

The `WebSearchTool` is primarily backed by the Brave Search API. It requires a subscription token configured in the system.

**Tool Implementation:**

- Brave Search API ( WebSearchTool ) — Uses the BRAVE_API_URL and requires an X-Subscription-Token header. src/tools/web.rs 54-79 src/tools/web.rs 165-174
- Result Handling — Parses the BraveResponse into a list of titles, URLs, and snippets, limited by MAX_WEB_SEARCH_COUNT . src/tools/web.rs 81-98 src/tools/web.rs 187-198

**Sources:** [src/tools/web.rs54-211](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/web.rs#L54-L211)

## SSRF Protection and DNS Pinning

Both `web_fetch` and `web_screenshot` implement a unified defense-in-depth SSRF protection mechanism centered around `resolve_and_check_host`.

### The Validation Pipeline

```

```

### Key Security Functions

- is_blocked_host(url) : Performs immediate checks on the hostname string. It blocks localhost , *.localhost , and literal IP addresses that fall into private ranges (10.x, 192.168.x, etc.) or link-local addresses. src/tools/web.rs 1031-1076
- resolve_and_check_host(url) : The core security gate. It resolves the hostname using tokio::net::lookup_host and iterates through every returned IP address. If any IP is loopback, private, or link-local, the request is aborted with a SecurityViolation . src/tools/web.rs 1090-1156
- DNS Pinning in Screenshots : For the web_screenshot tool, DNS is re-checked for every intercepted request to narrow the DNS-rebinding window across redirect chains. src/tools/screenshot.rs 97-114

**Sources:** [src/tools/web.rs1031-1156](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/web.rs#L1031-L1156) [src/tools/screenshot.rs97-114](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/screenshot.rs#L97-L114)

## Web Fetch Tool

The `WebFetchTool` extracts readable content from web pages, prioritizing main content areas and converting HTML to clean Markdown.

### Content Extraction Logic

1. Root Discovery : find_content_root searches for <main> , <article> , or [role=main] tags using pre-compiled Lazy<Selector> instances. src/tools/web.rs 39-43 src/tools/web.rs 938-965
2. Element Filtering : Elements in SKIP_ELEMENTS (scripts, styles, nav, footer, etc.) are discarded during traversal. src/tools/web.rs 49-52
3. Markdown Conversion : dom_to_markdown recursively traverses the DOM to produce structured text, handling headings, lists, and code blocks. src/tools/web.rs 967-1029
4. Byte Limits : To prevent memory exhaustion, the tool enforces MAX_FETCH_BYTES (800KB) and MAX_FETCH_CHARS (200k). src/tools/web.rs 29-34

### Parameters

- url : The target address (http/https only).
- max_chars : Maximum output length (default 50k). src/tools/web.rs 28

**Sources:** [src/tools/web.rs574-812](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/web.rs#L574-L812) [src/tools/web.rs938-1029](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/web.rs#L938-L1029)

## Web Screenshot Tool

The `WebScreenshotTool` uses a headless Chromium browser via the `chromiumoxide` crate. It provides the most comprehensive view of a page but requires the `screenshot` feature.

### Browser-Level Interception

Unlike simple HTTP fetches, a browser makes many sub-requests. ZeptoClaw secures this by enabling the Chrome DevTools Protocol (CDP) `Fetch` domain:

1. Request Interception : Every request the browser attempts is paused via FetchEnableParams . src/tools/screenshot.rs 355-361
2. Real-time Validation : The tool listens for EventRequestPaused . It extracts the URL and runs validate_browser_request_url (which includes DNS resolution checks) before allowing the browser to continue via ContinueRequestParams . src/tools/screenshot.rs 120-149
3. Redirect Tracking : It manually tracks document-level redirects in seen_document_redirect_urls to enforce a hard limit of MAX_SCREENSHOT_REDIRECT_HOPS (5) and prevent infinite redirect loops. src/tools/screenshot.rs 49 src/tools/screenshot.rs 158-181

### Execution Loop

The tool uses `tokio::select!` to simultaneously drive the browser navigation and handle the stream of interception events, ensuring security checks are applied to every sub-resource. [src/tools/screenshot.rs383-429](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/screenshot.rs#L383-L429)

**Sources:** [src/tools/screenshot.rs1-487](https://github.com/qhkm/zeptoclaw/blob/2c743d31/src/tools/screenshot.rs#L1-L487)
