Repository navigation
security: rule-store fail-closed, cookie CSRF, log hygiene, protected workspace paths and model endpoint SSRF - #436
Merged
Merged
Conversation
A failed rule load left the enabled-tools set nil, so IsToolEnabled answered false for every tool and the guard returned before any rule ran; Match, MatchBuiltin and MatchPersistence answered "no match" on the same error. A database outage therefore let every tool call run unchecked. Now, when the rules or the enabled-tools setting cannot be read, IsToolEnabled answers true so the call reaches the rule path, and the three matchers return a deny. The error is logged once per outage. A failed read of the enabled-tools setting counts as a failed load instead of silently selecting the defaults. A deny or ask rule whose pattern does not compile is no longer skipped: it matches every call as a deny until it is fixed or disabled. A broken allow rule still allows nothing.
… origin requireAuth accepted the artex_token cookie on its own for every method and checked neither Origin nor Sec-Fetch-Site. The handlers decode a JSON body whatever its Content-Type, so a page on another origin of the same site (another port of the host, a sibling subdomain) could send a text/plain POST that the browser sends without a preflight and with the cookie: POST /api/mcp stored a server entry with a command. A POST, PUT, PATCH or DELETE whose session comes from the cookie must now be same-origin: Sec-Fetch-Site is same-origin, or Origin names the scheme, host and port the request was sent to. Anything else, including a request with neither header, is answered 403. Requests that carry a bearer token are not checked, nor are GET and HEAD. The /api/auth/* routes stay outside requireAuth, so setup and login are unchanged. The web console sends the bearer token on every state-changing request.
…g sink The log sink keeps every standard-logger line in a ring, persists it to server_logs and serves it through /api/logs, /api/logs/history and /api/logs/stream to any session. Two secrets went through it. The one-time setup token was logged with log.Printf. It is now printed on stderr directly, with the same wording, so `docker compose logs` and the journal still show it; the sink gets a line that says where it was printed. A global proxy with user:password was logged in full when the browser MCP was synced and when a stored value failed validation at startup, and was written with its credentials into the --proxy-server argument of the browser MCP row, which GET /api/mcp lists. The log lines and the row now carry the proxy without its userinfo. A stored address that does not parse is not written to the row at all. As a second line of defence the sink masks the password of any scheme://user:password@ it is given, in the ring and on stderr, and rows persisted earlier are masked when they are read back.
…ce deletes The workspace file manager refused traffic/_ca and traffic/_index by path, but DELETE /api/workspace/delete on their parent, traffic, removed the whole tree: the capture CA private key, the exchange index and the blobs went with it. The blob store, traffic/_blobs, was not denied at all and could be listed, read and downloaded. traffic/_blobs joins the denied prefixes, and a delete is refused with 400 when a denied prefix lies beneath the entry it would remove. A symlink to such a directory is still removed as a link.
…g upstream model errors POST /api/llm/models treated every address outside RFC 1918, loopback, link-local, multicast and the metadata addresses as public. It now also refuses 100.64.0.0/10, 198.18.0.0/15, 192.0.0.0/24, 240.0.0.0/4, NAT64 64:ff9b::/96 and 6to4 2002::/16, for literal hosts, resolved names, redirects and at dial time. An endpoint listed in ARTEX_LLM_PRIVATE_ENDPOINTS may still sit in 100.64.0.0/10 or 198.18.0.0/15, as it may in RFC 1918 space; the other ranges are never allowed. A non-200 answer was returned with the first 512 bytes of its body, which let a caller read what any reachable host answers. The answer now carries the status only.
POST /api/llm/models refused 64:ff9b::/96 and 2002::/16 as a whole. A DNS64 resolver answers with a 64:ff9b::/96 address for every IPv4-only name, so on a NAT64 network every public provider was refused and no setting brought it back. An address in 64:ff9b::/96 (the IPv4 address in the low 32 bits) or in 2002::/16 (the IPv4 address in bits 16 to 47) is now judged as the IPv4 address it embeds, by the rule a bare IPv4 address gets: private, loopback, link-local, metadata, reserved, carrier-grade NAT and unspecified addresses stay refused, a public one is accepted. The rule is the same for literal hosts, resolved names, redirects and at dial time, and an endpoint listed in ARTEX_LLM_PRIVATE_ENDPOINTS gets behind such an address what it gets as a bare IPv4 address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security hardening across the interception rules, cookie sessions, log sink, workspace file manager and the model endpoint probe. No behavior change on the normal path; the operator-facing behavior is unchanged except where a request was unsafe before.
Tests cover each item, including the cross-origin request refusal, the log masking, the delete guard, the reserved ranges for literal and resolved hosts, and the embedded IPv4 cases. The full Go suite, gofmt, vet and the Linux, Windows and Darwin builds pass.
Limits stated in the commits: the path and rule filtering remains a confinement layer, not a sandbox; other IPv6 forms that embed an IPv4 (local-use NAT64, Teredo, IPv4-compatible, operator-specific prefixes) are not treated; a database outage blocks tool calls by design; behind a TLS proxy that rewrites the host, the cookie check depends on Sec-Fetch-Site.