🇰🇷 한글 설명
Linux kernel의 ksmbd SMB 서버에서 복합 요청(QUERY_DIRECTORY + QUERY_INFO) 처리 시 OutputBufferLength 검증이 누락되어 있습니다. 파일명을 smb2_file_all_info 구조체에 복사하는 과정에서 버퍼 크기를 초과하여 smbConvertToUTF16() 호출 시 메모리 손상이 발생할 수 있습니다.
💡 쉬운 설명
Linux 파일 공유 서비스(SMB)에서 특정 크기의 파일명을 처리할 때 메모리 경계를 넘어 쓰기가 발생하는 문제입니다. 공격자가 조작된 요청으로 서버의 메모리를 손상시킬 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: fix potencial OOB in get_file_all_info() for compound requests
When a compound request consists of QUERY_DIRECTORY + QUERY_INFO
(FILE_ALL_INFORMATION) and the first command consumes nearly the entire
max_trans_size, get_file_all_info() would blindly call smbConvertToUTF16()
with PATH_MAX, causing out-of-bounds write beyond the response buffer.
In get_file_all_info(), there was a missing validation check for
the client-provided OutputBufferLength before copying the filename into
FileName field of the smb2_file_all_info structure.
If the filename length exceeds the available buffer space, it could lead to
potential buffer overflows or memory corruption during smbConvertToUTF16
conversion. This calculating the actual free buffer size using
smb2_calc_max_out_buf_len() and returning -EINVAL if the buffer is
insufficient and updating smbConvertToUTF16 to use the actual filename
length (clamped by PATH_MAX) to ensure a safe copy operation.
📍 영향받는 시스템
ksmbd가 활성화된 Linux 커널 5.15 이상의 모든 시스템 (NAS, 파일 서버, Samba4 대체 구성)
⚔️ 공격 벡터
SMB 클라이언트가 복합 명령으로 응답 버퍼를 거의 소진한 후 파일명 길이를 초과하도록 QUERY_INFO 요청을 전송
🛡️ 대응 방법
Linux kernel을 패치된 버전으로 업데이트하여 smb2_calc_max_out_buf_len() 검증 로직 적용
🔧 검증 코드
ksmbd가 출력되면 SMB 서버가 활성화된 상태이며, 커널 버전이 5.15 이상이면서 보안 패치가 미적용된 경우 취약함
lsmod 2>/dev/null | grep -q ksmbd && (uname -r | grep -qE '[0-9]\.[0-9]+' && echo 'ksmbd active, check kernel version' || echo 'kernel version check failed') || echo 'ksmbd not loaded'