🇰🇷 한글 설명
Linux 커널의 SUNRPC 구성 요소 내 xdr_buf_trim 함수에서 정수 언더플로우 취약점이 발견되었습니다. 특정 조건에서 버퍼 길이를 계산할 때 음수 값이 발생하여 매우 큰 양수로 변환될 수 있으며, 이는 후속 XDR 디코더에 잘못된 스트림 경계를 전달하게 됩니다.
💡 쉬운 설명
데이터를 처리하는 과정에서 계산 실수로 인해 데이터의 크기가 실제보다 훨씬 크게 잘못 인식되는 문제입니다. 이로 인해 공격자가 시스템의 메모리 영역을 넘어서는 데이터를 처리하게 만들어 보안 문제를 일으킬 수 있습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
SUNRPC: xdr_buf_trim: clamp buf->len to avoid underflow
xdr_buf_trim() trims `len` bytes from the tail of an xdr_buf by
walking the tail, pages, and head iovecs. Each per-section step
uses min_t() so it never removes more bytes than that section
holds, but the final accounting at the fix_len label subtracts the
total bytes actually consumed from buf->len without any clamp:
fix_len:
buf->len -= (len - trim);
When the caller has set buf->len to a value smaller than the sum
of the iov_lens, (len - trim) can exceed buf->len and the unsigned
subtraction wraps to near UINT_MAX. gss_krb5_unwrap_v2() reaches
xdr_buf_trim() in exactly that state:
buf->head[0].iov_len -= GSS_KRB5_TOK_HDR_LEN + headskip;
buf->len = len - (GSS_KRB5_TOK_HDR_LEN + headskip);
xdr_buf_trim(buf, ec + GSS_KRB5_TOK_HDR_LEN + tailskip);
buf->len is a small wire-derived value while the iov_lens are at
page scale, so the per-section loops legitimately consume far more
bytes than buf->len records. The wrapped buf->len then propagates
as the authoritative stream bound into every downstream XDR
decoder.
Fix by clamping the decrement so buf->len bottoms out at zero:
buf->len -= min_t(unsigned int, buf->len, len - trim);
On the normal path where the iov_lens sum to buf->len, (len - trim)
is always <= buf->len and the result is identical to before. No
callers change behavior outside the underflow case.
📍 영향받는 시스템
SUNRPC를 사용하는 Linux 커널 버전 (GSS-KRB5 관련 기능 포함)
⚔️ 공격 벡터
조작된 네트워크 패킷을 전송하여 SUNRPC의 xdr_buf_trim 함수에서 정수 언더플로우를 유도
🛡️ 대응 방법
커널 패치를 적용하여 xdr_buf_trim 함수 내의 길이를 계산할 때 min_t를 사용하여 언더플로우를 방지하도록 업데이트
🔧 검증 코드
현재 실행 중인 커널 버전을 확인하여 취약점이 해결된 최신 패치 버전인지 확인합니다.