CVE-2023-41334

8.4 HIGH

📋 TL;DR

This vulnerability in Astropy allows remote code execution through improper input validation in the TransformGraph().to_dot_graph function. An attacker can inject malicious commands via the savelayout argument, which get executed despite an error being raised. Users of Astropy 5.3.2 are affected.

💻 Affected Systems

Products:
  • Astropy
Versions: 5.3.2
Operating Systems: All platforms running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems using the TransformGraph().to_dot_graph function with user-controlled input to the savelayout parameter.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with attacker gaining remote code execution, potentially leading to data theft, system takeover, or lateral movement.

🟠

Likely Case

Limited code execution in the context of the Astropy application, potentially allowing file system access, data exfiltration, or further exploitation.

🟢

If Mitigated

No impact if the vulnerable function is not called or if input validation prevents exploitation.

🌐 Internet-Facing: MEDIUM
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires the vulnerable function to be called with attacker-controlled input. The advisory provides technical details but no public exploit code.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 5.3.3

Vendor Advisory: https://github.com/astropy/astropy/security/advisories/GHSA-h2x6-5jx5-46hf

Restart Required: No

Instructions:

1. Upgrade Astropy using pip: pip install --upgrade astropy==5.3.3
2. Verify the version: python -c "import astropy; print(astropy.__version__)"
3. Ensure the version shows 5.3.3 or higher.

🔧 Temporary Workarounds

Input Validation

all

Validate and sanitize all user input passed to the savelayout parameter of TransformGraph().to_dot_graph function.

Function Restriction

all

Avoid using TransformGraph().to_dot_graph with untrusted input or disable the function if not needed.

🧯 If You Can't Patch

  • Implement strict input validation for the savelayout parameter to prevent command injection.
  • Restrict access to systems using vulnerable Astropy versions and monitor for suspicious activity.

🔍 How to Verify

Check if Vulnerable:

Check Astropy version: python -c "import astropy; print(astropy.__version__)". If version is 5.3.2, the system is vulnerable.

Check Version:

python -c "import astropy; print(astropy.__version__)"

Verify Fix Applied:

After patching, verify version is 5.3.3 or higher using the same command.

📡 Detection & Monitoring

Log Indicators:

  • Unexpected subprocess executions from Astropy processes
  • Error logs related to TransformGraph().to_dot_graph with unusual arguments

Network Indicators:

  • Outbound connections from Astropy processes to unexpected destinations

SIEM Query:

process_name:"python" AND command_line:"astropy" AND (command_line:"subprocess" OR command_line:"Popen")

🔗 References

📤 Share & Export