Summary
Tasmota's Referer-based CSRF protection can be bypassed when it incorrectly accepts a crafted Referer value as coming from the device. If an administrator without a WebPassword visits a malicious page while on the device's network, the page may cause unauthorized requests to change device settings or issue console commands.
Affected context
The issue affects Tasmota devices through version 16.0.0 when the web interface relies on the vulnerable Referer check in HttpCheckPriviledgedAccess(). Risk is greatest when a device has no WebPassword and an administrator can reach it from their browser while visiting an attacker-controlled page. The described flaw involves hostname or IP substring matching in the Referer validation.
Exploit preconditions
- Attack surface: The Tasmota web interface must be reachable from the administrator's browser.
- Required access: The attacker need not authenticate to the device, but must be able to lure an administrator onto a malicious page; the described scenario concerns devices without a WebPassword.
- Trigger point: The administrator's browser makes a request to the device while the vulnerable Referer check is in use.
- Why exploitation is possible: The check can treat a crafted Referer value as trusted based on a hostname or IP substring, allowing a cross-origin request to bypass CSRF protection.
Why this happens
The underlying bug is insufficient validation of the Referer header. Treating a hostname or IP substring as proof that a request originated from the device's trusted interface can confuse attacker-controlled values with trusted origins. This is a CSRF weakness mapped to CWE-352: a browser can make authenticated or otherwise privileged requests without adequate verification of the user's intent.
Potential impact
- An attacker may issue unauthorized console commands.
- Device Wi-Fi, MQTT, or other settings could be changed.
- Firmware-related actions could be triggered.
- Device availability or network connectivity could be disrupted.
General mitigation guidance
Defensive patterns include replacing substring-based Referer checks with robust origin validation and using anti-CSRF tokens for state-changing requests. Require authentication for privileged device operations, including by default, and apply appropriate browser cookie protections where applicable. Restrict access to device management interfaces to trusted networks and limit the privileges available to management endpoints.
How teams detect issues like this
- Review request-validation code for hostname or IP substring checks used as an origin or Referer trust decision.
- Use static analysis and code review to identify state-changing routes that lack CSRF tokens or equivalent request-origin protections.
- Test security policies to confirm that cross-origin requests cannot invoke privileged actions and that sensitive operations require authentication.
- Monitor device management activity for unexpected configuration, console, or firmware changes.

