# Security model `plugin_websearch` makes **outbound** requests and holds **your API keys**. Two questions matter, and this file answers both precisely: 1. *What can this binary reach, and can it be pointed somewhere it should not?* 2. *Where do my keys live, and can anything read them back out?* There is no filesystem write outside the one config file, no process spawning, and no inbound listener: it is a CGI program and an MCP stdio server. ## 1. What leaves the node Exactly one kind of outbound request: an HTTPS exchange with the search backend that is currently active. | Backend | Request | Credential sent | |---|---|---| | `duckduckgo` | `POST {base}/html/` (form body) | none | | `searxng` | `GET {base}/search?format=json` | none (a self-hosted URL may carry its own auth in the URL — your choice, it is not added by this plugin) | | `brave` | `GET {base}/res/v1/web/search` | `X-Subscription-Token: ` | | `tavily` | `POST {base}/search` | `Authorization: Bearer ` | | `exa` | `POST {base}/search` | `x-api-key: ` | | `perplexity` | `POST {base}/search` | `Authorization: Bearer ` | **Your query goes to that backend.** That is what a search tool is for; it is stated here so it is never a surprise. Nothing else is transmitted — no session content, no hostname, no username, no node id. Base URLs are operator-supplied (config or environment) and must start with `http://` or `https://`; anything else is refused at save time *and* by the URL parser. A URL with `userinfo@` is refused by the parser, and a host containing anything outside `[A-Za-z0-9.-]` is refused too, so a crafted base cannot smuggle a different host or a shell fragment. ## 2. TLS is verified, everywhere, with no downgrade The transport is the SCORPIOX BOT Connector SDK's HTTP/1.1 + TLS client, vendored: * TLS **1.2 minimum**, chain verified against `src/ca_roots_pem.h` (compiled in) plus any operator bundle via `SX_CA_BUNDLE`, **hostname checked** against the certificate. * There is **no** "skip verification" setting in the config file and **no** HTTP parameter that reaches it. The single escape hatch is the environment variable `SX_TLS_INSECURE=1`, which is documented as debug-only and is logged loudly. * No `libcurl`, no `OpenSSL`, no system CA file is required at runtime — there is nothing on the host that can be swapped underneath the binary to weaken it. * Every phase (DNS, connect, handshake, each read) has its own absolute deadline, and the response body is capped, so a hostile server cannot hang the plugin or exhaust memory. ## 3. Where keys live, and why they never come back `~/.scorpiox/connectors/plugin_websearch/config.json` (or `/workspace/.scorpiox/connectors/plugin_websearch/config.json` on BotCloud), **mode 0600**, written atomically (temp file → `rename`). The directory is chosen deliberately **outside** the plugin's own directory so a plugin update cannot take the keys with it. * No JSON response and no MCP response ever contains a key. The page and the tools only learn `has_key: true|false`. * The page's key inputs are `type="password"`, they are cleared after a save, and the serverside never echoes a key back into the HTML. * An empty key field means *leave the saved key alone*; removing one is an explicit `clear__key` field, so "I tabbed past the box" cannot silently unset it. * `tests/run.sh` asserts that neither the save response, the providers response, nor the page markup contains the key that was just written. ## 4. Node authentication The node API's `:8150` is LAN-reachable, so the page and the JSON API are gated: * Accepted credentials: `X-Bot-Password: `, `Authorization: Bearer `, `?pwd=` (the last one is what the bot's plugin iframe appends). * When `BOT_PASSWORD` is unset the gate is a no-op — that is the node's own policy, not this plugin's. * `--meta` and `--mcp` return **before** the gate: discovery (`/plugins`) and the `sx-connector-mcp` router must work without a password, and neither answers a web request. `tests/run.sh` proves a bare `GET` is `401` while a set node password is configured. ## 5. Untrusted markup: DuckDuckGo only DuckDuckGo has no API, so its result page is parsed. That page is the only attacker-influenced markup in the tree, and it is treated accordingly: * Nothing is written by a page: the parser only ever fills fixed, bounded buffers. * Tag stripping drops `