CVE-2024-27081: Esphome Remote Code Execution Vulnerability
HIGHCVE-2024-27081 is a HIGH (CVSS 7.2) remote code execution vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Esphome libraries in the PyPI ecosystem. The issue involves esphome vulnerable to remote code execution via arbitrary file write. Remediation is available by upgrading affected packages to version 2024.2.1.
CVE-2024-27081 at a Glance
Security Impact
CVSS: 7.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-27081
To remediate this vulnerability, upgrade all affected Esphome dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install esphome>=2024.2.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show esphome
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2024-27081, inspect your installed packages using pip:
pip show esphome
Analyze the terminal output to locate any version of Esphome in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2024.2.1), your application is affected.
Note: The pip show esphome command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Esphome, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-27081 Affected Esphome Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
esphome
|
PyPI |
≥ 2023.12.9
< 2024.2.1
All 1 versions
2023.12.9
|
2024.2.1
|
References
Frequently Asked Questions
What is CVE-2024-27081?
Which Esphome versions are affected?
What version fixes CVE-2024-27081?
Is esphome affected?
What is the CVSS score of CVE-2024-27081?
What CWE is associated with CVE-2024-27081?
How can I check PyPI dependencies for CVE-2024-27081?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-8p25-3q46-8q2p",
"modified" : "2025-02-07T20:44:54Z",
"published" : "2024-03-01T20:09:19Z",
"aliases" : [ "CVE-2024-27081" ],
"summary" : "ESPHome vulnerable to remote code execution via arbitrary file write",
"details" : "### Summary\nSecurity misconfiguration in edit configuration file API in dashboard component of ESPHome version 2023.12.9 (command line installation) allows authenticated remote attackers to read and write arbitrary files under the configuration directory rendering remote code execution possible.\n\n### Details\nIt is possible to abuse this path traversal vulnerability both in command line installation and Home Assistant add-on, but it is possible to read and write files only under the configuration directory. \n\nThe vulnerability is present and exploitable in the command line installation, but it was not possible to confirm an impact in the home assistant add-on version.\n\n### PoC\n<img width=\"482\" alt=\"/edit?configuration=/config/.esphome/esphome.json\" src=\"https://github.com/esphome/esphome/assets/115887876/d2da3180-976e-4bed-b4b9-35ac960a7fb4\">\n<br/>\n\n<img width=\"344\" alt=\"/edit?configuration=/config/.esphome/build/test01/src/main.cpp (firmware for board named test01)\" src=\"https://github.com/esphome/esphome/assets/115887876/707fb6d7-d4a8-461e-bbb7-05382471e925\">\n<br/>\n\n<img width=\"482\" alt=\"RCE payload POST request on /edit?configuration=.esphome/platformio/packages/tool-esptoolpy/esptool.py\" src=\"https://github.com/esphome/esphome/assets/115887876/c6cb28d8-352d-4fea-b77a-705f63be94e3\">\n<br/>\n\n<img width=\"482\" alt=\"Arbitrary code execution during ESP board flashing\" src=\"https://github.com/esphome/esphome/assets/115887876/5eb0f14c-ceb2-4b15-8898-c02c610763d1\">\n\n\n### Impact\nThe issue gives read and write access to files under the configuration directory and allows malicious users to write arbitrary code in python scripts executed during the compilation and flashing of firmwares for ESP boards. \n\nIf chained with GHSA-9p43-hj5j-96h5 and GHSA-5925-88xh-6h99, this issue could allow an unauthenticated remote user to gain remote code execution on the machine hosting the dashboard.\n\nIt also allows accessing sensitive information such as esphome.json and board firmware source code allowing a user to modify the board firmware, and leaking secrets such as: WiFi network credentials, fallback hotspot WiFi credentials, OTA component authentication password and API encryption key.\n\n### Credits\nSpike Reply Cybersecurity Team",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "esphome"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2023.12.9"
}, {
"fixed" : "2024.2.1"
} ]
} ],
"versions" : [ "2023.12.9" ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/esphome/esphome/security/advisories/GHSA-8p25-3q46-8q2p"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-27081"
}, {
"type" : "WEB",
"url" : "https://github.com/esphome/esphome/commit/d814ed1d4adc71fde47c4df41215bee449884513"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/esphome/esphome"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-03-01T20:09:19Z",
"nvd_published_at" : "2024-02-26T17:15:10Z"
}
}