
KERUI K259 5MP Wi-Fi (Tuya Smart Security Camera) 코드 실행 취약점을 포함합니다.
KERUI K259 5MP Wi-Fi / Tuya Smart Security Camera 펌웨어 v33.53.87은 부팅/업데이트 로직에 코드 실행 취약점을 포함하고 있습니다. 시작 중에 /usr/sbin/anyka_service.sh가 마운트된 TF/SD 카드를 검사하고, /mnt/update.nor.sh가 존재하면 /tmp/net.sh로 복사하여 root로 실행하므로, 물리적 접근이 있는 공격자가 임의 명령을 실행할 수 있습니다.
취약 엔드포인트 : /usr/sbin/anyka_service.sh, /usr/bin/update_entry
트리거 파일 : update.nor.sh (마운트된 tf/sd 카드의 루트에 위치)
/usr/sbin/anyka_service.sh
...
start_update()
{
/usr/bin/update_entry &
}
...
umount /mnt
mount_tf_card
sh /usr/sbin/tf_update.sh
start_update
i=5
while [ $i -gt 0 ]
do
sleep 1
pid=`pgrep /usr/bin/update_entry`
if [ -z "$pid" ]; then
echo "The /usr/bin/update_entry has exited, start_update!!!"
break
fi
i=`expr $i - 1`
done
if [ $mount_status -eq 1 ]; then
if [ -f /tmp/enter_update ]; then
echo "/tmp/enter_update file is exist, should be update!"
update_flag=1
else
echo "/tmp/enter_update file is not exist!"
update_flag=0
fi
else
update_flag=0
fi
if [ $update_flag -eq 1 ]; then
/tmp/net.sh
fi
...
/usr/bin/update_entry (의사 / 디컴파일됨)
int sub_108f8()
{
FILE *v0; // r6
char v2[152]; // [sp+0h] [bp-98h] BYREF
memset(v2, 0, 0x80u);
v0 = popen("find /mnt/ -maxdepth 1 -name \"update.nor.sh\"", "r");
if (v0)
{
while (fgets(v2, 128, v0))
{
if (strstr(v2, "update.nor.sh"))
{
puts("==================find update.nor.sh!! start update.nor.sh==================");
system("cp -f /mnt/update.nor.sh /tmp/net.sh");
usleep(0x2710u);
system("chmod 777 /tmp/net.sh");
system("touch /tmp/enter_update");
system("sync");
usleep(0x2710u);
break;
}
}
pclose(v0);
return 0;
}
else
{
puts("error:popen failed");
return -1;
}
}
sd/tf 카드의 루트에 내용이 포함된 /update.nor.sh를 생성합니다.
sd 카드를 삽입하고 장치를 재부팅합니다.
성공적인 익스플로잇 시 장치는 /mnt/update.nor.sh를 /tmp/net.sh로 복사하고, 실행 가능으로 표시한 후 실행합니다. 텔넷 서비스(또는 임의 명령)가 시작되어 루트 셸 접근을 허용합니다.