🇰🇷 한글 설명
datamodel-code-generator 0.59.0부터 0.81.0 버전에서 공격자가 제어하는 Protobuf 스키마를 통해 임의의 경로에 파일을 생성하거나 기존 파일을 덮어쓸 수 있는 취약점이 발견되었습니다. 공격자는 WEAK_IMPORT_PATTERN을 악용하여 임시 디렉토리를 벗어나 상위 디렉토리에 접근할 수 있으며, 이는 Protobuf 구문 선언문이 포함된 파일을 생성합니다. 이 문제는 0.81.0 버전에서 수정되었습니다.
💡 쉬운 설명
데이터 모델을 자동으로 만들어주는 프로그램이 나쁜 의도를 가진 파일을 읽을 때, 컴퓨터의 엉뚱한 위치에 파일을 만들거나 기존 파일을 망가뜨릴 수 있는 문제입니다. 해커가 만든 특수한 파일을 프로그램이 처리하게 되면 시스템의 중요한 파일이 바뀔 위험이 있습니다.
🇺🇸 원문 (English)
datamodel-code-generator generates Python data models from schema definitions. From 0.59.0 until 0.81.0, an attacker-controlled Protobuf schema can supply absolute or parent-directory paths captured by WEAK_IMPORT_PATTERN and consumed by _write_missing_weak_imports in src/datamodel_code_generator/parser/protobuf.py. Exploitation requires a victim or automated job to process the attacker-controlled schema with Protobuf input support, which requires the grpcio-tools package. The paths escape the weak_imports temporary directory before protoc runs, allowing creation of directory trees and new files or overwrite of existing writable files with a generated Protobuf syntax declaration. The effect persists when later Protobuf compilation fails. The written content is limited to a proto2 or proto3 syntax declaration, and direct arbitrary code execution has not been demonstrated. This issue is fixed in version 0.81.0.
📍 영향받는 시스템
datamodel-code-generator 0.59.0 ~ 0.81.0 (grpcio-tools 설치 환경)
⚔️ 공격 벡터
공격자가 조작한 Protobuf 스키마를 입력값으로 제공하여 경로 탐색(Path Traversal) 유도
🛡️ 대응 방법
datamodel-code-generator를 0.81.0 이상의 최신 버전으로 업데이트
🔧 검증 코드
출력된 버전이 0.81.0 미만이면 취약한 상태이며, 0.81.0 이상이면 안전합니다.
pip show datamodel-code-generator | grep Version