Synopsis
Tenable has discovered a couple of vulnerabilities in the port 37777 interface found on a variety of Amcrest/Dahua IP camera and NVR devices. Initially, we verified these vulnerabilities to be present on the Amcrest IP2M-841 and Amcrest 1080-Lite 8CH, and Amcrest verified the issue on a number of their other products. We also assume the vulnerabilities are present among other Dahua developed devices.
CVE-2020-5735: Remote Authenticated Stack Buffer Overflow
A remote authenticated attacker can send a crafted message to port 37777 and overflow a stack-based buffer. Specifically, using command 0x62 with subcommand 0x04 invoke DDNS testing logic within the device. When providing the DDNS testing logic with a large Protocol field value a memcpy() will write beyond the bounds of a stack buffer. At the very least, the resulting crash force the camera to reboot. We also believe that this could be used to execute arbitrary code.
We've created a proof of concept that reproduces the crash. You can find it on our GitHub.
CVE-2020-5736: Remote Authenticated Null Ptr Dereference
A remote authenticated attacker can send a crafted message to port 37777 and crash the device. Specifically, invoking command 0xa2 to reach the log search functionality and providing a payload length of 0 results in the crash due to a NULL pointer dereference
We've created a proof of concept that reproduces the crash. You can find it on our GitHub.
Brute forcing over port 37777
Amcrest / Dahua have taken steps to ensure that login brute force attacks cannot take place over the HTTP interface. For example, the NVR under test only allows 10 login attempts and the camera under test allows 30 attempts. However, there is no restriction on the number of login attempts over port 37777 despite using the same credentials. Furthemore, this interface offers all the administrative capabilities and video/audio streaming offered by the HTTP interface. The only thing preventing brute force attacks on port 37777 is a proprietary login algorithm which we have obviously have implemented in our PoC.
As such, we suggest user's not expose this port to the internet. However we observe that Shodan has flagged ~1.3 million hosts exposing this interface.
Solution
Amcrest passed the following solution to Tenable.
Amcrest_SD-Mao-Rhea_Eng_N_Stream3_AMCREST_V2.623.00AC004.0.R.200316.bin applies to the following models: IP2M-853EW IP2M-858W IP4M-1053EW IP2M-866W IP2M-866EW Amcrest_XVR5x04-X1_Eng_N_Amcrest_V4.000.00AC000.0.R.200218.bin applies to the following models: AMDV10814-H5 Amcrest_IPC-AWXX_Eng_N_AMCREST_V2.420.AC00.18.R.20200217.bin applies to the following models: IP2M-841 IPM-721 IPM-HX1 Amcrest_IPC-HX2(1)XXX-Sag_Eng_N_AMCREST_V2.800.00AC000.0.R.200330.bin applies to the following models: IP8M-2597E Amcrest_IPC-Consumer-Web-Mao-Molec_Eng_N_AMCREST_V2.800.0000000.6.R.200314.bin applies to the following models: IP2M-841-V3 Amcrest_IPC-HX5X3X-Rhea_Eng_NP_Stream3_AMCREST_V2.622.00AC000.0.R.200320.bin applies to the following models: IP8M-2493EB IP8M-2496EB IP8M-2454EW IP8M-T2499EW IP8M-MT2544EW IP8M-MB2546EW
Additional References
https://amcrest.com/firmwaredownloadshttps://www.shodan.io/search?query=port%3A%2237777%22
Disclosure Timeline
All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.
Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.
For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.
If you have questions or corrections about this advisory, please email [email protected]