Back to skill

Security audit

golang-samber-slog

Security checks for vulnerabilities and agentic risk

Overview

This Go logging skill is coherent, but its examples may lead agents to log sensitive HTTP request data to shared or third-party logging systems without clear safeguards.

Review this skill before installing if it may be used on production web services. Keep request and response body logging disabled by default, avoid logging Authorization/Cookie headers or client identifiers unless necessary, add redaction before any remote sink, and restrict any raw payload logging to explicitly approved non-sensitive endpoints with short retention.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
references/http-middlewares.md:44
Finding
Request-body logging example can disclose credentials and personal data to downstream log sinks## Vulnerability Details **File Location**: `references/http-middlewares.md`, lines 44-54 **Vulnerability Type**: Sensitive data exposure through unsafe logging guidance **Risk Level**: Medium ### Vulnerable Code ```go // With config router.Use(sloggin.NewWithConfig(logger, sloggin.Config{ DefaultLevel: slog.LevelInfo, ClientErrorLevel: slog.LevelWarn, ServerErrorLevel: slog.LevelError, WithRequestBody: true, WithUserAgent: true, Filters: []sloggin.Filter{ sloggin.IgnorePath("/health", "/metrics"), sloggin.IgnorePathPrefix("/static"), }, })) ``` The same unsafe `WithRequestBody: true` pattern is repeated for Echo, Fiber, and Chi in this file. `SKILL.md` also presents request-body logging as an ordinary middleware configuration option without requiring endpoint filtering or content redaction. ### Technical Analysis Enabling `WithRequestBody` causes request payloads to become log attributes. Request bodies commonly contain passwords, session tokens, API keys, payment information, identity data, and other regulated personal information. The documented 64 KB maximum only limits volume; it does not provide confidentiality or remove secrets. This Skill is specifically designed to route records to remote backends such as Sentry, Loki, Datadog, Slack, webhooks, Kafka, and cloud object storage. Consequently, following this example can cause request secrets to cross the process and trust boundary and be retained by third-party or shared logging infrastructure. Although the middleware defaults this option to `false`, the prominent framework examples explicitly enable it without showing redaction, allowlisting safe routes, excluding authentication and payment endpoints, or warning against production use. This exceeds the minimum data collection needed for ordinary HTTP request logging, for which method, path, status, latency, and payload length are sufficient. The sta ...[truncated 1973 chars]
Remediation
## Remediation Suggestions 1. Keep `WithRequestBody` and `WithResponseBody` disabled in the default and primary examples: ```go WithRequestBody: false, WithResponseBody: false, ``` 2. Add an explicit warning that body logging should not be enabled globally in production and that size limits do not constitute redaction. 3. If body logging is necessary for troubleshooting, use an allowlist of known-safe endpoints and content types. Always exclude authentication, token, payment, upload, and personal-data routes. 4. Sanitize records before routing them to any sink. Redact values by schema and key, including passwords, tokens, authorization data, cookies, secrets, email addresses, IP addresses, and payment fields. Ensure sanitization wraps all downstream handlers. 5. Prefer structured, non-sensitive diagnostic fields such as body size, schema-validation result, content type, and a correlation identifier rather than the raw payload. 6. Document safe handling for the Sentry `request` attribute. Remove or redact authorization headers, cookies, sensitive query parameters, and request bodies before attaching a request object. 7. Add tests with representative secret values to verify that no configured sink receives raw credentials or personal information. 8. Apply least-privilege access, short retention periods, encryption in transit and at rest, and auditing to every remote logging backend. These controls are defense in depth and do not replace source-side minimization and redaction.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (18)

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
## Cross-References

- → See `samber/cc-skills-golang@golang-observability` skill for slog fundamentals (levels, context, handler setup, migration)
- → See `samber/cc-skills-golang@golang-error-handling` skill for the log-or-return rule
- → See `samber/cc-skills-golang@golang-security` skill for PII handling in logs
- → See `samber/cc-skills-golang@golang-samber-oops` skill for structured error context with `samber/oops`
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The HTTP middleware example explicitly enables request body logging (`WithRequestBody: true`) without any adjacent warning about secrets, credentials, tokens, or personal data that may be present in request payloads. In a logging-focused skill, examples are likely to be copied into production, so this can lead to sensitive data exposure in logs and downstream sinks such as Sentry, Loki, Datadog, or webhooks.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
This markdown file documents sending logs to third-party services including Datadog, Sentry, Loki, Graylog, Kafka, Fluentd, Logstash, Slack, Telegram, and generic webhooks, but it does not warn that log records may contain user or system data that will leave the local environment. Under the markdown-specific SQP-2 criteria, descriptions of behaviors affecting privacy or data handling should disclose that impact.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The documentation explicitly promotes `WithRequestBody` and `WithResponseBody` style logging capabilities without any warning that HTTP bodies commonly contain credentials, tokens, PII, session data, or other secrets. In a logging middleware skill, this is especially risky because readers may copy these examples directly into production and unintentionally create durable sensitive-data exposure in centralized logs.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
Documenting request-header and client-IP logging options without privacy and secret-handling guidance can lead users to capture `Authorization`, cookies, API keys, forwarding headers, and personal data in logs. Because this skill is specifically about HTTP logging middleware, the omission is more dangerous than in a generic doc: it normalizes broad request observability without emphasizing minimization and redaction.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
This markdown file includes examples that send log records to external services such as Sentry and Loki, which may transmit user or system data off-host. Although the examples discuss behavior and routing, they do not warn readers about privacy implications or the need to avoid sending sensitive data to remote sinks.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The prompt explicitly requires output in Go ('Set up a slog pipeline in Go...') without offering a language choice or documenting a justified locale/language constraint. This is a natural-language policy issue under the stated rule because it mandates a specific language rather than allowing user opt-in.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
This prompt is framed around a Go-specific API and asks for a fix 'with slog-multi' in that language ecosystem, without offering the user any language choice or documenting a justified language constraint. Under the provided policy rule, that is a language-forcing instruction.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
The prompt requires setting up logging 'in a Go HTTP server' and asks for a complete main() function, thereby mandating a specific programming language without user opt-in. The file does not document a policy justification for this constraint.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
The prompt constrains the response to a Go logging library context without offering any language choice. Per the provided rule, this is a language policy concern unless the constraint is clearly justified in the text.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
The prompt includes Go code and asks for diagnosis within that language/library context, but does not offer the user a language option or note a justified language restriction. That matches the language-policy violation pattern described in the rule.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
This prompt explicitly targets a Gin server and samber/slog-gin usage, effectively requiring a Go-based answer without user opt-in. The text does not justify the language constraint as an explicit region- or compliance-specific requirement.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
The prompt mandates a solution using samber/slog-multi and reusable middleware in that ecosystem, which effectively forces a Go-language response. No opt-in or explicit justification for the language restriction is provided in the text.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
The prompt prescribes use of samber/slog-multi and Loki file fallback setup, which constrains the answer to a Go-specific library stack without user language choice. That is a policy issue under the provided rule set.

Natural-Language Policy Violations

Low
Confidence
91% confidence
Finding
This text asks about replacing slogmulti handlers and their latency model, anchoring the response to a Go-specific library context without any user opt-in on language. The constraint is not explicitly justified in the file.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
The prompt requires a solution for 'my Go service' using slog and slog-multi, which forces a specific programming language context without offering a choice. The text does not explicitly justify why the language must be fixed.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
This prompt explicitly asks for setup using Go-specific libraries and imports, mandating a Go-language answer without user choice. Under the stated policy rule, such forced language use should be justified or optional.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
The prompt is tightly scoped to a Go HTTP server and Go context APIs, requiring a Go-specific answer without offering language opt-in. No explicit policy justification for the forced language appears in the file.

Static analysis

No suspicious patterns detected.