T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:249
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:34-36`; `bin/run.mjs:111-120`; `bin/run.mjs:249-257` **Vulnerability Type**: Credential exposure through command-line arguments and URL query parameters **Risk Level**: Medium ### Vulnerable Code The documented invocation expands the API token directly into the process command line: ```bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` The executable injects that token into the request parameters: ```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; } ``` All parameters declared as query parameters, including `token`, are then appended to the request 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); } } ``` The resulting request is sent using the URL containing the credential: ```js 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, }; response = await fetch(url, requestInit); ``` ### Technical Analysis The API token is exposed at two separate layers: 1. The shell expands `$JUST_ONE_API_TOKEN` into the Node.js process argument list. Depending on operating-system permissions and process isolation, other local users, process-monitoring agents, diagnosti ...[truncated 2221 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Read the token directly from the environment** - Replace the `--token` argument with `process.env.JUST_ONE_API_TOKEN`. - Remove or reject token values supplied through `--params-json` so callers cannot accidentally place credentials in ordinary request parameters. 2. **Use an authentication header** - If supported by JustOneAPI, transmit the credential using an authorization header, for example: ```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}`, }, }; ``` 3. **Remove the token from query-parameter definitions** - Treat authentication separately from operation-specific parameters. - Ensure `applyQueryParams` cannot append `token`, `apiKey`, or other credential fields to URLs. 4. **Update the documentation** - Replace the current command with: ```bash JUST_ONE_API_TOKEN="..." node {baseDir}/bin/run.mjs \ --operation "<operation-id>" \ --params-json '{"key":"value"}' ``` - Prefer setting the environment variable through a protected secret manager rather than inline shell assignment where shell history or job configuration could retain it. 5. **Apply defense-in-depth controls** - Redact credential-like fields from errors, traces, and logs. - Use short-lived, revocable, and narrowly scoped tokens. - Rotate the existing token if it may already have appeared in process telemetry or URL logs. - Configure API gateways and observability systems to suppress or redact sensitive query parameters if query-based authentication cannot be immediately removed. ]]>
