Tenable Research released two vulnerabilities in NVRMini2, NUUO’s Network Video Recorder software on September 17th. Risk information is as below:
Reference link: https://www.tenable.com/security/research/tra-2018-25
Attack demo: https://www.youtube.com/watch?v=2EuFOZfRL4U
Sketch of NVRMini2 structure：
CVE-2018-1149: Unauthenticated Remote Stack Buffer Overflow
The HTTP interface exposes the binary cgi_system through the http://<target>/cgi-bin/cgi_system endpoint. Much of the functionality of cgi_system requires the remote user to be authenticated. One of the ways the system verifies authentication is by comparing the session identifier in the user’s PHPSESSID cookie against the session file stored in /tmp/. In the following screenshot, you can see how the system builds up the filename of the tmp file.
The value returned from sub_534a4 is the session identifier string. The string has not been limited to any size. Similarly there is no bounds check when the string is passed into sprintf to build the tmp filename. As such a remote unauthenticated attacker can overflow the stack buffer passed into sprintf. A one line proof of concept looks like this:
Furthermore, this overflow is exploitable to achieve remote code execution. This is particularly devastating because not only is an attacker able to control the NVR but the credentials for all the cameras connected to the NVR are stored in plaintext on disk.
A common idiom in the NVRMini2’s PHP code base is to first:
- Check that the current PHP session is valid.
- Verify the session has appropriate permissions for the page being accessed (ie. admin, poweruser, user, root, guest).
However, a back door code appears in check_session_is_valid():
|if (file_exists(constant(“MOSES_FILE”))) //back door
Not a “back door” comment, it appears just like that in the code base. The constant(“MOSES_FILE“) turns out to be /tmp/moses. If the file /tmp/moses/ exists on the file system then an unauthenticated remote attacker can list all of the non-admin users and change their passwords:
At the time of disclosure, Tenable has not provided any solution yet. But they recommended users to keep their devices from being exposed to the internet and appropriately isolate the device on their networks.
- Use NSFOCUS Web Vulnerability Scanning System (WVSS ) and/or NSFOCUS Remote Security Assessment System (RSAS) to detect your vulnerable devices.
- Use NSFOCUS Network Intrusion Detection System (NIDS) to detect attack signatures in your network.
Use NSFOCUS Web Application Firwall (WAF), NSFOCUS Next-gen Firewall (NF), and/or NSFOCUS Network Intrusion Prevention System (NIPS) to isolate or block attacks.