@@ -26,11 +26,13 @@ const BLOCKED: UrlGuardResult = { |
26 | 26 | * fetches and blocks any that land on a private/reserved address. |
27 | 27 | * |
28 | 28 | * IP literals are classified directly; hostnames are DNS-resolved and every |
29 | | - * returned address is checked. A resolution failure is not treated as a block — |
30 | | - * an unresolvable host reaches nothing, and Chromium fails the load naturally. |
31 | | - * The residual DNS-rebinding TOCTOU window (our lookup vs Chromium's) is only |
32 | | - * fully closable with egress firewalling; {@link isBlockedRequestUrl} adds a |
33 | | - * synchronous per-request literal-IP backstop for redirects and subresources. |
| 29 | + * returned address is checked. Resolution failure fails CLOSED (blocks): we |
| 30 | + * can't confirm the host is public, and Chromium resolves independently, so it |
| 31 | + * could still reach a private address our lookup missed — matching |
| 32 | + * `validateUrlWithDNS` in `apps/sim`. The residual DNS-rebinding TOCTOU window |
| 33 | + * (our lookup vs Chromium's) is only fully closable with egress firewalling; |
| 34 | + * {@link isBlockedRequestUrl} adds a synchronous per-request literal-IP backstop |
| 35 | + * for redirects and subresources. |
34 | 36 | */ |
35 | 37 | export async function checkAgentUrl(rawUrl: string): Promise<UrlGuardResult> { |
36 | 38 | const url = parseHttpUrl(rawUrl) |
@@ -56,10 +58,13 @@ export async function checkAgentUrl(rawUrl: string): Promise<UrlGuardResult> { |
56 | 58 | return BLOCKED |
57 | 59 | } |
58 | 60 | } catch (error) { |
59 | | - logger.info('Agent navigation host did not resolve; letting the load fail naturally', { |
| 61 | + // Fail closed: an unresolved host can't be confirmed public, and Chromium |
| 62 | + // resolves independently, so it could still reach a private address. |
| 63 | + logger.warn('Agent navigation host did not resolve; blocking', { |
60 | 64 | host, |
61 | 65 | error: getErrorMessage(error), |
62 | 66 | }) |
| 67 | + return { ok: false, error: 'That address could not be resolved.' } |
63 | 68 | } |
64 | 69 |
|
65 | 70 | return OK |
|