🇰🇷 한글 설명
Linux 커널의 NFSD에서 inode 락을 획득하기 전에 파일 크기를 확인하는 과정에서 TOCTOU(Time-of-Check to Time-of-Use) 취약점이 발생합니다. 이로 인해 추가 전용(append-only) 파일에 대해 권한 검사를 우회하여 파일 크기를 강제로 줄이는 트런케이션(truncation)이 가능해질 수 있습니다.
💡 쉬운 설명
파일을 수정할 수 없는 '추가 전용' 파일임에도 불구하고, 시스템이 권한을 확인하는 찰나의 순간을 이용해 파일 내용을 강제로 삭제하거나 크기를 줄일 수 있는 보안 결함입니다. 공격자는 이 허점을 이용해 데이터 무결성을 해칠 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
NFSD: check truncate permission under inode lock
nfsd_setattr() checks whether a size update needs NFSD_MAY_TRUNC
before it takes inode_lock(). The comparison uses the file size sampled
by that unlocked read, but the actual ATTR_SIZE update is applied later
under inode_lock() by notify_change().
This leaves a TOCTOU window for append-only files. If a client sends a
SETATTR that does not shrink the file at the time of the unlocked
sample, a concurrent append can extend the file before nfsd_setattr()
takes inode_lock(). notify_change() then applies a real truncation
without the NFSD_MAY_TRUNC check that rejects IS_APPEND(inode). The VFS
truncate syscall paths perform their own append-only checks before
calling notify_change(), so NFSD must make this decision against the
locked size it is about to change.
Split the write-count acquisition from the truncation permission check.
Keep get_write_access() before the locked setattr work, then recheck
whether the requested size is below i_size_read(inode) after inode_lock()
has been acquired and before notify_change(ATTR_SIZE). This also avoids
the plain unlocked inode->i_size load.
📍 영향받는 시스템
Linux Kernel (NFSD 기능이 활성화된 버전)
⚔️ 공격 벡터
SETATTR 요청과 파일 추가(append) 작업을 동시에 수행하여 권한 검사와 실제 적용 사이의 시간차(TOCTOU)를 이용한 공격
🛡️ 대응 방법
Linux 커널을 최신 보안 패치가 적용된 버전으로 업데이트하여 inode 락 획득 후 크기를 재검증하도록 수정해야 합니다.
🔧 검증 코드
출력된 커널 버전이 해당 취약점이 해결된 패치 버전 이상인지 확인합니다.