Security Architecture
The webhook server follows a defense-in-depth approach with multiple security layers:Core Security Components
- Webhook Authentication - HMAC-SHA256 signature verification
- IP Allowlisting - Restrict access to GitHub and Cloudflare IP ranges
- Token Security - Multiple token support with automatic rotation
- Network Isolation - Deploy critical endpoints behind VPN or reverse proxy
- SSL/TLS - Encrypted communication with GitHub API
Token Security Best Practices
Token Storage
Never commit tokens to version control. Use one of these secure methods:-
Environment Variables (Recommended for containers):
-
External Secret Management:
-
Configuration File (secure file permissions):
Token Permissions
Use fine-grained personal access tokens when possible:-
Repository permissions:
Contents: Read & WriteIssues: Read & WritePull requests: Read & WriteChecks: Read & WriteMetadata: ReadAdministration: Read & Write (for branch protection)
-
Organization permissions:
Members: Read (for OWNERS validation)
Token Rotation Strategy
Implement automatic failover with multiple tokens:- Automatic failover when rate limits are reached
- Zero downtime during token rotation
- Distribute API quota across multiple tokens
Token Monitoring
Monitor token usage in structured logs:SSL/TLS Configuration
Production Settings
- Deploy behind reverse proxy with TLS termination
- Use valid SSL certificates (Let’s Encrypt, commercial CA)
- Enable HSTS headers in reverse proxy
- Disable TLS 1.0/1.1, enforce TLS 1.2+
Development Settings
Network-Level Security
Reverse Proxy with Authentication
nginx example with HTTP Basic Auth:Firewall Rules
Restrict access to webhook server port:VPN Access
Deploy log viewer endpoints only on VPN:- WireGuard VPN - Modern, secure VPN solution
- OpenVPN - Traditional VPN with broad compatibility
- Tailscale - Zero-config mesh VPN
Network Segmentation
Isolate webhook server in dedicated network segment:Sensitive Data Protection
Log Masking
Always enable in production:- GitHub personal access tokens (
ghp_*,github_pat_*) - Webhook secrets
- Container registry passwords
- PyPI tokens
- API keys in environment variables
Custom Check Runs Security
Risks:- Commands run with the webhook server’s system permissions
- Commands execute in the cloned repository worktree
- Malicious or misconfigured commands could compromise server security
- Environment variables in commands may expose sensitive data in logs
- Review all commands carefully - Only configure commands from trusted sources
- Principle of least privilege - Run the webhook server with minimal required permissions
- Audit configurations - Regularly review
custom-check-runsin configuration files - Restrict configuration access - Limit who can modify
config.yamland.github-webhook-server.yaml - Monitor execution logs - Watch for unexpected command behavior or failures
- Avoid sensitive data in commands - Do not embed secrets directly in command strings
Security Best Practices
1. Log Viewer Access Control
Required security measures:- ✅ Deploy behind reverse proxy with authentication
- ✅ Use firewall rules to restrict access to trusted IP ranges only
- ✅ Never expose log viewer ports directly to the internet
- ✅ Monitor access to log endpoints in infrastructure logs
- ✅ Consider VPN-only access for maximum security
- GitHub personal access tokens
- User information and webhook payloads
- Repository details and sensitive data
- Internal system information
2. Container Security
Run as non-privileged user when possible:3. Secrets Management
Use external secret management systems:- HashiCorp Vault - Enterprise secret management
- AWS Secrets Manager - Cloud-native secrets
- Kubernetes Secrets - Container orchestration secrets
- GitHub Secrets - For GitHub Actions integration
4. Comprehensive Logging
Enable detailed logging for security monitoring:5. Regular Updates
Keep webhook server updated:6. Security Monitoring
Monitor for security events:Environment Variables
Security-related environment variables:| Variable | Description | Default | Security Impact |
|---|---|---|---|
WEBHOOK_SECRET | GitHub webhook secret | - | HIGH - Required for signature verification |
VERIFY_GITHUB_IPS | Verify GitHub IP addresses | false | HIGH - Enable for production |
VERIFY_CLOUDFLARE_IPS | Verify Cloudflare IP addresses | false | MEDIUM - Enable if using Cloudflare |
ENABLE_LOG_SERVER | Enable log viewer endpoints | false | CRITICAL - Never enable on public networks |
ENABLE_MCP_SERVER | Enable MCP server endpoints | false | CRITICAL - Never enable on public networks |
Compliance and Auditing
Audit Trail
Structured webhook logs provide complete audit trail:Data Retention
Implement log rotation and retention policies:Compliance Frameworks
SOC 2 Considerations:- Access control (reverse proxy authentication)
- Audit logging (structured webhook logs)
- Data encryption (TLS/SSL)
- Incident response (monitoring and alerting)
- Data minimization (configure only necessary webhooks)
- Right to erasure (log retention policies)
- Data security (encryption, access control)
Security Checklist
Before deploying to production:- Enable webhook signature verification (
WEBHOOK_SECRET) - Enable IP allowlist verification (
VERIFY_GITHUB_IPS=true) - Enable sensitive data masking (
mask-sensitive-data: true) - Deploy log viewer behind authentication (nginx, VPN)
- Configure TLS/SSL with valid certificates
- Implement firewall rules for webhook server
- Use external secret management for tokens
- Enable comprehensive logging (
log-level: INFO) - Set up monitoring and alerting
- Implement log rotation and retention
- Review custom check runs security
- Test disaster recovery procedures
- Document security procedures
Next Steps
Webhook Verification
Learn about IP allowlisting and HMAC signature verification
Log Viewer Security
Secure the unauthenticated log viewer endpoints