T09 · Insecure Skill Coding Practices
- Location
scripts/web-access.js:18- Finding
Plaintext API Token Storage in Source Code
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:55-65andscripts/web-access.js:18-21
Vulnerability Type: Plaintext sensitive credential storage
Risk Level: MediumThe installation instructions explicitly direct users to insert a Huawei Cloud bearer token into the JavaScript source file:
javascript // 👇 把你的 TOKEN 填入下面引号中 const TOKEN = '';The corresponding application code defines and subsequently uses that source-level token:
javascript // API 配置 // 🔑 必填:请填入你的华为云 AI 联网增强 Token // 开通指南:https://developer.huawei.com/consumer/cn/doc/AppGallery-connect-Guides/agc-ainetworking-serviceopen-0000002370503878 const API_URL = 'https://connect-api.cloud.huawei.com/api/aiNetworking/v1/webSearch'; const TOKEN = '';Technical Analysis
Although the distributed copy contains an empty value, the documented configuration process requires users to replace it with a live secret. This stores the bearer token as plaintext project content rather than retrieving it from a protected runtime credential source.
Once populated, the secret may be exposed through source-control commits, package publication, project archives, automated backups, shared development directories, code-review systems, or diagnostic bundles. The application then places the value into the HTTP
Authorizationheader:javascript headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${TOKEN}` },A bearer token generally grants its holder the associated API authorization without requiring additional proof of identity. Therefore, disclosure is sufficient for reuse until the token expires or is revoked.
Attack Path
- A user follows
SKILL.mdand inserts a valid Huawei Cloud token intoscripts/web-access.js. - The populated source file is committed, packaged, backed up, shared, or otherwise exposed to an unauthorized party.
- The unauthorized party extracts the plaintext token ...[truncated 879 chars]
- A user follows
- Remediation
View remediation
Remediation Suggestions
-
Remove source-level token configuration and read the credential from a protected environment variable:
javascript const TOKEN = process.env.HUAWEI_AI_NETWORKING_TOKEN; if (!TOKEN) { throw new Error('HUAWEI_AI_NETWORKING_TOKEN is required'); } -
Update
SKILL.mdto instruct users to configure the environment variable or an approved secret manager rather than editing JavaScript source. -
Ensure local environment files containing secrets are excluded from source control, package publication, backups, and diagnostic output.
-
Never print the token or complete authorization header in logs and error messages.
-
Apply least privilege, expiration, usage limits, and rotation controls to the token where supported.
-
Revoke and replace any live token that has previously been committed, packaged, shared, or published. Removing it from the latest revision alone is insufficient because it may remain in repository history or external archives.
-
Add automated secret scanning to source-control and release workflows to prevent future credential disclosure.
-
