🇰🇷 한글 설명
ASTEVAL 라이브러리가 FormattedValue AST 노드 처리 시 str.format() 메서드를 위험하게 사용하여, 공격자가 f-string을 통해 임의의 Python 코드를 실행할 수 있습니다. AttributeError 예외를 의도적으로 유발하여 보호된 객체 속성에 접근하는 방식으로 악용됩니다.
💡 쉬운 설명
ASTEVAL 라이브러리가 텍스트 포맷팅을 처리할 때 보안 검증을 제대로 하지 않아, 악의적인 입력으로 숨겨진 코드를 실행할 수 있습니다. 이를 통해 애플리케이션의 민감한 정보나 보호된 데이터에 접근할 수 있습니다.
🇺🇸 원문 (English)
ASTEVAL is an evaluator of Python expressions and statements. Prior to version 1.0.6, if an attacker can control the input to the `asteval` library, they can bypass asteval's restrictions and execute arbitrary Python code in the context of the application using the library. The vulnerability is rooted in how `asteval` performs handling of `FormattedValue` AST nodes. In particular, the `on_formattedvalue` value uses the dangerous format method of the str class. The code allows an attacker to manipulate the value of the string used in the dangerous call `fmt.format(__fstring__=val)`. This vulnerability can be exploited to access protected attributes by intentionally triggering an `AttributeError` exception. The attacker can then catch the exception and use its `obj` attribute to gain arbitrary access to sensitive or protected object properties. Version 1.0.6 fixes this issue.
📍 영향받는 시스템
ASTEVAL 라이브러리 버전 1.0.6 미만
⚔️ 공격 벡터
제어된 f-string 입력으로 format() 메서드를 악용하고, AttributeError 예외를 유발하여 exception 객체의 obj 속성을 통해 보호된 속성 접근
🛡️ 대응 방법
ASTEVAL을 버전 1.0.6 이상으로 업그레이드
🔧 검증 코드
버전이 1.0.6 이상이면 안전, 그 미만이면 취약
pip show asteval | grep Version | awk '{print $2}'