T09 · Insecure Skill Coding Practices
- Location
scripts/send_voice.py:31- Finding
Feishu Tenant Access Token Exposed Through Process Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/send_voice.py, lines 31-39
Vulnerability Type: Sensitive credential exposure through subprocess arguments
Risk Level: MediumVulnerable Code
python def upload_file(token, opus_path): # Upload with curl because multipart handling is more complex in pure Python result = subprocess.run([ "curl", "-s", "-X", "POST", f"{FEISHU_API}/im/v1/files", "-H", f"Authorization: Bearer {token}", "-F", "file_type=opus", "-F", "file_name=voice.opus", "-F", f"file=@{opus_path}" ], capture_output=True, text=True)Technical Analysis
The Feishu tenant access token is interpolated directly into the command-line arguments supplied to
curl. Althoughsubprocess.runuses an argument array and does not invoke a shell, the resultingcurlprocess still contains the complete bearer token in its process argument vector.Depending on operating-system process visibility and host configuration, another local user, monitoring agent, diagnostic utility, or compromised process may read the command line through process-listing tools or interfaces such as
/proc/<pid>/cmdline. The exposure lasts for the duration of the upload process.Using an argument array prevents shell command injection, but it does not protect secrets placed in process arguments. Passing the authorization header this way therefore exceeds minimum safe credential-handling requirements.
Attack Path
- An authorized invocation of the Skill reads the Feishu application credentials and obtains a tenant access token.
- The Skill starts
curlwithAuthorization: Bearer <token>in its process arguments. - A local attacker or compromised monitoring process observes running processes while the audio upload is in progress.
- The attacker reads the
curlargument vector and extracts the bearer token. - Before the token expires, the attacker submits requests directly t ...[truncated 703 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the
curlsubprocess with an in-process HTTP implementation supporting multipart uploads, such as a reviewed and pinned Python HTTP client. Set the authorization header in the client request so the token never appears in a child process argument vector. - If
curlmust be retained, provide sensitive headers through a protected temporary configuration file or standard input rather than command-line arguments. Create any temporary file with owner-only permissions and delete it immediately after use. - Avoid printing or logging authorization headers, application secrets, access tokens, or complete request objects.
- Check the subprocess return code before parsing its output and handle malformed or unsuccessful API responses without exposing credentials.
- Grant the Feishu application only the scopes required to upload audio and send messages.
- Rotate or invalidate potentially exposed credentials and tokens if process command lines may have been collected by untrusted monitoring or diagnostic systems.
- Replace the
