bridge: sanitize outbound /proc and env leaks#142
Merged
Conversation
Greptile SummaryAdds broker-side outbound message sanitization to prevent sensitive data leaks through Slack. The implementation blocks high-risk patterns (like Key changes:
Minor improvement opportunity:
Confidence Score: 5/5
Important Files Changed
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]
Last reviewed commit: 13f9f35 |
| { 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" }, |
There was a problem hiding this 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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/procleak shapes (e.g./proc/*/environ,/proc/*/cmdline, NUL-delimited env dumps)/sendand/replyendpointsValidation