aimhubio Aim Unrestricted Code Execution Vulnerability via Outdated safer_getattr() Function
Vulnerability
A vulnerability allowing unrestricted code execution has been identified in aimhubio Aim version 3.22.0. The issue arises in the AimQL query language, which relies on an outdated version of the safer_getattr() function from RestrictedPython. This outdated version fails to properly restrict access to the str.format_map() method, enabling attackers to leak server-side secrets or potentially execute arbitrary code. The vulnerability exists because str.format_map() can read arbitrary attributes from Python objects, allowing access to sensitive variables such as environment variables. If an attacker can write files to a known location on the Aim server, they could use str.format_map() to load a malicious dynamic library into the Python interpreter, leading to unrestricted code execution.
Impact
Exploitation of this vulnerability could result in the leakage of sensitive server-side secrets or unrestricted code execution on the server.
Reproduction
The vulnerability can be reproduced by sending an AimQL query that utilizes the str.format_map() method to access sensitive environment variables. For example, if the Aim server is running with a secret environment variable, a crafted query can be used to leak the variable's value character by character. Once the vulnerability is confirmed, it can be escalated to unrestricted code execution by uploading a malicious dynamic library to the server and using a similar AimQL query to load the library into the Python interpreter.
Vulnerability Rating
Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.
