T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/searchPlan.js:10
- Finding
- Access Token Exposure Through Process Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `scripts/searchPlan.js:10-38` **Additional Locations**: `SKILL.md:23,56,95,101,105,131,146,159,184,189,213,219`; `scripts/createBitmapTask.js:29`; `scripts/createDesign.js:26`; `scripts/getBitmapTaskResult.js:27`; `scripts/getCandidateLayout.js:27`; `scripts/getLayoutResult.js:27`; `scripts/getRenderResult.js:31`; `scripts/getStyles.js:29`; `scripts/getTags.js:25`; `scripts/getUploadToken.js:25`; `scripts/triggerLayout.js:50,62`; `scripts/versionCheck.js:27`; `scripts/trigger-render.js:85,103,127` **Vulnerability Type**: Sensitive credential exposure through command-line arguments and query strings **Risk Level**: Medium ### Vulnerable Code ```javascript const args = process.argv.slice(2); let token = ''; let query = ''; let areaId = ''; let start = '0'; let num = '20'; for (let i = 0; i < args.length; i++) { if (args[i] === '--token' && args[i + 1]) token = args[i + 1]; else if (args[i] === '--query' && args[i + 1]) query = args[i + 1]; else if (args[i] === '--areaId' && args[i + 1]) areaId = args[i + 1]; else if (args[i] === '--start' && args[i + 1]) start = args[i + 1]; else if (args[i] === '--num' && args[i + 1]) num = args[i + 1]; } if (!token) { console.error('Error: --token is required'); process.exit(1); } let path = `/oauth2/openapi/ai-design-skill/floorplan/standard/search?access_token=${encodeURIComponent(token)}&start=${start}&num=${num}`; if (query) path += `&query=${encodeURIComponent(query)}`; if (areaId) path += `&area_id=${areaId}`; const options = { hostname: 'oauth.kujiale.com', port: 443, path: path, method: 'GET' }; ``` The Skill documentation instructs the agent to invoke scripts with the access token directly on the command line, for example: ```text node ./scripts/searchPlan.js --token=<token> --query=<community> --areaId=<city-id> --start=0 --num=20 node ./scripts/trigger-render.js --obsDesignId=<designId> --xToken=<token> ``` ### ...[truncated 2483 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Stop accepting access tokens through command-line arguments. 2. Read the token directly from `.kjlconfig.json` inside each script, or pass it through a protected file descriptor or dedicated secret-injection mechanism. 3. If environment variables are used, ensure the execution platform does not expose them through logs, crash reports, or child-process diagnostics. 4. Send credentials in an HTTP authorization header instead of a URL query parameter, where supported: ```javascript const options = { hostname: 'oauth.kujiale.com', port: 443, path: '/oauth2/openapi/ai-design-skill/floorplan/standard/search', method: 'GET', headers: { Authorization: `Bearer ${token}` } }; ``` 5. If the service requires `access_token` as a query parameter, request or implement a server-side API change. Until then, explicitly redact that parameter from logs, errors, tracing data, and telemetry. 6. Never include complete request URLs containing tokens in exceptions. Construct sanitized diagnostic URLs with credential fields replaced by `[REDACTED]`. 7. Protect `.kjlconfig.json` with owner-only filesystem permissions and document token revocation and rotation procedures. 8. Update every affected script consistently rather than fixing only `searchPlan.js`. ]]>
