🇰🇷 한글 설명
datamodel-code-generator 0.11.6부터 0.64.0 버전 사이에서 x-python-import 또는 customTypePath 스키마 확장을 통해 임의의 파이썬 코드를 실행할 수 있는 취약점이 발견되었습니다. 공격자가 제어하는 스키마를 사용하여 임포트 문을 깨뜨리고 악성 코드를 삽입할 수 있으며, 생성된 모델을 임포트할 때 코드가 실행됩니다.
💡 쉬운 설명
데이터 형식을 자동으로 만들어주는 도구가 나쁜 코드가 섞인 데이터를 읽을 때, 공격자가 심어놓은 명령어를 실행해버리는 문제입니다. 이로 인해 컴퓨터가 해커의 명령을 수행하게 될 수 있습니다.
🇺🇸 원문 (English)
datamodel-code-generator generates Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON, YAML, or CSV. From 0.11.6 until 0.64.0, datamodel-code-generator allows attacker-controlled x-python-import or customTypePath schema extensions to reach src/datamodel_code_generator/parser/jsonschema.py and generated import handling through Import.from_full_path and Imports.create_line in src/datamodel_code_generator/imports.py, allowing a newline to break out of an import statement and execute Python code when the generated model is imported. This issue is fixed in version 0.64.0.
📍 영향받는 시스템
datamodel-code-generator 0.11.6 ~ 0.64.0
⚔️ 공격 벡터
조작된 스키마 확장(x-python-import 등)을 포함한 파일을 입력하여 생성된 코드에 악성 파이썬 명령어를 삽입
🛡️ 대응 방법
datamodel-code-generator를 0.64.0 이상의 최신 버전으로 업데이트하십시오.
🔧 검증 코드
출력된 버전이 0.64.0 미만이면 취약한 상태이며, 0.64.0 이상이면 안전합니다.
pip show datamodel-code-generator 2>/dev/null | grep Version