Repository navigation
!feat(plugins): add web fetch provider boundary - #59465
Conversation
e8e174e to
2bc3127
Compare
Greptile SummaryThis PR introduces a One behavioral regression is worth addressing before merge: Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/tools/web-fetch.ts
Line: 70-81
Comment:
**`proxy` and `storeInCache` silently dropped through the new provider path**
`FetchFirecrawlContentParams` still declares `proxy` and `storeInCache`, and the values are passed to `resolved.definition.execute(...)` (line 292–298), but the Firecrawl provider's `createTool.execute` in `firecrawl-fetch-provider.ts` reads only `url`, `extractMode`, and `maxChars` — `proxy` and `storeInCache` are silently discarded. A caller passing `proxy: "stealth"` or `storeInCache: false` will observe no difference from the defaults (`"auto"` / `true`), with no error or warning.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/web-fetch/runtime.ts
Line: 21-27
Comment:
**`preferRuntimeProviders` is declared but never read**
`ResolveWebFetchDefinitionParams.preferRuntimeProviders` is accepted at call sites (`createWebFetchTool` passes `true`, `fetchFirecrawlContent` passes `false`) but `resolveWebFetchDefinition` always calls `resolveBundledPluginWebFetchProviders` unconditionally — the parameter has no effect on provider selection. The two runtime tests that assert "bundled wins when preferred" pass for the same reason (the mock for `resolveRuntimeWebFetchProviders` is set but never invoked).
If this is intentional (current scope: bundled-only), removing the parameter or adding a clear comment would avoid misleading future callers. If runtime providers should be consulted when `preferRuntimeProviders: true`, the guard is missing.
How can I resolve this? If you propose a fix, please make it concise.Reviews (3): Last reviewed commit: "Merge branch 'main' into feat/web-fetch-..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8e174eb16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🔒 Aisle Security AnalysisWe found 5 potential security issue(s) in this PR:
1. 🟠 SSRF policy bypass: provider fallback executes on unvalidated URL when guarded fetch fails
DescriptionIn
Vulnerable code: const rawPayload = await params.providerFallback.definition.execute({
url: params.urlToFetch,
extractMode: params.extractMode,
maxChars: params.maxChars,
});RecommendationEnforce SSRF policy before invoking any web-fetch provider, using the same checks as the core guarded fetch. Suggested approach:
Example (sketch): import { resolvePinnedHostnameWithPolicy } from "../../infra/net/ssrf.js";
async function assertWebFetchUrlAllowed(urlRaw: string) {
const url = new URL(urlRaw);
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("Invalid URL");
// Will throw SsrFBlockedError if disallowed
await resolvePinnedHostnameWithPolicy(url.hostname, { policy: undefined });
}
async function maybeFetchProviderWebFetchPayload(params: ...) {
if (!params.providerFallback) return null;
await assertWebFetchUrlAllowed(params.urlToFetch);
const rawPayload = await params.providerFallback.definition.execute({ ... });
...
}Additionally, consider requiring provider implementations to accept a pre-validated URL only, and document that providers must not be invoked with URLs that haven't passed SSRF validation. 2. 🟡 Unbounded `maxChars` and missing parameter schema in Firecrawl web-fetch provider can cause memory/CPU DoS
DescriptionThe Firecrawl web-fetch provider tool declares an empty
Vulnerable code: createTool: ({ config }) => ({
description: "Fetch a page using Firecrawl.",
parameters: {},
execute: async (args) => {
const maxChars =
typeof args.maxChars === "number" && Number.isFinite(args.maxChars)
? Math.floor(args.maxChars)
: undefined;
return await runFirecrawlScrape({ cfg: config, url, extractMode, maxChars });
},
})Even if the default agent web-fetch tool clamps Recommendation
Example (illustrative): const MAX_CHARS_CAP = 200_000;
createTool: ({ config }) => ({
description: "Fetch a page using Firecrawl.",
parameters: {
type: "object",
additionalProperties: false,
properties: {
url: { type: "string", minLength: 1, maxLength: 2048 },
extractMode: { type: "string", enum: ["markdown", "text"] },
maxChars: { type: "integer", minimum: 100, maximum: MAX_CHARS_CAP },
proxy: { type: "string", enum: ["auto", "basic", "stealth"] },
storeInCache: { type: "boolean" },
},
required: ["url"],
},
execute: async (args) => {
const maxChars =
typeof args.maxChars === "number" && Number.isFinite(args.maxChars)
? Math.min(MAX_CHARS_CAP, Math.max(100, Math.floor(args.maxChars)))
: undefined;
return runFirecrawlScrape({ cfg: config, url: String(args.url), extractMode, maxChars });
},
});Also consider capping output size independent of 3. 🟡 Prompt-injection via unwrapped provider-controlled metadata fields in web_fetch fallback payload
Description
Issues:
While these are “metadata” fields, they still appear in the tool JSON and can influence downstream tool chaining / agent behavior. Vulnerable code: const contentType =
typeof payload.contentType === "string" ? normalizeContentType(payload.contentType) : undefined;
...
const extractor =
typeof payload.extractor === "string" && payload.extractor.trim()
? payload.extractor
: params.providerId;
...
fetchedAt:
typeof payload.fetchedAt === "string" && payload.fetchedAt
? payload.fetchedAt
: new Date().toISOString(),RecommendationTreat all provider-originated strings as untrusted and either wrap them (if they are meant to be read by the model) or strictly validate/normalize them (if they are protocol metadata). Suggested hardening:
Example: function hasCtl(s: string) {
for (const ch of s) {
const c = ch.charCodeAt(0);
if (c <= 0x1f || c === 0x7f) return true;
}
return false;
}
function normalizeExtractor(x: unknown, fallback: string) {
if (typeof x !== 'string') return fallback;
const v = x.trim();
if (!v || v.length > 64 || hasCtl(v) || !/^[a-z0-9._-]+$/i.test(v)) return fallback;
return v;
}
function normalizeFetchedAt(x: unknown) {
if (typeof x !== 'string') return undefined;
const v = x.trim();
if (!v || v.length > 64 || hasCtl(v)) return undefined;
const t = Date.parse(v);
return Number.isFinite(t) ? new Date(t).toISOString() : undefined;
}Then use these normalizers in 4. 🟡 SSRF guard bypass via Firecrawl web fetch provider (arbitrary URL forwarded to Firecrawl)
DescriptionThe new Firecrawl web-fetch provider forwards an arbitrary user-controlled
Impact depends on Firecrawl’s own protections, but if Firecrawl allows fetching internal/metadata endpoints, an attacker could use OpenClaw to retrieve and exfiltrate such content via Firecrawl responses (an indirect SSRF / internal resource access vector). Vulnerable code: const url = typeof args.url === "string" ? args.url : "";
...
return await runFirecrawlScrape({
cfg: config,
url,
extractMode,
maxChars,
...(proxy ? { proxy } : {}),
...(storeInCache !== undefined ? { storeInCache } : {}),
});RecommendationApply the same SSRF / URL validation rules used by the built-in Minimum hardening:
Example (illustrative): import { assertWebUrlAllowed } from "../infra/net/ssrf.js"; // or existing helper
execute: async (args) => {
const raw = typeof args.url === "string" ? args.url : "";
const parsed = new URL(raw);
assertWebUrlAllowed(parsed); // throws SsrFBlockedError or similar
return await runFirecrawlScrape({ cfg: config, url: parsed.toString(), ... });
}Also apply the same validation in the standalone 5. 🔵 Sensitive config (potential secrets) embedded into web fetch snapshot cache key
Description
Key points:
Vulnerable code: return JSON.stringify({
// ...
config: params.config ?? null,
env: buildPluginSnapshotCacheEnvKey(params.env),
});RecommendationDo not include raw config values in cache keys. Since the cache is already scoped by function buildWebFetchSnapshotCacheKey(params: {
workspaceDir?: string;
bundledAllowlistCompat?: boolean;
onlyPluginIds?: readonly string[];
env: NodeJS.ProcessEnv;
}): string {
return JSON.stringify({
workspaceDir: params.workspaceDir ?? "",
bundledAllowlistCompat: params.bundledAllowlistCompat === true,
onlyPluginIds: [...new Set(params.onlyPluginIds ?? [])].toSorted((l, r) => l.localeCompare(r)),
env: buildPluginSnapshotCacheEnvKey(params.env),
});
}If you truly need to differentiate configs beyond object identity, compute a redacted or hashed fingerprint (e.g., include only non-sensitive fields, or hash a redacted structure) rather than serializing the full config object. Analyzed PR: #59465 at commit Last updated on: 2026-04-02T11:43:16Z Latest run failed. Keeping previous successful results. Trace ID: Last updated on: 2026-04-02T12:52:22Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c73e54e07
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e1992e53b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d3804acb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7f401a1db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41bc8ef24c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (pluginWebFetch && typeof pluginWebFetch === "object" && !Array.isArray(pluginWebFetch)) { | ||
| return pluginWebFetch; |
There was a problem hiding this comment.
Preserve legacy fetch key fallback when plugin config is partial
Do not return pluginWebFetch unconditionally here: if plugins.entries.firecrawl.config.webFetch exists but only sets non-secret fields (for example baseUrl), this early return suppresses fallback to tools.web.fetch.firecrawl.*, so resolveFirecrawlApiKey can no longer see a still-valid legacy key and Firecrawl fetch/search starts failing with “needs a Firecrawl API key.” This is a regression for partial migrations where users add new plugin-owned fetch settings before moving the legacy key.
Useful? React with 👍 / 👎.
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
* feat(plugins): add web fetch provider boundary * feat(plugins): add web fetch provider modules * refactor(web-fetch): remove remaining core firecrawl fetch config * fix(web-fetch): address review follow-ups * fix(web-fetch): harden provider runtime boundaries * fix(web-fetch): restore firecrawl compare helper * fix(web-fetch): restore env-based provider autodetect * fix(web-fetch): tighten provider hardening * fix(web-fetch): restore fetch autodetect and compat args * chore(changelog): note firecrawl fetch config break
Summary
web_searchwas pluginized, butweb_fetchstill carried Firecrawl-specific fallback/config/secret behavior in core.webFetchProvidersplugin contract, generic fetch-provider runtime resolution, moved Firecrawl fetch ownership behind the plugin boundary, and removed the remaining coretools.web.fetch.firecrawl.*runtime/config surface.web_fetchtool shape.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
src/agents/tools/web-fetch.tsand related runtime-secret/config plumbing still owned Firecrawl-specific behavior whileweb_searchhad already moved to provider plugins.webFetchProvidersmanifest/runtime contract, no contract tests for fetch-provider ownership, and no migration path off the legacy coretools.web.fetch.firecrawl.*config shape.git blame, prior PR, issue, or refactor if known): this is follow-through on the plugin-boundary cleanup after fix(plugins): guard runtime facade activation #59412, plus recent upstream work that moved more provider auth/config handling and trusted web-tool header/endpoint behavior behind reusable helpers instead of vendor-specific core branches.Regression Test Plan (if applicable)
src/agents/tools/web-tools.fetch.test.tssrc/agents/tools/web-fetch.cf-markdown.test.tssrc/agents/tools/web-fetch.ssrf.test.tssrc/secrets/runtime-web-tools.test.tssrc/agents/openclaw-tools.web-runtime.test.tssrc/plugins/contracts/registry.contract.test.tssrc/plugins/contracts/registry.retry.test.tssrc/plugins/contracts/plugin-registration.contract.test.tssrc/plugins/contracts/web-fetch-provider.contract.test.tssrc/config/legacy-web-fetch.test.tssrc/commands/doctor-legacy-config.migrations.test.tssrc/cli/command-secret-gateway.test.tssrc/cli/command-secret-targets.test.tssrc/web-search/runtime.test.tsextensions/firecrawl/src/firecrawl-tools.test.tsweb_fetchstays generic, Firecrawl compat is owned by the plugin, legacy fetch config migrates cleanly to plugin-owned config, and runtime/CLI secret handling stays provider-generic.web_fetchand Firecrawl tests covered the fallback behavior; this PR extends them to the provider-routed and migrated-config paths.User-visible / Behavior Changes
web_fetchnow resolves provider fallbacks through plugin-owned fetch providers instead of a Firecrawl-only core branch.tools.web.fetch.provider.plugins.entries.firecrawl.config.webFetch.*.openclaw doctor --fixmigrates legacytools.web.fetch.firecrawl.*config to the plugin-owned Firecrawl config path.firecrawl_scrapetool.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:web_fetchinput validation and network guardrails.Repro + Verification
Environment
tools.web.fetch.*,plugins.entries.firecrawl.config.webFetch.*, legacytools.web.fetch.firecrawl.*Steps
web_fetchwith no provider and fetch static HTML content.openclaw doctor --fixagainst legacytools.web.fetch.firecrawl.*config.Expected
web_fetchhandles direct HTTP/readability/basic HTML itself.Actual
Evidence
Human Verification (required)
pnpm buildpnpm test -- src/agents/tools/web-tools.fetch.test.ts src/secrets/runtime-web-tools.test.ts src/agents/openclaw-tools.web-runtime.test.ts src/plugins/contracts/registry.contract.test.ts src/plugins/contracts/registry.retry.test.ts src/plugins/contracts/plugin-registration.contract.test.ts src/plugins/contracts/web-fetch-provider.contract.test.ts extensions/firecrawl/src/firecrawl-tools.test.tspnpm test -- src/secrets/runtime-web-tools.test.ts src/config/legacy-web-fetch.test.ts src/commands/doctor-legacy-config.migrations.test.ts src/cli/command-secret-gateway.test.ts src/cli/command-secret-targets.test.tspnpm test -- src/agents/tools/web-fetch.cf-markdown.test.ts src/agents/tools/web-fetch.ssrf.test.ts src/web-search/runtime.test.tspnpm config:docs:genpnpm plugin-sdk:api:gennode --import tsx scripts/generate-base-config-schema.ts --writepnpm testpnpm check(branch has unrelatedtsgonoise outside this surface)Review Conversations
Compatibility / Migration
openclaw doctor --fixto migratetools.web.fetch.firecrawl.*toplugins.entries.firecrawl.config.webFetch.*.Risks and Mitigations
Risk:
Risk: