Skip to content

Bug: web_search never forwards sandboxed to provider resolution, so the sandboxed trust filter is a no-op #144164

Open

Description

@yetval

Summary

web_search provider resolution never forwards the sandboxed flag it is given, so the sandboxed-provider trust filter is a no-op for search. A sandboxed agent calling web_search can be served by an arbitrary workspace or external plugin provider, while the same agent calling web_fetch is correctly restricted to bundled or verified-official providers.

Environment

  • Commit: 67e99bc (origin/main at time of filing)
  • Surface: web_search provider resolution

Steps to reproduce

  1. Put a workspace-origin plugin at <workspaceDir>/.openclaw/extensions/untrusted-web/ whose openclaw.plugin.json declares both contracts, so the same plugin is a candidate for search and for fetch:
{
  "id": "untrusted-web",
  "contracts": {
    "webSearchProviders": ["untrusted"],
    "webFetchProviders": ["untrusted"]
  }
}
  1. Drive the two real exported resolvers with the exact argument objects the two runtimes build for a sandboxed agent, on identical config and identical workspace:
resolvePluginWebSearchProviders({ config, workspaceDir });                    // what web-search builds
resolvePluginWebFetchProviders({ config, workspaceDir, sandboxed: true });    // what web-fetch builds
  1. Compare the returned provider lists.

Expected

For a sandboxed agent the trust filter excludes workspace and external providers from web_search, exactly as it does for web_fetch. The stated policy lives in the filter's own comment: sandboxed web tools may run bundled providers or a verified official install, never an arbitrary workspace or external plugin with the same contract.

Actual

The filter never engages for web_search. The workspace-origin provider is returned to the sandboxed agent.

Root cause

src/web-search/runtime.ts:271-279 builds its own argument object for provider resolution and omits sandboxed:

  const resolveProviders = params.preferRuntimeProviders
    ? resolveRuntimeWebSearchProviders
    : resolvePluginWebSearchProviders;
  return sortPluginEntriesForAutoDetect(
    resolveProviders({
      config: params.config,
      ...(pluginId ? { onlyPluginIds: [pluginId] } : {}),
    }),
  );

The flag is available at that point. ResolveWebSearchDefinitionParams declares sandboxed?: boolean (src/web-search/runtime-types.ts:17), src/agents/openclaw-tools.ts:222-229 passes sandboxed: options?.sandboxed into createWebSearchTool, and src/agents/tools/web-search.ts:127 forwards it into runWebSearch. It is dropped at the resolution call above and nowhere else.

The two resolver wrappers do not accept the field either: resolvePluginWebSearchProviders (src/plugins/web-search-providers.runtime.ts:52-62) and resolveRuntimeWebSearchProviders (:69-76) have no sandboxed in their parameter types, unlike src/plugins/web-fetch-providers.runtime.ts:42.

So the filter at src/plugins/web-provider-resolution-shared.ts:96-101 is only ever reached with params.sandboxed undefined on the search path:

        // Sandboxed web tools may run bundled providers or a verified official install,
        // never an arbitrary workspace or external plugin with the same contract.
        (!params.sandboxed ||
          plugin.origin === "bundled" ||
          plugin.trustedOfficialInstall === true) &&

The shared machinery underneath already honors the flag end to end (src/plugins/web-provider-runtime-shared.ts:26, :93, :107), so nothing else is missing. Only the search wrapper never passes it.

Scope note, deliberately narrow: this is a trust-boundary policy that does not take effect for one tool. It is not a demonstrated sandbox escape or code-execution bypass. The provider still has to be installed and enabled in config to be resolved at all. What is lost is the origin restriction the policy states.

Sibling surfaces

web_fetch threads the flag correctly at src/web-fetch/runtime.ts:212-219, and that call shape is pinned by an assertion at src/web-fetch/runtime.test.ts:491. src/web-search/runtime.test.ts contains zero occurrences of sandboxed. This looks like a one-sided fix: the sibling got the guard and the search path did not.

