
CVE-2026-9999에 대한 개념 증명(PoC) 익스플로잇으로, 서버리스 객체 스토리지 이벤트의 경로 탐색(path traversal)을 시연하여 함수 소스 코드를 덮어쓰고 RCE(원격 코드 실행)를 달성합니다.
객체 스토리지 이벤트를 처리하는 서버리스 플랫폼이 object.key 필드를 검증하지 않아, 공격자가 경로 탐색을 통해 함수의 소스 코드를 덮어쓸 수 있습니다.
심각도: 치명적 (다음 호출 시 RCE)
#!/usr/bin/env python3
"""
vulnerable_serverless.py - Simulated AWS Lambda-like runtime with event injection.
"""
import json, os, shutil, subprocess
from http.server import HTTPServer, BaseHTTPRequestHandler
FUNCTION_DIR = "/tmp/function"
os.makedirs(FUNCTION_DIR, exist_ok=True)
# initial function code
with open(os.path.join(FUNCTION_DIR, "handler.py"), "w") as f:
f.write("""
def handler(event):
return "Hello, " + event.get('name', 'world')
""")
class Handler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
event = json.loads(body)
# Vulnerable: use event['key'] to decide which file to load?
# Simulate: the function source is overwritten by an "update" event from storage.
if event.get('source') == 'storage':
# Path traversal in object key
object_key = event['object']['key'] # attacker controlled
# Overwrite handler.py with the object content (simulated)
dst = os.path.join(FUNCTION_DIR, "handler.py")
# directory traversal to write outside? But we want to overwrite handler.py.
# Attack: object.key = "../../../tmp/function/handler.py"
# Normalize to ensure it's within FUNCTION_DIR? No validation!
# The "get object" would fetch the file; here we just write injected code.
injected_code = event.get('code', '# no code')
# Resolve the full path – this is the vulnerability:
full_path = os.path.normpath(os.path.join(FUNCTION_DIR, object_key))
# Only check if it is under FUNCTION_DIR? Not present.
with open(full_path, 'w') as f:
f.write(injected_code)
self.send_response(200)
self.end_headers()
self.wfile.write(b"Update applied")
else:
# Execute current handler (for demo)
import handler
result = handler.handler(event)
self.send_response(200)
self.end_headers()
self.wfile.write(result.encode())
server = HTTPServer(('0.0.0.0', 8000), Handler)
server.serve_forever()
서버리스 플랫폼의 이벤트 처리 과정에서 발생하는 경로 탐색 취약점으로, 공격자가 함수의 소스 코드를 덮어쓸 수 있으며 이후 호출 시 원격 코드 실행으로 이어집니다.
object.key 필드를 검증 없이 신뢰하여, ../ 시퀀스가 함수 샌드박스 내 임의 경로에 파일을 쓸 수 있게 합니다.python vulnerable_serverless.py
python exploit_event_injection.py