Skip to content

Security: Fix network exposure and add secret redaction#1

Merged
doneyli merged 1 commit intomainfrom
security/fix-network-exposure-and-secrets
Jan 31, 2026
Merged

Security: Fix network exposure and add secret redaction#1
doneyli merged 1 commit intomainfrom
security/fix-network-exposure-and-secrets

Conversation

@doneyli
Copy link
Owner

@doneyli doneyli commented Jan 31, 2026

Summary

This PR addresses security vulnerabilities identified during a security audit:

🔴 Critical: Network Exposure (Fixed)

  • langfuse-web was bound to 0.0.0.0:3050 - accessible from any network
  • minio S3 API was bound to 0.0.0.0:9090 - accessible from any network

Impact: Anyone on the same WiFi/LAN could access your Langfuse dashboard and all captured Claude Code conversations, including code, prompts, and potentially secrets.

Fix: Both services now bind to 127.0.0.1 (localhost only).

🟡 Medium: Shell Injection in install-hook.sh (Fixed)

  • Script used source .env which would execute any shell code in the .env file
  • Now uses safe grep-based extraction

🟢 New: Automatic Secret Redaction

Before sending traces to Langfuse, the hook now automatically redacts:

  • OpenAI/Anthropic API keys (sk-...)
  • Langfuse keys (sk-lf-...)
  • Bearer tokens
  • Passwords in common formats
  • Generic API keys

This is enabled by default. Disable with CC_LANGFUSE_REDACT=false if needed.

🟢 New: Log Rotation

  • Hook log rotates at 10MB, keeps 3 backups
  • Prevents unbounded disk usage

Test Plan

  • Unit tests pass
  • Docker Compose files validate
  • Sanitization patterns verified manually
  • All services still bind correctly

Files Changed

  • docker-compose.yml - Localhost binding for langfuse-web, minio
  • docker-compose.test.yml - Same fixes for test config
  • hooks/langfuse_hook.py - Secret redaction + log rotation
  • scripts/install-hook.sh - Safe .env parsing

🤖 Generated with Claude Code

## Changes

### Network Security (HIGH priority)
- Bind langfuse-web to 127.0.0.1:3050 instead of 0.0.0.0:3050
- Bind minio S3 API to 127.0.0.1:9090 instead of 0.0.0.0:9090
- Apply same fixes to docker-compose.test.yml

This prevents services from being accessible to other machines on the
network. Previously, anyone on the same WiFi/LAN could access your
Langfuse dashboard and all captured traces.

### Credential Loading (MEDIUM priority)
- Replace `source .env` with grep-based extraction in install-hook.sh
- Prevents potential shell injection if .env contains malicious code

### Secret Redaction (NEW feature)
- Add automatic redaction of common secret patterns before sending to Langfuse
- Patterns: OpenAI/Anthropic keys, Bearer tokens, passwords, API keys
- Enabled by default, disable with CC_LANGFUSE_REDACT=false
- Recursive sanitization for nested dicts/lists in tool inputs/outputs

### Log Rotation (NEW feature)
- Add log rotation when langfuse_hook.log exceeds 10MB
- Keep 3 backup files (.log.1, .log.2, .log.3)
- Prevents unbounded disk usage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@doneyli doneyli merged commit 86d54b2 into main Jan 31, 2026
1 check passed
@doneyli doneyli deleted the security/fix-network-exposure-and-secrets branch January 31, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant