반응형
  • Sudo 취약점 CVE-2021-3156 공개 (Baron Samedit)

  • 취약점 이름 : Baron Samedit
  • CVE 번호 : CVE-2021-3156
  • CVSSv3 점수 : 7.8
  • 최약점 공개 : 2021-01-27
  • 취약점 버전 : 1.8.2~1.8.31p2 / 1.9.0~1.9.5p1 
  • 취약점 내용 : Heap-based Buffer Overflow로 인한 권한 상승 (루트 권한 획득)
  • 취약점 패치 방법 : sudo 1.9.5p2 버전으로 업데이트
  • 취약점 시연 영상 : https://vimeo.com/504872555

해당 취약점은 2011년 7월에 도입 되어 2021년 1월에 취약점이 공개 되었습니다. 취약점은 계속 있었으나 약 10년만에 발견되었던 만큼 취약점이 해당하는 버전이 많아 대부분의 시스템이 취약할 것으로 생각됩니다. 

시연 영상을 보시면 아시겠지만 계정 패스워드를 알지 못해도 루트 권한을 획득할 수 있으며, Ubuntu 20.04 (sudo 1.8.31), Debian 10 (Sudo 1.8.27), Fedora 33 (Sudo 1.9.2) 등 여러 배포판 리눅스에서 전체 루트 권한을 획득할 수 있었다고 합니다.

취약점을 발견한 Qualys 연구팀에서는 취약점에 대한 악용 코드를 게시하지 않겠다고 하여 당장 Baron Samedit 취약점에 대해 문제가 발생하지는 않겠지만, 기술적인 내용들을 게시했으므로 추후 악용될 가능성은 충분해 보입니다.

 

  • 1) 취약점 테스트

아래 명령어를 입력하여 취약한지 테스트가 가능 합니다.

sudoedit -s /
  • 취약한 경우 : "sudoedit :" 으로 시작하는 오류 응답
  • 패치된 경우 : "usage :" 으로 시작하는 오류 응답

 

  • 2-1) 임시 패치 방법 (RedHat)

스크립트를 사용해 sudoedit 바이너리의 작동을 중지 시키는 방법이며, 이 방법은 임시로 스크립트를 돌리는 방식이기 때문에 재부팅할 때 마다 적용 시켜주어야 하는 번거로움이 있습니다.

RedHat에서는 아래와 같은 방법을 제공 했는데, 그냥 전체 복사 붙여넣기 해서는 안되니 아래 내용 참고하여 적용 하셔야 합니다.

* 버전 차이(7, 8)에 따라 debuginfo-install 에서 설치받는 패키지가 다르니 참고 해주세요.

* 보안 패치 후 systemtap script를 중지 시키는 라인(맨 마지막)이 있습니다. 

## 1. Install required systemtap packages and dependencies, example: 
yum install systemtap yum-utils kernel-devel-"$(uname -r)"

# Then for RHEL 7 install kernel debuginfo, using:
debuginfo-install -y kernel-"$(uname -r)" 

# Then for RHEL 8 install sudo debuginfo, using:
debuginfo-install sudo


## 2. Create the following systemtap script: (call the file as sudoedit-block.stap)
probe process("/usr/bin/sudo").function("main")  {

        command = cmdline_args(0,0,"");

        if (strpos(command, "edit") >= 0) {

                raise(9);

        }

}


## 3. Install the script using the following command: (using root)
# (This should output the PID number of the systemtap script)
# This script will cause the vulnerable sudoedit command to stop working. The sudo command will still work as usual.
# The above change does not persist across reboots and must be applied after each reboot.
nohup stap -g sudoedit-block.stap &


## 4. Once the new fixed packages are installed, the systemtap script can be removed by killing the systemtap process.  For example, by using:
# Warning: Do not attempt to disable sudoedit by removing the symlink as this is not a sufficient mitigation option.
kill -s SIGTERM 7590 (where 7590 is the PID of the systemtap process)

 


참고자료

blog.qualys.com/vulnerabilities-research/2021/01/26/cve-2021-3156-heap-based-buffer-overflow-in-sudo-baron-samedit

 

CVE-2021-3156: Heap-Based Buffer Overflow in Sudo (Baron Samedit) | Qualys Security Blog

The Qualys Research Team has discovered a heap overflow vulnerability in sudo, a near-ubiquitous utility available on major Unix-like operating systems. Any unprivileged user can gain root privileges…

blog.qualys.com

access.redhat.com/security/cve/CVE-2021-3156

 

Red Hat Customer Portal - Access to 24x7 support and knowledge

 

access.redhat.com

반응형

+ Recent posts