T09 · Insecure Skill Coding Practices
- Location
scripts/copy-generator.py:22- Finding
Hardcoded GLM API Credential Used as a Default
- Content
View full analysis
Vulnerability Details
File Location:
scripts/copy-generator.py:22-23, with credential use atscripts/copy-generator.py:73-78
Vulnerability Type: Hardcoded API credential
Risk Level: HighVulnerable Code
python GLM_API_KEY = os.getenv('GLM_API_KEY', 'sk-JSJg7OYHJZPOn87CpHq0d5VMGLkTCBdJcVxUOdUp06IpUABx') GLM_API_URL = 'https://open.bigmodel.cn/api/paas/v4/chat/completions'The embedded value is subsequently placed in the authorization header:
python response = requests.post( GLM_API_URL, headers={ 'Authorization': f'Bearer {GLM_API_KEY}', 'Content-Type': 'application/json' },Technical Analysis
The application embeds a credential-shaped GLM API key as the default value used when the
GLM_API_KEYenvironment variable is absent. Consequently, every copy of the package exposes the same credential to anyone able to read the source code.The audit could not independently confirm whether the key remains active. Nevertheless, embedding and automatically using a bearer credential is an insecure coding practice. Source packages, repositories, build artifacts, logs, and backups are not appropriate secret-storage mechanisms.
The fallback also prevents the application from failing securely when configuration is missing. Instead of stopping and asking the user to provide their own credential, it silently uses the embedded credential.
Attack Path
- An attacker downloads or otherwise obtains the publicly distributed Skill package.
- The attacker reads
scripts/copy-generator.py. - The attacker extracts the hardcoded bearer token from line 22.
- If the token is active, the attacker submits arbitrary requests directly to the GLM API.
- Those requests consume the credential owner's quota and may incur charges or trigger account-level rate limits.
- Revocation of the shared credential can then disrupt every deployment relying on the fallb ...[truncated 525 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the hardcoded fallback entirely:
python GLM_API_KEY = os.getenv("GLM_API_KEY") if not GLM_API_KEY: raise RuntimeError("GLM_API_KEY must be configured") -
Immediately revoke and rotate the exposed credential if it is or was active.
-
Require every deployment to use a separately provisioned credential with the minimum necessary API permissions and quota.
-
Store credentials in environment variables or a supported secret manager rather than source files.
-
Add automated secret scanning to source-control and publishing workflows.
-
Review repository history and previously published artifacts because removing the value from the current file does not remove earlier copies.
-
Configure usage alerts, rate limits, and billing limits for API credentials.
-
