A new Hikvision tripwire.

alastairstevenson

Staff member
Oct 28, 2014
16,064
6,885
Scotland
With apologies in advance for the TL;DR aspect:

Unfortunately, not an improvement to their already quite good video analytics, but a cynical and nasty trap put in place to deliberately and permanently brick a camera where the 'mtd hack' has been attempted by a customer trying to make best use of the Hikvision product that they have acquired.

I had not seen this before, but suspect that, like various other changes they have made in response to what's been posted in public on ipcamtalk.com and other sites, this is a deliberate attempt to counter the benefits that ipcamtalk forum members have seen by doing the 'mtd hack'.
But it goes further and attempts to punish the user and permanently disable the camera.

I'd offered to take a look (for the learning experience) at a Hikvision DS-2CD2032-I camera that had been innocently bricked by a 5.4.5_170123 EN upgrade to a CN region camera, leaving it in an inconsistent language mismatch state with no web access, as has been seen a few times on this forum.
The update attempt was in response to the Hikvision statement about this firmware release fixing the recent 'Hikvision backdoor' high-severity vulnerability.

I've recently started tinkering with the camera firmware, and had a version ready for testing, which I applied.
The camera came straight to life, operating normally with EN/ML menus.
A good (and a bit surprising) result!

So I thought - why don't I do the 'mtd hack' before sending it back, so the user can update as required in the future.
Bad idea!
It turns out that Hikvision have added code to specifically trap any writes to mtdblock6, which sets a flag as a signal to routines in the normal kernel, the recovery kernel, and the bootloader that the camera should be disabled.

The consequence is that the camera permanently bootloops, and whatever firmware is applied via the tftp updater or the bootloader, the trap has been sprung and stays closed. The bootloader and the Linux kernel are primed to recognise this, and to block any recovery attempts.
Not nice.
Here is a sample error from the bootloader startup, and app startup, showing that the trap exists even at a low level:
(that was before I managed to fix it, quite simply actually, after all sorts of strange and devious attempts.)

Code:
U-Boot 1.3.4-71557 (Apr  3 2014 - 13:08:34)

ERR: status & (FIO_DMASTA_RE | FIO_DMASTA_AE)
status=0x%x05000800
FIO_DMASTA_RE=0x%x04000000
FIO_DMASTA_AE=0x%x02000000
ERR: status & (FIO_DMASTA_RE | FIO_DMASTA_AE)
status=0x%x05000800
FIO_DMASTA_RE=0x%x04000000
FIO_DMASTA_AE=0x%x02000000
ERR: status & (FIO_DMASTA_RE | FIO_DMASTA_AE)
status=0x%x05000800
FIO_DMASTA_RE=0x%x04000000
FIO_DMASTA_AE=0x%x02000000
init_boot_param:nand_read_data failed
ue
ARM Clock: 480MHz
DDR Clock: 336MHz
Hit Ctrl+u to stop autoboot: 0
|RCV UDP pack timeout|
Unknown command:null
nand booting ...
load kernel...
load ramdisk...
init started: BusyBox v1.19.3 (2015-03-20 17:37:48 CST)
starting pid 375, tty '': '/etc/init.d/rcS'
Starting udev:      [ OK ]

Code:
[04-15 07:33:08][pid:853][HW_IF][ERROR]ioctl error errno=5
[04-15 07:33:08][pid:853][SYSINIT][ERROR]hwif_getsecinfo failed.
[04-15 07:33:08][pid:853][SYSINIT][ERROR]sys app init failed to reboot!
davinci receive cmd_query_davinci_param.
S: cmd_query_davinci_param
 
Live and learn I guess, hopefully you bricked it before calling your guy saying it was fixed.

I'm actually fine with Hik trying to control their exports and guide things through properly supported channels. You may own the hardware but not the software thats loaded onto that - if things go south when trying to modify the software then thats kinda tough - Hik putting safeguards in to protect their software is their business.
 
It turns out that Hikvision have added code to specifically trap any writes to mtdblock6, which sets a flag as a signal to routines in the normal kernel, the recovery kernel, and the bootloader that the camera should be disabled.

The consequence is that the camera permanently bootloops, and whatever firmware is applied via the tftp updater or the bootloader, the trap has been sprung and stays closed. The bootloader and the Linux kernel are primed to recognise this, and to block any recovery attempts.
Not nice.

Does this mean that its monitoring for new writes? All of my cams have had the Mtd hack for a while. Am I in danger of bricking the camera if I try to update any of my cameras?
 
Does this mean that its monitoring for new writes?
I'm speculating a bit - bit it looks to me that firmware (presumably the Linux part) of 5.3.0 and over will allow you to write mtdblock6 but it quietly zeros the language byte, and uses that as a flag to throw an error for any subsequent reads. So once you get into that state, it's not easy to get out of it.
Firmware before 5.3.0 didn't do this, so the 'mtd hack' worked OK. It looks to me like it's Hikvision's attempt to throw a spanner into the benefits of the 'mtd hack'.

All of my cams have had the Mtd hack for a while. Am I in danger of bricking the camera if I try to update any of my cameras?
I don't think it's very clear how some of the older cameras take to the newer firmware.
I've updated several mtd-hacked 2032, 2332 through from 5.2.3 to 5.4.5 with no problems.
But @whoslooking has indicated that not all cameras will do this.
Maybe he can comment with some further info.
 
  • Like
Reactions: aster1x
The boot on early models was simply that, running very little in the way of checking on a region or security.
Hik started to up the game when CBX and a few others started charging people to swap the region. The models 2xx2 with mtd hacks that upgraded without issue were 5.02 5.16 5.20 5.23 Versions 5.25 and 5.28 even with no mtd and CH seem to fail an upgrade.