T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:225- Finding
Authentication Token Transmitted in the Request URL Query String
- Content
View full analysis
Vulnerability Details
File Location:
bin/run.mjs:22-29,bin/run.mjs:70-72, andbin/run.mjs:225-231
Vulnerability Type: Credential exposure through URL query parameters
Risk Level: MediumVulnerable Code
The operation declares the authentication token as a query parameter:
javascript { "defaultValue": null, "description": "Authentication token required for API access.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" },All declared query parameters, including
token, are then appended to the URL:javascript const baseUrl = manifest.baseUrl; const url = new URL(operation.path, ensureBaseUrl(baseUrl)); applyPathParams(operation, params, url); applyQueryParams(operation, params, url);javascript 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); } }Consequently, the effective request has the following form:
text https://api.justoneapi.com/api/twitter/get-user-detail/v1?token=SECRET&restId=USER_IDTechnical Analysis
Sending the token to
api.justoneapi.comis necessary for the declared API functionality. However, placing authentication credentials in the URL exceeds the minimum safe exposure necessary for authentication.HTTPS encrypts the complete URL during transport, so a passive network observer cannot normally read the query string. Nevertheless, URLs are routinely captured by infrastructure outside the immediate application, including:
- Reverse-proxy and API gateway access logs
- Server request logs
- Web application firewalls and monitor ...[truncated 1926 chars]
- Remediation
View remediation
Remediation Suggestions
-
Change the API authentication contract to use an HTTP authorization header, preferably:
javascript const requestInit = { headers: { accept: "application/json", authorization: `Bearer ${token}`, }, method: operation.method, }; -
Remove
tokenfromoperation.parametersand ensure it is never passed toURLSearchParams. -
If JustOneAPI currently requires query-string authentication, coordinate a server-side migration to header-based authentication. Client-only changes must not be made without server support.
-
Until migration is possible:
- Configure gateways, proxies, servers, and tracing systems to redact the
tokenquery parameter. - Disable full-URL logging for this endpoint.
- Use narrowly scoped, short-lived tokens.
- Rotate the token immediately if URLs may already have been logged.
- Configure gateways, proxies, servers, and tracing systems to redact the
-
Add an explicit denylist in
applyQueryParamsso credential-like fields cannot accidentally enter URLs:javascript const sensitiveNames = new Set(["token", "apiKey", "access_token"]); function applyQueryParams(operation, params, url) { for (const parameter of operation.parameters.filter( (item) => item.location === "query" )) { if (sensitiveNames.has(parameter.name)) { throw new Error(`Sensitive parameter cannot be placed in URL: ${parameter.name}`); } const value = params[parameter.name]; if (value !== undefined) { appendValue(url.searchParams, parameter.name, value); } } } -
Add automated tests asserting that serialized request URLs never contain authentication credentials.
-
