You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CSRF Vulnerability in Firmware Update Endpoints Allows Remote Code Execution
Critical
me-no-dev
published
GHSA-9vfw-wx65-c872Jun 30, 2025
Package
ESP32 Arduino
(Arduino)
Affected versions
< 3.2.1
Patched versions
3.2.1
Description
Summary:
Several OTA update examples and the HTTPUpdateServer implementation in this repository are vulnerable to Cross-Site Request Forgery (CSRF). The update endpoints accept POST requests for firmware uploads without CSRF protection. This allows an attacker to upload and execute arbitrary firmware, resulting in remote code execution (RCE).
The firmware update endpoints (e.g., /update) do not implement CSRF protections such as anti-CSRF tokens or Origin/Referer header checks.
In the provided examples, and by default in HTTPUpdateServer, the update endpoint may be unauthenticated or left unauthenticated by users following the examples.
Even if authentication is enabled (e.g., via username and password), CSRF remains a risk: if a user is already logged in via their browser, a CSRF attack will still work because the browser will send the saved credentials (e.g., via cookies or HTTP auth) along with the forged request.
An attacker can trick a user (who is on the same network as an ESP32 device running vulnerable code) into visiting a malicious website that silently uploads a malicious firmware image to the device’s update endpoint.
Attack Scenario:
The device is connected to a local network running any of the vulnerable examples or code.
A user who previously authenticated to the device's update endpoint visits a malicious website.
The site issues a POST request (with a malicious firmware image) to the device’s /update endpoint.
The browser automatically includes the user’s credentials, if any.
The device installs and runs the attacker’s firmware (RCE).
Impact:
Remote code execution on affected ESP32 devices.
Complete compromise of device integrity and functionality.
Potential lateral movement within local networks.
Proof of Concept (PoC):
A minimal HTML page that exploits the vulnerability (user must be on the same network as the device):
<formid="csrf" action="http://<device-ip>/update" method="POST" enctype="multipart/form-data"><inputtype="file" name="update" /><inputtype="submit" value="Upload malicious firmware" /></form><script>// To send automatically with a malicious payload, use fetch or submit via JS</script>
Recommended Remediation:
Require authentication for all update endpoints by default (username/password).
Implement CSRF protection on all web forms (per-session random tokens, and/or Origin/Referer checks).
Advise in documentation that authentication mitigates but does not eliminate CSRF risk—anti-CSRF measures are required even when authentication is used.
Summary:
Several OTA update examples and the
HTTPUpdateServer
implementation in this repository are vulnerable to Cross-Site Request Forgery (CSRF). The update endpoints accept POST requests for firmware uploads without CSRF protection. This allows an attacker to upload and execute arbitrary firmware, resulting in remote code execution (RCE).Impacted Source Files:
Vulnerability Details:
/update
) do not implement CSRF protections such as anti-CSRF tokens or Origin/Referer header checks.Attack Scenario:
/update
endpoint.Impact:
Proof of Concept (PoC):
A minimal HTML page that exploits the vulnerability (user must be on the same network as the device):
Recommended Remediation:
References: