T09 · Insecure Skill Coding Practices
- Location
modules/recovery-strategies.md:103- Finding
Unredacted Error Context Logging and Alert Forwarding
- Content
View full analysis
Vulnerability Details
File Location:
modules/recovery-strategies.md, lines 103–121
Vulnerability Type: Sensitive data exposure through unrestricted logging and alert forwarding
Risk Level: MediumVulnerable Code
python def log_error_with_context(error: LeylineError, context: dict): """Log error with full context for debugging.""" log_entry = { "timestamp": datetime.utcnow().isoformat(), "error_type": type(error).__name__, "category": error.category.value, "message": str(error), "recoverable": error.category in [ ErrorCategory.TRANSIENT, ErrorCategory.RESOURCE ], "context": context } logger.error(json.dumps(log_entry)) # Alert on critical errors if error.category == ErrorCategory.PERMANENT: send_alert(log_entry)Technical Analysis
The documented error-handling pattern serializes the complete caller-supplied
contextobject and exception message without applying field allowlisting, recursive redaction, size limits, or sensitivity classification. Error context can contain authorization headers, API tokens, cookies, prompts, request bodies, personal information, service configuration, or internal identifiers.The resulting record is written to the configured logger. For permanent errors, the same unsanitized record is also passed to the unspecified
send_alertfunction. Alerting integrations commonly transmit records to third-party monitoring or messaging systems, expanding the number of systems and users able to access the data.This project contains documentation and illustrative snippets rather than an executable implementation. Therefore, the finding affects implementations that adopt this pattern. The audit does not establish a specific external destination or confirmed network exfiltration.
Attack Path
- An attacker supplies crafted input that is retained in the operation's context or causes sensitive ...[truncated 1241 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace unrestricted context logging with an explicit allowlist of operational fields, such as request ID, service name, error category, and non-sensitive status codes.
- Recursively redact sensitive keys, including
authorization,cookie,token,api_key,password,secret,credential,prompt,payload, and request-body fields. - Sanitize exception messages because upstream libraries may embed URLs, headers, request fragments, or credentials in exception text.
- Apply length and nesting limits before serialization to reduce accidental data exposure and log-forging or resource-exhaustion risks.
- Send alerts only a minimal summary and an opaque incident identifier. Keep detailed diagnostics in a separately protected system when necessary.
- Require encrypted transport, strict access controls, short retention periods, and audit logging for both log storage and alert destinations.
- Add automated tests using representative secrets to verify that sensitive values never appear in generated logs or alerts.
- Document the destination and security assumptions of
send_alertand prohibit forwarding raw caller-controlled context.
