🇰🇷 한글 설명
TFTP 서버가 짧은 ERROR 패킷을 보낼 때, 클라이언트가 수신된 데이터그램의 범위를 넘어 최대 64바이트를 초과하여 읽는 취약점입니다. 오류 메시지를 복사하는 루프 과정에서 데이터의 끝을 확인하지 않아 힙 버퍼 오버플로우가 발생할 수 있습니다.
💡 쉬운 설명
악의적인 서버가 잘못된 형식의 에러 메시지를 보내면, 클라이언트 프로그램이 메모리의 허용된 범위를 넘어서 데이터를 읽게 됩니다. 이 과정에서 기기의 중요한 메모리 정보가 유출되거나 프로그램이 비정상적으로 종료될 수 있습니다.
🇺🇸 원문 (English)
A TFTP server that answers with a short ERROR packet makes the client read up to 64 bytes past the
received datagram.
Each receive path checks only that the datagram is at least four bytes long (nxd_tftp_client.c:1229,
1521, 1984). When the opcode is NX_TFTP_CODE_ERROR the message string is copied with a loop whose
only limits are the destination buffer and a NUL byte:
```c
/* addons/tftp/nxd_tftp_client.c:1769 */
for (i = 0; (i < (sizeof(tftp_client_ptr -> nx_tftp_client_error_string) - 1)) && (*buffer_ptr); i++)
```
Nothing compares `buffer_ptr` against `nx_packet_append_ptr`. An ERROR packet that carries no
terminating NUL, which a server controls completely, walks the loop off the end of the packet until
it happens to meet a zero byte or fills the 64 byte destination.
```
ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 1 at 0x60d0000000c8 thread T4
#0 _nxd_tftp_client_file_read addons/tftp/nxd_tftp_client.c:1769
0x60d0000000c8 is 0 bytes to the right of 136-byte region
```
The open path has the same loop at :1327 and reports the same way. What is read lands in
`nx_tftp_client_error_string`, which the application is expected to display or log, so adjacent
packet pool memory ends up in whatever the device does with the error text.
Add `(buffer_ptr < packet_ptr -> nx_packet_append_ptr)` to the loop condition in all three paths.
📍 영향받는 시스템
nxd_tftp_client.c를 사용하는 TFTP 클라이언트 라이브러리 (NetX Duo 기반)
⚔️ 공격 벡터
조작된 ERROR 패킷을 전송하는 악의적인 TFTP 서버를 통한 네트워크 공격
🛡️ 대응 방법
데이터 복사 루프 조건에 buffer_ptr이 packet_ptr->nx_packet_append_ptr보다 작은지 확인하는 검증 로직을 추가해야 합니다.
🔧 검증 코드
소스 코드 내의 에러 메시지 복사 루프 조건문에 패킷 경계 검사 로직(buffer_ptr < nx_packet_append_ptr)이 포함되어 있는지 확인합니다.
grep -nE 'nx_tftp_client_error_string|nxd_tftp_client.c' addons/tftp/nxd_tftp_client.c
💻 영향받는 소프트웨어
IBM WebSphere Application Server