A Python application that detects passwords and sensitive credentials shared in Slack channels and sends security alerts.
.
├── assets/ # Static assets (images, icons)
│ └── images/ # Image files
├── docs/ # Documentation
│ ├── SETUP.md # Setup instructions
│ └── SETUP GUIDE.md # Detailed setup guide
├── setup/ # Setup scripts
│ ├── setup_secret_detector.py # Main setup script
│ └── setup_requirements.txt # Setup script dependencies
├── src/ # Source code
│ ├── bedrock_analyzer.py
│ ├── init.py
│ └── slack_utils.py
├── tests/ # Test files
├── requirements.txt # Python dependencies
└── .env.example # Example environment variables
This application monitors Slack messages for potential credentials, passwords, or sensitive information. When detected, it sends alerts to a designated security channel and a direct message to the user who posted the sensitive information.
Features:
- Pattern-based detection: Uses regex patterns to identify various credential formats
- AI-powered analysis: Optional integration with Amazon Bedrock for AI-based detection
- Comprehensive monitoring: Works in all channel types (public, private, DMs)
- Auto-join capability: Can automatically join new channels when invited
- Real-time monitoring: Processes Slack events as they occur
- Security alerts: Sends notifications to a security team channel
- User education: Notifies users when they share sensitive information
- Python 3.9 or higher
- Slack Workspace with admin privileges
- Go to api.slack.com/apps and click "Create New App"
- Choose "From scratch" and provide a name (e.g., "Password Detector") and select your workspace
- Go to "OAuth & Permissions" and add these scopes:
channels:history
- Read messages in public channelschannels:join
- Join public channelschannels:read
- Get channel informationchat:write
- Send alert messagesgroups:history
- Read messages in private channelsgroups:read
- View private channel informationim:history
- Read direct messagesim:read
- View direct message informationmpim:history
- Read group direct messagesmpim:read
- View group direct message informationusers:read
- View basic user information
- Install the app to your workspace
- Copy the "Bot User OAuth Token" (starts with
xoxb-
) for later use
- Create a private channel in Slack (e.g.,
#security-alerts
) - Add your bot to this channel
- Copy the channel ID for configuration
- Clone this repository
- Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Copy
.env.example
to.env
and fill in your configuration:cp .env.example .env
- Edit
.env
with your Slack token and channel ID:SLACK_BOT_TOKEN=xoxb-your-token-here ALERT_CHANNEL_ID=C12345678 USE_BEDROCK=true # Optional: Set to false to disable AI detection
- Run the setup script:
python setup/setup_secret_detector.py
Once configured, the bot will automatically:
- Monitor messages in all channels where it's invited (public, private, and DMs)
- Join new channels when invited
- Detect potential passwords and credentials
- Send alerts to the security team
- Notify users who post sensitive information
The bot can work in:
- Public channels (after being invited or joining)
- Private channels (requires explicit invitation)
- Direct messages (requires user to initiate)
- Multi-person direct messages (requires explicit addition)
Note: For privacy and security reasons, the bot will only join channels it's explicitly invited to.
To enable Amazon Bedrock for AI-based detection:
- Set
USE_BEDROCK=true
in your.env
file - Configure your AWS credentials if using Bedrock
- The AI detection can identify credentials and sensitive information that might not match the predefined patterns
-
Set up a local environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Create a .env file with test credentials:
SLACK_BOT_TOKEN_DEV=xoxb-your-token ALERT_CHANNEL_ID=C12345678
-
Run tests:
pytest
- In any public channel where your bot is present, post a message containing a fake password, like:
password = "MyTestPassword123!"
- Check your security alert channel for the notification
- Verify that the user who posted the message received a direct message
- The application never logs or stores actual credentials
- All sensitive information handling follows security best practices
- Use environment variables for sensitive configuration
- Implement proper access controls and monitoring
MIT License - See LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.