🇰🇷 한글 설명
Linux 커널의 NFSv2 구현에서 SETATTR/CREATE 요청 시 허용 범위를 초과하는 useconds 값을 처리할 때 정수 오버플로가 발생할 수 있는 취약점입니다. ILP32 아키텍처에서 잘못된 값이 나노초로 변환되는 과정에서 데이터 오염이 발생하며, 이는 파일 시스템의 시간 정보가 잘못 기록되는 결과를 초래할 수 있습니다.
💡 쉬운 설명
NFS 서버가 잘못된 시간 값을 받았을 때 이를 제대로 걸러내지 못해 시스템 내부 데이터가 꼬일 수 있는 문제입니다. 공격자가 조작된 시간 값을 보내면 파일의 생성/수정 시간이 비정상적으로 설정될 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
nfsd: reject out-of-range useconds in NFSv2 SETATTR/CREATE
The NFSv2 sattr decoder converts the wire useconds to nanoseconds in
svcxdr_decode_sattr():
iap->ia_atime.tv_nsec = tmp2 * NSEC_PER_USEC;
tmp2 is a u32 and NSEC_PER_USEC is 1000, so the product is computed in
unsigned long. On ILP32 that is 32 bits, and an out-of-range useconds
value such as 4294968 wraps to tv_nsec == 704. The corruption therefore
happens during decode, before any proc function can inspect the value,
and a later range check on tv_nsec would see an in-range result and
accept it. Rejecting in the decoder yields an RPC GARBAGE_ARGS reply.
NFSv2 defines no NFSERR_INVAL, so there is no NFS-level status to return
for a malformed time argument, and the check cannot move to the proc
function the way the v3/v4 nsec range checks do.
Guard the raw useconds before the multiplication and reject values
greater than 1000000. useconds == 1000000 is kept: it is the Sun
convention for "set to the current server time", and the in-tree Linux
NFSv2 client emits it in both the atime and the mtime field for a plain
touch / utimes(file, NULL) (see encode_sattr() and
xdr_encode_current_server_time() in fs/nfs/nfs2xdr.c). Rejecting 1000000
would turn that common operation into a hard decode failure for both
SETATTR and CREATE. 1000000 * NSEC_PER_USEC is 10^9, which does not wrap
on ILP32, so the Sun convention value passes through safely. Only
genuinely out-of-range values (> 1000000) are rejected. The atime and
mtime guards are therefore symmetric.
The decoder only applied the Sun convention in the mtime block, which
clears ATTR_ATIME_SET|ATTR_MTIME_SET when mtime useconds == 1000000. If a
client puts 1000000 in the atime field but not in the mtime field, the
atime block stored an out-of-range tv_nsec (10^9) and left ATTR_ATIME_SET
set, so the bogus value reached the filesystem. Apply the convention in
the atime block as well, clearing ATTR_ATIME_SET so the server uses its
current time and ignores the value. Only ATTR_ATIME_SET is cleared there.
The mtime block keeps its existing behavior, where 1000000 means "set
both atime and mtime to now".
[ cel: various tweaks, addenda, and clean-ups ]
📍 영향받는 시스템
NFSv2를 사용하는 Linux 커널 (특히 ILP32 아키텍처 환경)
⚔️ 공격 벡터
NFSv2 프로토콜을 통해 조작된 useconds 값을 포함한 SETATTR 또는 CREATE RPC 요청 전송
🛡️ 대응 방법
NFSv2 디코더에서 1,000,000을 초과하는 useconds 값을 거부하도록 커널 패치 적용
🔧 검증 코드
현재 커널 버전과 NFS 지원 여부를 확인하고, 최신 보안 패치가 적용된 커널 버전인지 확인합니다.
uname -a && grep -i 'NFS' /proc/filesystems