🇰🇷 한글 설명
Linux 커널의 Smack 보안 모듈에서 smack_msg_queue_msgrcv 함수가 권한 확인 시 대상(target) 작업이 아닌 현재(current) 작업의 권한을 잘못 검사하는 취약점이 발견되었습니다. 이로 인해 메시지 수신 권한이 없는 작업이 MAC(강제 접근 제어) 정책을 우회하여 메시지를 가로챌 수 있습니다.
💡 쉬운 설명
메시지를 받는 사람이 누구인지 확인해야 하는데, 메시지를 보내는 사람의 신분증만 확인하는 오류가 있었습니다. 이 때문에 권한이 없는 사람도 몰래 메시지를 받아갈 수 있는 보안 구멍이 생겼습니다.
🇺🇸 원문 (English)
In the Linux kernel, the following vulnerability has been resolved:
smack: fix incorrect task context in smack_msg_queue_msgrcv
The smack_msg_queue_msgrcv() function incorrectly checks
the permissions of the 'current' task instead of the
'target' task.
In the msgsnd() syscall path, if a receiver is already waiting,
the pipelined_send() optimization is used to push the message
directly to the receiver task:
ipc/msg.c`pipelined_send():
` smp_store_release(&msr->r_msg, msg)
In this case, the 'sender' (current) task performs the check
on behalf of the 'receiver' task (msr->r_tsk, passed as the
'target' parameter):
ipc/msg.c`pipelined_send():
` security_msg_queue_msgrcv(,, target := msr->r_tsk,,)
However, smack_msg_queue_msgrcv() ignores the 'target' and
checks 'current':
smack_msg_queue_msgrcv(…)
` smk_curacc_msq(isp, MAY_READWRITE); // current task
'current' MAY satisfy smack_msg_queue_msgrcv r/w requirement,
but 'target' (the receiver task) might NOT;
as a result, an unauthorized receiver gets the message,
violating MAC policy.
Test:
1) create a sysv message queue with label “foo”
2) echo "bar foo r" >/smack/load2
3) msgrcv(,,,0,MSG_NOERROR) in "bar"-labeled task.
The task is waiting for the messages ...
4) msgsnd() from a "foo"-labeled task:
"bar"-labeled task gets the message.
This patch fixes the issue by checking permission on the
'target' task instead of 'current'.
(2008-02-04, Casey Schaufler)
📍 영향받는 시스템
Linux Kernel (Smack 보안 모듈이 활성화된 시스템)
⚔️ 공격 벡터
권한이 없는 프로세스가 메시지 큐에서 대기 중인 상태에서, 권한이 있는 프로세스가 메시지를 보낼 때 발생하는 최적화 경로를 이용해 메시지를 탈취
🛡️ 대응 방법
Smack 모듈의 smack_msg_queue_msgrcv 함수가 'current' 대신 'target' 작업의 권한을 확인하도록 커널 패치 적용
🔧 검증 코드
커널 버전과 Smack 설정 활성화 여부를 확인하여 해당 보안 모듈의 적용 상태를 파악합니다.
uname -a && grep -i smack /boot/config-$(uname -r) 2>/dev/null