Suggested fix, since this is an issue and not a patch: thread sandboxed from src/web-search/runtime.ts:271-279 into both resolver signatures the same way src/web-fetch/runtime.ts:212-219 does, and add the mirror of the src/web-fetch/runtime.test.ts:491 assertion.

Real behavior proof

Behavior addressed: for a sandboxed agent, a workspace-origin plugin provider is filtered out of web_fetch resolution but survives web_search resolution.
Real environment tested: real exported provider resolvers driven in-process over a real on-disk workspace plugin, at commit c973fe7 (src/web-search/runtime.ts is byte-identical to 67e99bc)
Exact steps or command run after this patch: node --import ./scripts/tsx.mjs probe.ts, calling resolvePluginWebSearchProviders({config, workspaceDir}) and resolvePluginWebFetchProviders({config, workspaceDir, sandboxed: true}) on the same config and the same workspace containing the untrusted-web plugin above
Evidence after fix:

# OBSERVED (buggy, origin/main c973fe7e72)
web_search shape  resolvePluginWebSearchProviders({config})           : ["brave/brave","codex/codex","duckduckgo/duckduckgo","exa/exa","firecrawl/firecrawl","firecrawl/firecrawl-free","google/gemini","xai/grok","moonshot/kimi","minimax/minimax","ollama/ollama","parallel/parallel","parallel/parallel-free","perplexity/perplexity","qa-lab/qa-lab-search","searxng/searxng","tavily/tavily","untrusted-web/untrusted"]

# EXPECTED (correct behavior on identical inputs)
web_fetch  shape  resolvePluginWebFetchProviders({config,sandboxed})  : ["firecrawl/firecrawl"]

# counterfactual, same search resolver once sandboxed is threaded through
web_search shape + sandboxed threaded                                 : ["brave/brave","codex/codex","duckduckgo/duckduckgo","exa/exa","firecrawl/firecrawl","firecrawl/firecrawl-free","google/gemini","xai/grok","moonshot/kimi","minimax/minimax","ollama/ollama","parallel/parallel","parallel/parallel-free","perplexity/perplexity","qa-lab/qa-lab-search","searxng/searxng","tavily/tavily"]

# control, the same plugin is visible to web_fetch when sandboxed is absent
web_fetch  shape, no sandboxed (control)                              : ["firecrawl/firecrawl","untrusted-web/untrusted"]

Observed result after fix: untrusted-web/untrusted is dropped by the fetch shape and by the counterfactual search shape, and retained only by the search shape as main builds it, so the single differing input is whether sandboxed reaches the resolver.
What was not tested: no live sandboxed agent session was run and no network search was issued, so the downstream consequence of the untrusted provider actually answering a query is inferred from resolution output rather than observed; the preferRuntimeProviders branch through resolveRuntimeWebSearchProviders was read but not driven; the workspace plugin used here is a minimal local one rather than a published external install, so the trustedOfficialInstall arm of the filter was not exercised.

