T09 · Insecure Skill Coding Practices
- Location
index.js:20- Finding
Potential API Credential Disclosure Through Unsanitized Axios Error Logging
- Content
View full analysis
Vulnerability Details
File Location:
index.js, lines 20-30
Vulnerability Type: Sensitive credential exposure through verbose error logging
Risk Level: HighVulnerable Code
js headers: { 'Authorization': `Bearer ${apiKey}`, }, } ); const audioData = response.data.audio; fs.writeFileSync(outputFile, Buffer.from(audioData, 'base64')); console.log(`TTS generated and saved to ${outputFile}`); } catch (error) { console.error('Error generating TTS:', error);Technical Analysis
The application includes the TogetherAI API key in an Axios request's
Authorizationheader and logs the complete error object if the request fails. Axios error objects can retain request configuration and header information. Depending on the Axios and Node.js serialization behavior, the logged object may therefore include the bearer token.The risk applies to terminal output, process logs, CI/CD logs, agent execution transcripts, and centralized logging systems. Logging only a sanitized error message would be sufficient for routine diagnostics.
Attack Path
- An attacker or unreliable network condition causes the TogetherAI request to fail, such as through an invalid request, rejected credentials, connection failure, or non-success response.
- Axios constructs an error object that can contain the original request configuration.
- The request configuration contains
Authorization: Bearer <TOGETHERAI_API_KEY>. - The catch block passes the complete object to
console.error. - Anyone with access to the resulting terminal, execution transcript, or collected logs may recover the API credential.
- The exposed credential may then be used directly against the TogetherAI API.
Impact Assessment
Successful exploitation can disclose the configured TogetherAI API key. An attacker could make unauthorized API requests with the permissions and usage quota asso ...[truncated 343 chars]
- Remediation
View remediation
Remediation Suggestions
-
Never log the complete Axios error object when authenticated requests are involved.
-
Log only explicitly selected, non-sensitive fields, such as the error message and HTTP status:
js } catch (error) { const status = error.response?.status; console.error('Error generating TTS:', { message: error.message, status, }); } -
Add a centralized redaction function that removes
authorization,cookie, API-key, and token fields before structured objects are logged. -
Ensure production logging and monitoring systems apply an additional credential-redaction layer.
-
Rotate the TogetherAI API key if existing logs may contain prior request errors.
-
Use a narrowly scoped API credential and configure usage limits where the provider supports them.
-
