T09 · Insecure Skill Coding Practices
- Location
scripts/wechat_gzh.py:543- Finding
AppSecret Exposure Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/wechat_gzh.py:543
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: Mediumpython parser.add_argument('--secret', help='AppSecret(覆盖配置文件)')Technical Analysis
The CLI accepts the reusable WeChat AppSecret directly through the
--secretargument. Command-line arguments may be retained in shell history, captured in CI/CD job definitions and logs, or exposed to local process-inspection facilities, depending on the operating system and its access controls.Unlike a short-lived token, the AppSecret is a long-term application credential. An exposed AppSecret can be combined with the corresponding AppID to request new access tokens repeatedly until the credential is rotated.
Attack Path
- A user runs the client with
--secret APP_SECRET, potentially from an interactive shell or automation system. - The full command is retained in shell history, process telemetry, CI configuration, or execution logs.
- An attacker with access to one of those records obtains the AppSecret and corresponding AppID.
- The attacker submits those credentials to the official WeChat stable-token endpoint.
- After receiving an access token, the attacker invokes the WeChat APIs permitted for that Official Account.
Impact Assessment
Successful exploitation may allow an attacker to obtain account access tokens and exercise the WeChat API privileges granted to the application. Based on this skill's supported operations, relevant effects may include reading materials and publication data, uploading materials, publishing drafts, and deleting published articles. The exact scope remains constrained by the permissions and account type configured by WeChat.
- A user runs the client with
- Remediation
View remediation
Remediation Suggestions
- Remove the
--secretcommand-line option. - Load the AppSecret from a permission-restricted configuration file, operating-system credential store, or dedicated secret manager.
- If interactive entry is necessary, read the secret with
getpass.getpass()so it is neither echoed nor supplied through the process argument vector. - Ensure configuration files containing credentials are restricted to the owning user, such as mode
0600on supported systems. - Prevent secret values from being included in application logs, exception messages, telemetry, or CI job output.
- Rotate any AppSecret that has previously been supplied through command-line arguments in an environment where command history or execution logs may be accessible.
- Remove the
