scorpiox-bot-plugin-websearch
←SECURITY.mdmarkdown
116 lines · 5 KBHEAD
BlameDownload

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: <key>
tavily POST {base}/search Authorization: Bearer <key>
exa POST {base}/search x-api-key: <key>
perplexity POST {base}/search Authorization: Bearer <key>

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_<provider>_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: <pwd>, Authorization: Bearer <pwd>,

?pwd=<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 <script>/<style> content wholesale (a page's inline JS must

never arrive as "result text" in the model's context), and decodes HTML entities to

UTF-8 rather than guessing a single byte.

  • Every string taken from the page reaches output through the JSON escaper, so a quote,

a control byte or a \u0000 in a title cannot break the document or truncate a

field.

  • Redirect wrappers (/l/?uddg=…) are unwrapped by percent-decoding, and only

http(s) results are kept as links.

  • The "bot challenge" page is detected and reported as a challenge, never as "no

results" — a search that silently returns nothing for months is the failure mode

this avoids.

6. What is deliberately absent

  • No process spawning. grep -E '\b(popen|system|execv|fork)\s*\(' over src/

returns nothing, and the suite fails if it ever does.

  • No filesystem writes other than config.json (written temp → rename).
  • No inbound socket in the plugin process; the node's own server owns the port.
  • **No telemetry, no analytics, no contact with any host that is not the active

backend.**

  • No hidden cache. Results are not written to disk; a repeat query is a repeat

request, so "what did it fetch" is never an archaeological question.

7. Reporting

This is an open-source plugin on plugingit.scorpiox.net — the whole history, every

commit and the source.tar.gz behind every published binary are public and auditable

(scorpiox-cli-botplugin audit scans the full history for credentials and private

addresses before each publish).