
KERUI K259 5MP Wi-Fi (Tuya Smart Security Camera) contiene una vulnerabilidad de ejecución de código
KERUI K259 5MP Wi-Fi / Tuya Smart Security Camera firmware v33.53.87 contiene una vulnerabilidad de ejecución de código en su lógica de arranque/actualización: durante el inicio, /usr/sbin/anyka_service.sh escanea las tarjetas TF/SD montadas y, si /mnt/update.nor.sh está presente, lo copia a /tmp/net.sh y lo ejecuta como root, permitiendo que un atacante con acceso físico ejecute comandos arbitrarios.
Endpoint vulnerable : /usr/sbin/anyka_service.sh, /usr/bin/update_entry
Archivo disparador : update.nor.sh (colocado en la raíz de la tarjeta tf/sd montada)
/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 (pseudo / decompilado)
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;
}
}
crea /update.nor.sh en la raíz de una tarjeta sd/tf con el siguiente contenido
inserta la tarjeta sd y reinicia el dispositivo.
en caso de explotación exitosa, el dispositivo copiará /mnt/update.nor.sh a /tmp/net.sh, lo marcará como ejecutable y lo ejecutará. se iniciará un servicio telnet (o cualquier comando arbitrario) y permitirá acceso a una shell root.