T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:386
- Finding
- API Token Exposed Through Command-Line Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:43`; `bin/run.mjs:386-403, 432-442, 476-483` **Vulnerability Type**: Credential exposure through process arguments and URL query strings **Risk Level**: Medium ### Vulnerable Code `SKILL.md:43`: ```bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` `bin/run.mjs:386-403`: ```js function parseArgs(argv) { const parsed = { operation: null, paramsJson: "{}", token: null }; for (let index = 0; index < argv.length; index += 1) { const flag = argv[index]; const value = argv[index + 1]; if (flag === "--operation") { parsed.operation = value; index += 1; continue; } if (flag === "--params-json") { parsed.paramsJson = value; index += 1; continue; } if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` `bin/run.mjs:432-442`: ```js function injectToken(operation, params, cliToken) { const tokenParam = operation.parameters.find((parameter) => parameter.name === "token"); if (!tokenParam || params.token !== undefined) { return; } if (!cliToken) { fail("--token is required for this operation.", { operationId: operation.operationId, }); } params.token = cliToken; } ``` `bin/run.mjs:476-483`: ```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 The documented invocation expands `JUST_ONE_API_TOKEN` into the process command line. Depending on operating-system controls and the surrounding execution environment, command-line arguments may be visible through process inspection, shell tracing, job telemetry, audit s ...[truncated 2335 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Remove command-line token handling** - Read `JUST_ONE_API_TOKEN` directly from `process.env`. - Remove the `--token` option from `parseArgs`. - Fail safely when the environment variable is absent without printing its value. 2. **Move authentication out of the URL** - Prefer an HTTP authorization header, such as: ```js requestInit.headers.authorization = `Bearer ${token}`; ``` - Use the exact authentication scheme supported by JustOneAPI. - Remove `token` from query-parameter serialization when header-based authentication is available. 3. **If query authentication is mandated by the upstream API** - Document that the upstream protocol requires a query credential. - Ensure reverse proxies, API gateways, tracing systems, and access logs redact the `token` parameter. - Disable URL capture in local debugging and monitoring tools where practical. - Apply short token lifetimes, narrow scopes, usage limits, and routine rotation. 4. **Prevent accidental disclosure** - Add a centralized redaction function for `token`, `authorization`, and similar fields before emitting errors or telemetry. - Never include the constructed request URL in errors unless sensitive query parameters have first been removed. - Add automated tests confirming that credentials do not appear in process invocation examples, standard output, standard error, or diagnostic records. 5. **Update the documented invocation** - Replace the current command with: ```bash JUST_ONE_API_TOKEN="..." node {baseDir}/bin/run.mjs \ --operation "<operation-id>" \ --params-json '{"key":"value"}' ``` - Prefer configuring the environment outside interactive shell history, such as through a protected secret manager or execution environment. ]]>
