Skip to content

bridge: sanitize outbound /proc and env leaks#142

Merged
benvinegar merged 1 commit into
mainfrom
bridge/outbound-sanitize-proc-env
Feb 23, 2026
Merged

bridge: sanitize outbound /proc and env leaks#142
benvinegar merged 1 commit into
mainfrom
bridge/outbound-sanitize-proc-env

Conversation

@benvinegar
Copy link
Copy Markdown
Member

@benvinegar benvinegar commented Feb 23, 2026

Summary

  • add broker-side outbound sanitizer for Slack replies
  • block high-risk /proc leak shapes (e.g. /proc/*/environ, /proc/*/cmdline, NUL-delimited env dumps)
  • redact common token/env secret patterns before outbound send
  • apply sanitization to both /send and /reply endpoints
  • add unit tests for new sanitizer behavior

Validation

  • node --test slack-bridge/security.test.mjs

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 23, 2026

Greptile Summary

Adds broker-side outbound message sanitization to prevent sensitive data leaks through Slack. The implementation blocks high-risk patterns (like /proc/self/environ paths and NUL-delimited env dumps) completely and redacts known token formats (Slack, GitHub, OpenAI, AWS tokens) before sending messages through the /send and /reply endpoints.

Key changes:

  • New sanitizeOutboundText function with blocking patterns for /proc paths and env dumps
  • Redaction patterns for common API tokens and sensitive env assignments
  • Integration into both /send and /reply endpoints with contextual logging
  • Comprehensive test coverage for block, redact, and pass-through scenarios

Minor improvement opportunity:

  • Regex in line 178 has redundant character class that could be simplified

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Security-critical functionality has comprehensive test coverage, follows existing code patterns, and properly integrates into both outbound endpoints. The implementation is defensive and uses well-tested regex patterns. Only minor style suggestion identified.
  • No files require special attention

Important Files Changed

Filename Overview
slack-bridge/security.mjs Adds sanitizeOutboundText function with blocking and redaction patterns for sensitive data leaks
slack-bridge/broker-bridge.mjs Integrates sanitizeOutboundMessage wrapper into /send and /reply endpoints with proper logging
slack-bridge/security.test.mjs Comprehensive test coverage for blocking, redaction, and pass-through scenarios

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent sends message to /send or /reply] --> B[sanitizeOutboundMessage wrapper]
    B --> C[sanitizeOutboundText function]
    C --> D{Check BLOCK patterns}
    D -->|Match found| E[Return BLOCK_FALLBACK message]
    D -->|No match| F{Check REDACT patterns}
    F -->|Matches found| G[Replace with redaction tokens]
    F -->|No matches| H[Pass through unchanged]
    E --> I[Log warning with block reasons]
    G --> J[Log warning with redact reasons]
    H --> K[No logging]
    I --> L[Send sanitized text via broker]
    J --> L
    K --> L
    L --> M[Slack message posted]
Loading

Last reviewed commit: 13f9f35

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread slack-bridge/security.mjs
{ pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/g, replacement: "[REDACTED_GITHUB_TOKEN]", reason: "github-token" },
{ pattern: /\bsk-[A-Za-z0-9]{20,}\b/g, replacement: "[REDACTED_API_KEY]", reason: "openai-key" },
{ pattern: /\bAKIA[A-Z0-9]{16}\b/g, replacement: "[REDACTED_AWS_KEY]", reason: "aws-access-key" },
{ pattern: /\b((?:SECRET|TOKEN|PASSWORD|PASS|API(?:_|-)?KEY|ACCESS(?:_|-)?KEY|PRIVATE(?:_|-)?KEY|SESSION|COOKIE|BEARER|SLACK|GITHUB|OPENAI|ANTHROPIC|GEMINI|AWS)[A-Z0-9_-]*)=[^\s\n\r\0]{1,400}/gi, replacement: "$1=[REDACTED_ENV]", reason: "sensitive-env-assignment" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The character class [^\s\n\r\0] is redundant since \s already includes \n and \r. This could be simplified to [^\s\0] for cleaner regex syntax.

Prompt To Fix With AI
This is a comment left during a code review.
Path: slack-bridge/security.mjs
Line: 178

Comment:
The character class `[^\s\n\r\0]` is redundant since `\s` already includes `\n` and `\r`. This could be simplified to `[^\s\0]` for cleaner regex syntax.

How can I resolve this? If you propose a fix, please make it concise.

@benvinegar benvinegar merged commit 9a3e46b into main Feb 23, 2026
10 checks passed
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