CVE-2024-27287 ESPHome vulnerable to stored Cross-site Scripting in edit configuration file API

Medium 6.5 Published Updated

Authenticated attackers can inject scripts into ESPHome dashboard configuration files to steal session cookies and perform actions on behalf of victims.

Exploited in the wild
Not known
Login needed
An administrator
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-27287?

CVE-2024-27287 is a medium-severity cross-site scripting vulnerability in esphome, published on 6 Mar 2024. An attacker needs administrator access to exploit it, with no action from the victim.

Official description

ESPHome is a system to control your ESP8266/ESP32 for Home Automation systems. Starting in version 2023.12.9 and prior to version 2024.2.2, editing the configuration file API in dashboard component of ESPHome version 2023.12.9 (command line installation and Home Assistant add-on) serves unsanitized data with `Content-Type: text/html; charset=UTF-8`, allowing a remote authenticated user to inject arbitrary web script and exfiltrate session cookies via Cross-Site scripting. It is possible for a malicious authenticated user to inject arbitrary Javascript in configuration files using a POST request to the /edit endpoint, the configuration parameter allows to specify the file to write. To trigger the XSS vulnerability, the victim must visit the page` /edit?configuration=[xss file]`. Abusing this vulnerability a malicious actor could perform operations on the dashboard on the behalf of a logged user, access sensitive information, create, edit and delete configuration files and flash firmware on managed boards. In addition to this, cookies are not correctly secured, allowing the exfiltration of session cookie values. Version 2024.2.2 contains a patch for this issue.

Weakness: CWE-79

Which versions are affected by CVE-2024-27287?

3 open source packages ship an affected version, including esphome. It affects 1 product.

PackageAffectedFixed in
esphome PyPIFrom 2023.12.92024.2.2
esphome PyPIFrom 2023.12.92024.2.2
esphome PyPIFrom 2023.12.92024.2.2

Products include Esphome Esphome.

How do I fix CVE-2024-27287?

Upgrade esphome to 2024.2.2 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2024-27287 being exploited?

There is no known exploitation of CVE-2024-27287 in the wild and no public exploit code.

Sources

Also known as GHSA-9p43-hj5j-96h5, PYSEC-2026-1329.

Is CVE-2024-27287 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free