T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:27- Finding
API Token Exposure Through Process Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:40;bin/run.mjs:27-35, 73-85, 142-146, 207-215;generated/operations.json:14-22;generated/operations.md:20
Vulnerability Type: Credential exposure through command-line arguments and URL query strings
Risk Level: MediumVulnerable Code
SKILL.md:40instructs users to supply the token as a command-line argument:bash node {baseDir}/bin/run.mjs --operation "getVideoCommentV2" --token "$JUST_ONE_API_TOKEN" --params-json '{"aid":"<aid>"}'bin/run.mjs:27-35defines the credential as a required query parameter:js { "defaultValue": null, "description": "Access token for the API.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" }bin/run.mjs:73-85adds all query parameters, including the token, to the request URL and transmits it:js const baseUrl = manifest.baseUrl; const url = new URL(operation.path, ensureBaseUrl(baseUrl)); applyPathParams(operation, params, url); applyQueryParams(operation, params, url); const requestInit = { headers: { "accept": "application/json", }, method: operation.method, };bin/run.mjs:142-146accepts the credential through the process argument list:js if (flag === "--token") { parsed.token = value; index += 1; continue; }bin/run.mjs:207-215serializes every query parameter into the URL:js function applyQueryParams(operation, params, url) { for (const parameter of operation.parameters.filter((item) => item.location === "query")) { const value = params[parameter.name]; if (value === undefined) { continue; } appendValue(url.searchParams, parameter.name, value); } }Technical Analysis
Authentication is necessary for the Skill's declared Bilibili comment-retrieval functionality, and the re ...[truncated 2338 chars]
- Remediation
View remediation
Remediation Suggestions
- Read the token directly from
process.env.JUST_ONE_API_TOKENrather than requiring a--tokenargument. Remove or deprecate command-line token handling so the secret is not exposed in process listings. - If supported by JustOneAPI, transmit the credential in an authorization header, such as:
js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; - Remove
tokenfrom the operation's query-parameter definitions and regenerategenerated/operations.jsonandgenerated/operations.mdfrom the corrected API specification. - Ensure application, proxy, gateway, and telemetry logging redacts authorization data and any legacy
tokenquery parameter. - If the backend only supports query-string authentication, use narrowly scoped, short-lived tokens, prohibit URL logging where operationally possible, and explicitly document the remaining credential-disclosure risk.
- Rotate any token suspected of having appeared in process, command, proxy, gateway, or access logs.
- Read the token directly from
