T09 ยท Insecure Skill Coding Practices
- Location
logger.js:84- Finding
Generated Logging Exposes Unredacted Function Arguments and Stack Traces
- Content
View full analysis
Vulnerability Details
File Location:
logger.js, lines 84-108
Vulnerability Type: Sensitive data exposure through unsafe generated logging
Risk Level: MediumVulnerable Code
javascript generateLogging(fn) { const { name, body } = fn; return `async function ${name}(...args) { logger.info('${name} started', { args }); const startTime = Date.now(); try { ${body.trim().split('\n').map(line => ' ' + line).join('\n')} const duration = Date.now() - startTime; logger.info('${name} completed', { args, duration }); } catch (error) { const duration = Date.now() - startTime; logger.error('${name} failed', { args, duration, error: error.message, stack: error.stack }); throw error; } }`; }Technical Analysis
The generated instrumentation logs the complete
argsarray when a function starts, completes, or fails. No allowlist, type restriction, field filtering, or secret redaction is applied.Function arguments can contain passwords, API keys, authorization tokens, session cookies, payment information, personal data, request headers, request bodies, or entire application objects. Logging
error.stackcan additionally disclose internal filesystem paths and implementation details.This behavior violates data-minimization principles and contradicts the guidance in
SKILL.mdstating that passwords and tokens must not be logged. Although the project itself does not implement a network transport, generated code can pass this information to an application's existing logger. Such loggers commonly persist data to files or forward it to external aggregation services.Attack Path
- A user asks the Skill to add logging to an authentication, payment, account-management, or API-processing function.
generateLogging()wraps the target function and inserts logging calls containing the completeargsarray.- The instrumen ...[truncated 1274 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove complete argument logging. Do not emit
{ args }by default. - Generate logs from an explicit allowlist of safe operational metadata, such as operation name, duration, result status, and non-sensitive identifiers.
- Implement recursive redaction for fields commonly containing secrets, including
password,secret,token,authorization,cookie,apiKey,accessToken,refreshToken, and payment-related fields. - Exclude request headers, request bodies, credentials, buffers, and arbitrary nested objects unless the user explicitly selects safe fields.
- Make stack-trace logging configurable and disable it in externally visible or production logs unless operationally required.
- Apply length and depth limits to logged values to reduce accidental disclosure and excessive log volume.
- Document that downstream logger transports may persist or transmit data and require users to review retention, access controls, and external aggregation settings.
- Add automated tests that pass representative passwords, tokens, cookies, and nested secrets through generated instrumentation and verify that none appear in output.
- Remove complete argument logging. Do not emit
