Repository navigation
v1.42.2
Security fixes, from a report sent privately by Victor Martins on the day v1.42 came out (source review of v1.42; nothing was tested against a live system). Five findings, and four smaller ones; all are fixed here. Upgrade if you run the admin portal with operator accounts, OAuth, [admin.ai] with a server key, or tokens limited to reading.
Security
- ZMCP-01: stored XSS in the report template preview (operator to admin). A custom template is HTML its author writes, and the preview showed it on the portal's own origin, in a frame without a sandbox. An operator could save a template with a script; an admin who opened its preview ran that script with an admin session (new admin account, new tokens, settings). The same template reached the visual editor too: GrapesJS draws it on the portal's origin, and its own filter lets through, among others,
<iframe src="JavaScript:...">(it checks the scheme case-sensitively), so opening the template was enough. Now:- A template with markup that runs script or loads another document (
<script>,<iframe>,<object>,<embed>,<base>, anon...=handler,srcdoc,formaction, GrapesJS's owndata-gjs-...attributes (data-gjs-scriptis a script the editor runs), ajavascript:,vbscript:ordata:text/htmlURL, also behind entities or with characters a browser ignores) is refused when it is saved. Reports never need any of it: WeasyPrint runs no script. The built-in templates have none. - A template saved before this release with such markup opens as HTML source only; the visual editor refuses it (checked again in the browser, in an inert
DOMParserdocument, before anything is handed to GrapesJS), and GrapesJS's own filter is set to its strictest. - AI-generated templates go through the same check before they reach the editor.
- Both previews (custom and built-in) are served with
Content-Security-Policy: sandbox(no script runs, the page has no origin of its own) and shown in an<iframe sandbox>throughsrcdoc. The portal as a whole now sendsobject-src 'none'; base-uri 'self'; frame-ancestors 'self'.
- A template with markup that runs script or loads another document (
- ZMCP-02: OAuth consent not bound to the browser that logged in. The consent step was identified by the
request_idalone, which travels in the login link. With OAuth on, somebody could register a client of their own (dynamic registration needs no login), send a portal user the login link, and post "Allow" themselves once that user had signed in: the code went to their redirect URI. The login now gives the browser an HttpOnly, SameSite=Strict cookie with a random value, one per login (two clients connecting at once do not get in each other's way) and as long-lived as the login request; the consent step is accepted only with it (oauth.consent_rejectedin the audit log otherwise). The consent form also posts to the configured[oauth].login_pathnow, not always to/oauth/login. The consent screen also names the host the access goes to, next to the name the client gave itself. Only with[oauth].enabled = true(off by default). - ZMCP-03:
userdirectory.testcounted as a read. Zabbix fills in the stored LDAP bind password and connects to the host given in the call, so a token limited to reading (with theusersscope, against a Super admin API token) could have the bind password sent to a host of its choosing. It is a write now: not callable by a read-only token, on a read-only server, or through the raw API tool on either.user.loginis a write too (it tries a password against Zabbix and opens a session). Neither is sent a second time after a lost answer any more. - ZMCP-04: the server's AI key sent to an address the caller chose.
POST /templates/generate(operators) tookapi_basefrom the request and used it with the key in[admin.ai]. A per-callapi_baseis now used only with a per-call provider and key; it must be http(s), must not resolve into a private, loopback or link-local network, and the connection itself is checked to be to a public address (so a name that resolves elsewhere the second time is caught as well); such a request goes straight to the endpoint, never through anhttp(s)_proxythe server has, where the address seen would be the proxy's. Theapi_baseinconfig.tomlmay be local. Requests to an AI provider no longer follow redirects (a public endpoint could answer 302 to169.254.169.254). What a provider answers when it is not what was asked for, an error or a reply without content, goes to the server log, not back to the caller. - ZMCP-05: any file readable through
report_logo. The path came from a settings field an operator could post, and the template preview read whatever file it named into the page (config.tomlwith its tokens,/proc/self/environ). The field is set by the logo upload only now, and the preview reads the logo with the reports' own reader (PNG, JPG or SVG, no symbolic link).
Found by our own audit after the report
Three further reviews of the whole code (authorization, injection and data flow, authentication and secrets) went looking for more of the same kind. Each finding was reproduced on a local instance, fixed, and re-tested by the same review.
- Stored XSS through an OAuth client name, by anybody who can reach the MCP port (with
[oauth]on). Dynamic registration needs no login; the client's name was put into a JavaScript string inside anonsubmit=attribute, where HTML escaping does not hold (the browser decodes it before the script runs). An admin who clicked Revoke on that client ran the attacker's script. The same pattern with a template's display name let an operator act as an admin. Every value in an inline handler of the portal is now passed as a JSON literal. - A deleted, demoted or re-passworded portal user stayed logged in for up to 8 hours, and kept their OAuth tokens indefinitely (a refresh renewed them). A deleted admin could still create a new admin. Every portal request now checks the session against config.toml (user, role, password), and an OAuth token is refused once its user is deleted, given another role or a new password. One's own change of password or role keeps one's own session.
- CSRF check bypassed with a second
admin_sessioncookie. A cookie planted from a sibling subdomain in front of the real one made the check skip the request while the handler acted on the real session. A request with two such cookies is refused now. - An OAuth client's IP allowlist and lifetimes held for the first token only. A refresh, or an access token used from anywhere, went through. Both are checked on refresh and on every access token now, and the client's own lifetimes are kept.
- Report e-mail could reach any address.
allowed_recipientswas matched with a glob against the whole string, soattacker@evil.test x@example.commatched*@example.comand the mail went to both. Only one bare address per recipient is accepted now, and the mail is sent to exactly the checked list. - A read-only token could write files and send mail through
report_generate(save_to_file,email_to). Those now need a token that may write. - Operators could hand out more than their role. An operator could create, edit or regenerate an MCP token with every scope, including users and administration, which OAuth never grants an operator. Tokens an operator creates or changes are now held to the operator's OAuth limits (monitoring, data collection, alerts, extensions), and a wider token can be changed by an admin only. Within those limits an operator can still change any token, as before.
anomaly_detect,capacity_forecastandreport_generatechecked only thehostscope although they read items, trends, history, events and triggers. They check every source they read now.health_checkreports only the servers the token may use.- Unauthenticated OAuth client registration was unbounded, and each one rewrote config.toml on the event loop. At most 200 clients (names up to 100 characters, up to 10 redirect URIs), written off the event loop; when the limit is reached a warning is logged and the administrator removes unused clients in the portal.
- Login time told which user names exist (about 10 ms for an unknown name, 380 ms for a known one, portal and OAuth). Both take the same time now.
- Audit log export: a cell starting with
=,+,-or@(a user name typed at a failed login) was a live formula in a spreadsheet; it is text now. - Dependencies:
opentelemetry-api(installed withmcp) at least 1.45.1, which fixes a known vulnerability; an update of this server raises it.
Fixed
- Report e-mail checked neither the SMTP server's certificate nor its name (
smtplibwithout a context of its own). It does now, for STARTTLS and implicit TLS. New[reporting.email].verify_tls(defaulttrue), also in the admin portal under Settings, report e-mail: turn it off only for a server with a self-signed certificate on a network you trust. - The Zabbix API rate limit was one count for all clients, although
rate_limitis documented as per client: one token could use up the budget of all of them. It is counted per MCP token now (for OAuth, per registered client). Without a token it stays one shared count: a count per address would let a client that changes its address go past it. - PDF reports could load any
file://path and anyhttp(s)://URL a template named (WeasyPrint's default fetcher). Not reachable in v1.42, which renders built-in templates only, but it would have been with custom ones. Reports loaddata:URIs only now (WeasyPrint 62 to 70). - New
[server].require_auth(defaultfalse, also in the admin portal under Settings, TLS and access): refuse to start over HTTP on an address other than loopback when no client authentication is configured, instead of only warning.
Upgrading
- A token or a server marked read-only can no longer call
userdirectory_testoruser_login. Give such work a token that may write. - An SMTP server with a self-signed certificate stops accepting report e-mail until
verify_tls = falseis set for it. - A logo path in
config.tomlthat is not an image (PNG, JPG, SVG) is no longer shown in the preview; it never was in the reports. - A custom template is refused on save, and opens as HTML source only, when its text contains one of the patterns above anywhere, also outside a tag: the check is coarse on purpose. Jinja such as
{% if online == 1 %}(online=reads as a handler) or prose withJavaScript:hits it; rename the variable or reword the text. - A per-call
api_basein the AI template generator needs direct access to the internet from the server (no proxy is used for it); theapi_baseinconfig.tomlkeeps using the proxy. - An operator can no longer create or change MCP tokens beyond the operator's OAuth limits; existing wider tokens keep working, an admin manages them.
- A user whose password or role an admin changes, or whom an admin deletes, is logged out of the portal at once and their OAuth tokens stop working.
- A request carrying two
admin_sessioncookies is refused; a browser that has one left over from another site on the same domain needs its cookies cleared once.
Tests
- 1193 tests (65 new in
tests/test_security_report_1422.py, one class per finding, with the bypasses found in review: the editor's iframe with aJavaScript:source, a redirect to the metadata address, a reply echoed back; against v1.42.1, nearly all of them fail). In a browser (Chromium): a template with a script previews without running it; a template stored with the iframe payload, and one withdata-gjs-script, opens as source only (with the checks switched off the same template runs its script on opening, which shows the payload is live); the visual tab and saving are refused, an ordinary template still opens in the visual editor, and no page of the portal reports a CSP violation. The OAuth end-to-end tests keep the cookies a server sets, as a browser does. PDF rendering with the new fetcher checked with WeasyPrint 62.3, 66.0 and 70.0: an embedded image is rendered, afile://stylesheet and anhttp://request are not fetched.