Bug 2053192

Summary: azure-cli: az(1) loads code from cwd
Product: [Other] Security Response Reporter: Pedro Sampaio <psampaio>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: mhayden
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-10 17:21:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2053193    
Bug Blocks:    

Description Pedro Sampaio 2022-02-10 16:36:33 UTC
az(1) can't be used securely when the current working directory is 
untrusted (e.g. /tmp), because it loads code from cwd.

References:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1005251

Comment 1 Pedro Sampaio 2022-02-10 16:36:51 UTC
Created azure-cli tracking bugs for this issue:

Affects: fedora-35 [bug 2053193]

Comment 2 Major Hayden 🤠 2022-02-10 16:41:26 UTC
Thanks, Pedro. I'm taking a look to see what we can do.

Comment 3 Major Hayden 🤠 2022-02-10 17:00:38 UTC
As noted in the Debian ticket, writing out an `azure.py` file causes potentially malicious files in the current directory to be imported.

However, by dropping the local directory from `sys.path` and using runpy (as suggested), this appears to work:

```
#!/usr/bin/env python3
import sys
import runpy

# Remove the current working directory from the list of import paths.
sys.path = sys.path[1:]

# Use runpy to run the cli module..
runpy.run_module('azure.cli')
```

Comment 4 Product Security DevOps Team 2022-02-10 17:21:20 UTC
This CVE Bugzilla entry is for community support informational purposes only as it does not affect a package in a commercially supported Red Hat product. Refer to the dependent bugs for status of those individual community products.