T09 · Insecure Skill Coding Practices
- Location
wechat_search_fixed.py:78- Finding
External subprocesses inherit the complete parent environment
- Content
View full analysis
Vulnerability Details
File Location:
wechat_search.py:84-97,wechat_search_simple.py:71-84,wechat_search_fixed.py:78-92,wechat_search_fixed.py:107-114
Vulnerability Type: Excessive credential and environment exposure to child processes
Risk Level: MediumVulnerable Code
wechat_search.py:84-97:python tavily_key = os.environ.get('TAVILY_API_KEY') if not tavily_key: print("Error: TAVILY_API_KEY environment variable not set", file=sys.stderr) return [] # Construct search query with site restriction search_query = f'{query} site:mp.weixin.qq.com' # Use subprocess to call Tavily Node.js script result = subprocess.run([ 'node', '/root/.openclaw/workspace/skills/tavily-search/scripts/search.mjs', search_query, '-n', str(max_results) ], capture_output=True, text=True, timeout=30, env={**os.environ, 'TAVILY_API_KEY': tavily_key})wechat_search_simple.py:71-84:python tavily_key = os.environ.get('TAVILY_API_KEY') if not tavily_key: print("Error: TAVILY_API_KEY environment variable not set", file=sys.stderr) return [] # Construct search query with site restriction search_query = f'{query} site:mp.weixin.qq.com' # Call Tavily Node.js script result = subprocess.run([ 'node', '/root/.openclaw/workspace/skills/tavily-search/scripts/search.mjs', search_query, '-n', str(max_results) ], capture_output=True, text=True, timeout=30, env={**os.environ, 'TAVILY_API_KEY': tavily_key})wechat_search_fixed.py:78-92:python env = os.environ.copy() if 'TAVILY_API_KEY' not in env: # Try to get from common locations tavily_config_path = os.path.expanduser('~/.openclaw/tavily-config.json') if os.path.exists(tavily_config_path): with open(tavily_config_path, 'r') as f: config = json.load(f) env['TAVILY_API_KEY'] = config.get('api_key', '') result = su ...[truncated 2204 chars]- Remediation
View remediation
Remediation Suggestions
- Construct an explicit allowlisted environment instead of using
os.environ.copy()or{**os.environ, ...}. - Include only variables required to start the child process, such as a controlled
PATH, locale settings, andTAVILY_API_KEY. - Apply the same restricted environment to the
openclawsubprocess. - Resolve executables through trusted absolute paths and verify their ownership and permissions.
- Run network-search helpers under a dedicated low-privilege account or sandbox with restricted filesystem and network access.
- Avoid storing unrelated credentials in the environment of the process hosting third-party Skills.
- Construct an explicit allowlisted environment instead of using