Activity

  1. added
    P2
    clawsweeper:needs-security-review
    clawsweeper:no-new-fix-pr
    clawsweeper:source-repro
    impact:security
    issue-rating: 🦞 diamond lobster
    on Sep 10, 2026
  2. clawsweeper commented on Sep 10, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 10, 2026, 11:58 AM ET / 15:58 UTC.

    Summary
    The reported omission remains in current main and v2026.9.3 source. This is a concrete provider-policy defect worth retaining; the available evidence does not establish a sandbox escape, and no canonical fixing PR was identified.

    Reproducibility: yes. at the source level: the actual tool forwards sandbox status, then candidate selection drops it before the existing trust filter. No runtime reproduction was executed during this read-only review.

    Next step
    Route the bounded repair through OpenClaw security handling before implementation; the trust-policy surface excludes unattended issue-to-PR dispatch.

    Security
    Needs attention: The sandboxed provider-origin restriction is bypassed by an omitted flag, without evidence of a broader sandbox escape.

    Review details

    Best possible solution:

    Carry sandbox status through both search-resolution handoffs and resolver signatures, retaining the shared trust-policy owner and proving excluded providers never execute while permitted providers still work.

    Do we have a high-confidence way to reproduce the issue?

    Yes, at the source level: the actual tool forwards sandbox status, then candidate selection drops it before the existing trust filter. No runtime reproduction was executed during this read-only review.

    Is this the best way to solve the issue?

    Yes, forwarding the existing flag is the narrow repair, provided it covers the earlier candidate-to-loader handoff as well as both resolver signatures and verifies provider execution behavior.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The reporter demonstrated resolver eligibility, not a live sandboxed query reaching an excluded provider; downstream impact remains unmeasured.
    • Applying the existing restriction may make sandboxed searches using third-party providers unavailable; the repair needs explicit coverage of that outcome and unchanged non-sandboxed behavior.

    Codex review notes: model internal, reasoning medium; reviewed against 7af9cef3040e.

    Label changes

    Label changes:

    • add P2: A source-proven provider-origin restriction is ineffective, but the demonstrated scenario requires an installed, enabled plugin and establishes no sandbox escape.
    • add impact:security: The report concerns enforcement of the explicit sandboxed provider trust policy.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:needs-security-review: Current issue advisory state selects this label.

    Label justifications:

    • P2: A source-proven provider-origin restriction is ineffective, but the demonstrated scenario requires an installed, enabled plugin and establishes no sandbox escape.
    • impact:security: The report concerns enforcement of the explicit sandboxed provider trust policy.
    Evidence reviewed

    Security concerns:

    • [medium] Search selection omits the sandboxed provider restriction — src/web-search/runtime.ts:290
      The search runtime drops sandbox status before shared provider resolution, allowing otherwise eligible workspace or external providers to remain candidates despite the stated origin policy.
      Confidence: 0.99

    What I checked:

    • Current source proves two missing handoffs: resolveWebSearchCandidates omits options.sandboxed when constructing loadSortedWebSearchProviders arguments at lines 290–296; that helper also lacks the field and omits it from resolver arguments at lines 275–278. Repairing only the final call would therefore be incomplete. (src/web-search/runtime.ts:290, 7af9cef3040e)
    • Search wrappers omit the supported restriction: Both search resolver parameter types omit sandboxed. The underlying shared runtime accepts and forwards it, and the manifest candidate filter explicitly excludes non-bundled, non-verified providers when it is true. (src/plugins/web-search-providers.runtime.ts:52, 7af9cef3040e)
    • Actual tool entrypoint carries sandbox status: createWebSearchTool passes sandboxed into runWebSearch. Candidate execution subsequently invokes the selected provider’s factory and execute method without another origin check. This is an OpenClaw-owned provider-selection contract, independent of any particular provider implementation. (src/agents/tools/web-search.ts:134, 7af9cef3040e)
    • Sibling contract and regression coverage: The fetch runtime explicitly passes sandboxed: true even when runtime providers are preferred. Its focused test checks this routing, and public fetch documentation describes bundled or verified-official provenance as the permitted sandboxed provider set. (src/web-fetch/runtime.test.ts:492, 7af9cef3040e)
    • Latest release remains affected in source: The v2026.9.3 tag resolves to the supplied latest-release SHA. Its search runtime retains both missing handoffs, while its shared provider filter already supports sandboxed restrictions; no fixed-release claim is supported. (src/web-search/runtime.ts:275, 1391f7cd2d40)
    • Reporter supplies bounded resolver evidence: The supplied issue body records real exported resolver output over an on-disk workspace plugin at c973fe7. It explicitly excludes live agent execution, network search, runtime-preferred resolution, and official-install provenance from its tested scope. Current source independently supports the flag omission.

    Likely related people:

    • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:needs-security-reviewclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:securityissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions