NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Other MCP servers and tools

CVE-2026-32112: ha-mcp has XSS via Unescaped HTML in OAuth Consent Form

mediumCVSS 3.1 6.8GHSA-pf93-j98v-25pv

The beta OAuth mode of ha-mcp (ha-mcp-oauth) builds its consent page with Python f-strings and never escapes the values. An attacker who registers a client with a malicious name and gets the server operator to open a crafted authorization link can run JavaScript in the operator's browser and steal the Home Assistant Long-Lived Access Token. Upgrade to ha-mcp 7.0.0.

Published Mar 12, 2026 · Analysis Oct 31, 2026

What an attacker can do

consent_form.py renders client_name, client_id, redirect_uri, state and several error fields straight into HTML, and html.escape() is not called anywhere in the file. In attribute context, a double quote breaks out of the value attribute. In element context, markup goes through as is.

The attacker needs three things. First, network reach to the OAuth endpoint, which binds to 0.0.0.0 in HTTP mode. Second, a malicious client registered at /register. Dynamic client registration is open by default with no initial access token, because Claude.ai and ChatGPT must self-register. Third, the operator, the person who set up ha-mcp, has to open an authorization URL for that unfamiliar client. The advisory calls this step a meaningful social engineering bar, and it raised attack complexity to high.

If it works, the script runs in the consent page and can read what the operator types into the form, including the Home Assistant Long-Lived Access Token. That token gives access to the smart home. The default stdio mode is not affected.

Who is affected

ha-mcp (pip) 6.7.2 and earlier, in OAuth mode only (ha-mcp-oauth, which needs MCP_BASE_URL). The advisory states that most users run stdio mode, which is not affected.

pip show ha-mcp

If your launch command or service file does not run ha-mcp-oauth or set MCP_BASE_URL, you are not on the vulnerable path.

ha-mcp

Ecosystem
PyPI
Affected
< 7.0.0
Fixed in
7.0.0
Check
pip show ha-mcp

How to fix it

Upgrade to ha-mcp 7.0.0.

pip install --upgrade ha-mcp

The advisory names no workaround. Until you can upgrade, run stdio mode, or keep the OAuth endpoint off networks that attackers can reach, and never open an authorization link for an application you did not set up yourself. If you may have used a crafted link, revoke and replace the Home Assistant Long-Lived Access Token.

How to tell if you were hit

Check the list of registered OAuth clients and the /register request logs for client names that contain angle brackets, script tags, quotes or event handler attributes such as onerror. Look for consent page requests for clients you did not start from Claude.ai or ChatGPT. In Home Assistant, review the Long-Lived Access Token list and the login and API history for use from addresses you do not know.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

The ha-mcp OAuth consent form renders user-controlled parameters via Python f-strings with no HTML escaping. An attacker who can reach the OAuth endpoint and convince the server operator to follow a crafted authorization URL could execute JavaScript in the operator's browser. This affects only users running the beta OAuth mode (ha-mcp-oauth), which is not part of the standard setup and requires explicit configuration.

Details

Unescaped f-string rendering

consent_form.py builds HTML using Python f-strings. No call to html.escape() exists anywhere in the file. The following values are rendered unescaped:

  • client_name / client_id — in HTML element context (lines 299, 303)
  • client_id, redirect_uri, state — in HTML attribute context (lines 310–312), where a " character breaks out of value=""
  • error_message, error, error_description — in error display paths (lines 36–40, 496–497)

An attacker can register a client with a malicious client_name via the /register (DCR) endpoint, which accepts client_name without sanitization. If the server operator then visits a crafted authorization URL for that client, the payload executes in their browser.

Open Dynamic Client Registration

DCR is enabled by default with no initial access token required. This is intentional: Claude.ai and ChatGPT must self-register on first use, which is the standard MCP OAuth flow (RFC 7591). Requiring a pre-shared token would break those integrations. Registration alone grants no access — authorization requires an explicit action by the server operator.

Impact

Affected configuration: OAuth mode only (ha-mcp-oauth, requires MCP_BASE_URL). This mode is in beta and is not included in the main setup documentation. The vast majority of ha-mcp users run stdio mode, which is not affected.

Attack requirements:

  1. The attacker can reach the ha-mcp OAuth endpoint (it binds to 0.0.0.0 in HTTP mode)
  2. The attacker registers a malicious client via /register
  3. The attacker convinces the server operator — the person who set up ha-mcp — to follow a crafted authorization URL for an unrecognized application

Step 3 is a meaningful social engineering bar: the consent form displays the (unfamiliar) application name, and the operator has no legitimate reason to authorize an OAuth client they didn't initiate through Claude.ai or ChatGPT. Normal usage involves being redirected to the consent form from one of those platforms, not from an external link.

If exploited, a JavaScript payload could exfiltrate data entered into the consent form, including the Home Assistant Long-Lived Access Token.

Fix

Upgrade to 7.0.0

Credited to yotampe-pluto, julienld.

Questions

Is CVE-2026-32112 exploitable against stdio mode?

No. Only the beta OAuth mode (ha-mcp-oauth with MCP_BASE_URL) renders the consent form. The advisory says the vast majority of users run stdio.

Does the attacker need an account?

No account, but they need network reach to the OAuth endpoint, a client registered through open dynamic registration, and the operator following a crafted link.

What can the script steal?

Data entered into the consent form, including the Home Assistant Long-Lived Access Token.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Other MCP servers and tools vulnerabilities

All Other MCP servers and tools entries