# Security notes — `plugin_github` This plugin is a native executable that runs with your node user's permissions and talks to a network service you configure. Here is exactly what it does and what it guards. ## What the binary can do | Capability | Where | Why it is needed | |---|---|---| | Outbound TCP 80/443 to the configured API base | `src/gh_api.c` via `src/sx_http_tls.c` | GitHub REST calls (`/repos/…`, `/search/code`, `/user`) | | Read/write `config.json` (mode `0600`) in the connector directory | `src/gh_config.c` | store your PAT + API base locally | | Stdin/stdout JSON-RPC when run with `--mcp` | `src/sx_connector.c` | the agent-facing MCP server | | Nothing else | — | no `popen`, `system`, `exec`, `fork`, or shell-out anywhere in the connector's own sources (asserted by `tests/run.sh`) | ## Credential handling - The token is read from `GITHUB_TOKEN` (environment) or `/config.json` (`0600`, written atomically via temp+`rename()` and `chmod(0600)` after). - It is **never** serialized into a JSON response, a tool reply, the HTML page, or an error message. The suite asserts on every action that the exact stored token string does not appear in the answer. - `Disconnect` deletes the token from the store and keeps the API base. - On Windows the connector directory is `%LOCALAPPDATA%\scorpiox\connectors\plugin_github`. ## Transport - HTTPS with vendored BearSSL (no libcurl, no OpenSSL, no system CA file). Chain verification runs against a compiled-in root store plus optional `SX_CA_BUNDLE` / system bundles as extra anchors, **with hostname verification**. TLS 1.2 is the floor. - The single escape hatch is the environment variable `SX_TLS_INSECURE=1`, meant for debugging a self-hosted instance. It is never readable from `config.json`, a query string, or a POST body — `tests/cgi.py` proves the JSON API ignores it as a request parameter. - `http://` is accepted for the API base because the offline test suite and air-gapped GitHub Enterprise instances use it. There is no hard-coded host: the base is environment → config → `https://api.github.com`. ## Injection surface Everything a repo owner or issue author controls eventually reaches a model through this plugin: descriptions, titles, paths. - Names (`owner`, `repo`) pass an **allow-list** check (spaces, quotes, `%`, `?`, `#`, `&`, `<`, `>`, control and non-ASCII bytes are refused before any socket opens). Paths/queries are percent-encoded. - Response text is copied out of the JSON document **before** the document is freed, control bytes in rendered lines are replaced, and anything placed in JSON goes through the escaper — a malicious title cannot forge a row or break the MCP reply. - Tool output is hard-capped well under the SDK's reply buffer. ## Node authentication Every `?action=` (`status`, `save`, `test`, `tools`, `clear`) requires the node password (`X-Bot-Password`, `Authorization: Bearer`, or `?pwd=`), and `tests/cgi.py` drives the binary as a real CGI to prove each one answers 401 without it. Only `--meta` (discovery) and the static page shell are unauthenticated, exactly like every other plugin. ## Rate limits and failure - A `429` or `5xx` is retried **once**, sleeping `min(Retry-After, 5 s)`. A CGI request or tool call never turns into an unbounded wait. - Upstream refusals are relayed with GitHub's own `{"message": …}` text (and GraphQL-style `errors[0].message`), because that message is the user's one actionable fact. A `401` saying `Requires authentication` or `Bad credentials` is shown as-is, never replaced by a generic error. ## Honest verification tier `verified` is `"mock"`: `tests/run.sh` proves every request and response path against a recording mock, not against a paid/live account harness. The release report additionally documents a manual smoke test against the real `api.github.com`, but CI does not depend on it and the badge stays honest.