T09 · Insecure Skill Coding Practices
- Location
src/utils/request.js:69- Finding
API Credential Transmitted in URL Query Strings
- Content
View full analysis
Vulnerability Details
File Location:
src/utils/request.js:69-98, 101-119; credential-bearing parameters originate fromsrc/api/search.js:24-28, 48-58,src/api/detail.js:23-27, 46-54,src/api/comment.js:23-27, 45-52, andsrc/api/post.js:23-27, 45-52
Vulnerability Type: API credential exposure through URL query parameters
Risk Level: MediumVulnerable Code
The shared request functions serialize all parameters, including the API token, into the request URL:
js async function postJson(path, params, data) { if (!path || typeof path !== "string") { throw new Error("path must be a non-empty string"); } if (!params || typeof params !== "object") { throw new Error("params must be an object"); } if (!data || typeof data !== "object") { throw new Error("data must be an object"); } params.skill_name = skillName(); const fullPath = `${path}?${querystring.stringify(params)}`; const jsonData = JSON.stringify(data); const options = { host: constants.BASE_URL, path: fullPath, method: "POST", headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(jsonData), }, }; return await request(options, jsonData); } async function getJson(path, params) { if (!path || typeof path !== "string") { throw new Error("path must be a non-empty string"); } if (!params || typeof params !== "object") { throw new Error("params must be an object"); } params._ = Date.now(); const fullPath = `${path}?${querystring.stringify(params)}`; const options = { host: constants.BASE_URL, path: fullPath, method: "GET", headers: { "Content-Type": "application/json", }, }; return await request(options); }API workflows explicitly place the token into these parameter objects. For example:
js return await postJson( "/api ...[truncated 2215 chars]- Remediation
View remediation
Remediation Suggestions
-
Remove
tokenfrom all query-parameter objects. -
Transmit the credential in an HTTP authorization header, such as:
js headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json", } -
Refactor
postJsonandgetJsonso authentication is accepted separately from ordinary request parameters. -
Configure reverse proxies, API gateways, tracing systems, and application logs to redact authorization data and sensitive query parameters.
-
Avoid printing authentication material in errors or debug output.
-
Rotate tokens that may already have been retained in request logs.
-
Apply short expiration periods, per-token rate limits, and least-privilege API scopes where supported.
-
