Skip to content

Commit 48be2bf

Browse files
committed
update README.md for v1.0.1 security features
1 parent 1faec47 commit 48be2bf

3 files changed

Lines changed: 177 additions & 43 deletions

File tree

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@
136136
{
137137
"type": "Secret Keyword",
138138
"filename": "README.md",
139-
"hashed_secret": "df8f93c84a64b6396686b8e5833a28946a756d2b",
139+
"hashed_secret": "2ccbb370c147cffc90493a2c190f4f85ad780348",
140140
"is_verified": false,
141-
"line_number": 295
141+
"line_number": 568
142142
}
143143
],
144144
"app.py": [
@@ -344,5 +344,5 @@
344344
}
345345
]
346346
},
347-
"generated_at": "2025-10-24T00:47:18Z"
347+
"generated_at": "2025-10-24T01:17:22Z"
348348
}

README.md

Lines changed: 173 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -285,34 +285,48 @@ The main configuration file is `config.json` in the project root.
285285
**Default Configuration:**
286286
```json
287287
{
288-
"matrix_server": "https://matrix.example.com",
288+
"matrix_server": "",
289289
"app": {
290-
"host": "127.0.0.1",
290+
"host": "0.0.0.0",
291291
"port": 5000,
292292
"debug": true
293293
},
294-
"session": {
295-
"secret_key": "your-secret-key-here-change-this"
296-
}
294+
"language": "en"
297295
}
298296
```
299297

300298
**Configuration Options:**
301299

302300
| Parameter | Description | Default | Required |
303301
|-----------|-------------|---------|----------|
304-
| `matrix_server` | Your Matrix Synapse server URL (can be changed at login) | `https://matrix.example.com` | No |
305-
| `app.host` | Application host | `127.0.0.1` | Yes |
302+
| `matrix_server` | Default Matrix server URL (can be changed at login) | `""` | No |
303+
| `app.host` | Application host | `0.0.0.0` | Yes |
306304
| `app.port` | Application port | `5000` | Yes |
307-
| `app.debug` | Debug mode (disable in production) | `true` | Yes |
308-
| `session.secret_key` | Flask session secret key (change in production) | Generated | Yes |
305+
| `app.debug` | Debug mode (disable in production!) | `true` | Yes |
306+
| `language` | Default interface language | `en` | Yes |
307+
308+
### Environment Variables (v1.0.1+)
309+
310+
**Required for Production:**
311+
312+
| Variable | Description | Example | Default |
313+
|----------|-------------|---------|---------|
314+
| `FLASK_SECRET_KEY` | Session encryption key (min 32 chars) | `your-secret-key-here` | Auto-generated in debug |
315+
316+
**Optional (Security):**
317+
318+
| Variable | Description | Example | Default |
319+
|----------|-------------|---------|---------|
320+
| `EPT_DISABLE_SSL_VERIFY` | Disable SSL verification (dev only!) | `true` | `false` |
321+
| `EPT_CA_BUNDLE` | Path to CA bundle for custom certificates | `/path/to/ca.crt` | System default |
309322

310323
### Important Notes
311324

312-
1. **Matrix Server**: The `matrix_server` in config.json is optional - you can specify any server at login
313-
2. **Secret Key**: Change `session.secret_key` in production to a random string
325+
1. **Matrix Server**: The `matrix_server` in config.json is optional - specify any server at login
326+
2. **Secret Key**: `FLASK_SECRET_KEY` environment variable is REQUIRED in production (min 32 characters)
314327
3. **Debug Mode**: Set `app.debug` to `false` in production
315-
4. **SSL Certificates**: Self-signed certificates are automatically supported
328+
4. **SSL Verification**: Enabled by default in v1.0.1+ for security
329+
5. **Self-Signed Certificates**: Use `EPT_CA_BUNDLE` or `EPT_DISABLE_SSL_VERIFY=true` (dev only)
316330

317331
---
318332

@@ -513,16 +527,59 @@ EPT-MX-ADM supports multiple languages out of the box.
513527

514528
## Production Deployment
515529

516-
### Security Checklist
530+
### Security Checklist (v1.0.1+)
517531

518-
- [ ] Change `session.secret_key` in config.json to a random string
532+
**Critical (Required):**
533+
- [ ] Set `FLASK_SECRET_KEY` environment variable (min 32 chars, use `secrets.token_hex(32)`)
519534
- [ ] Set `app.debug` to `false` in config.json
520-
- [ ] Use strong passwords for admin accounts
521-
- [ ] Enable HTTPS (use nginx or Apache as reverse proxy)
522-
- [ ] Restrict access to the application (firewall, VPN)
523-
- [ ] Keep Python and dependencies up to date
524-
- [ ] Regular backups of config.json
525-
- [ ] Monitor logs for suspicious activity
535+
- [ ] Enable SSL verification (`EPT_DISABLE_SSL_VERIFY=false` or unset)
536+
- [ ] Use HTTPS only (via reverse proxy with valid certificates)
537+
- [ ] Verify CSRF protection is enabled (default in v1.0.1+)
538+
- [ ] Verify rate limiting is active (5 login attempts per minute)
539+
540+
**High Priority:**
541+
- [ ] Use strong, unique passwords for all admin accounts
542+
- [ ] Restrict network access (firewall, VPN, IP whitelist)
543+
- [ ] Enable security headers (X-Frame-Options, CSP, HSTS) via reverse proxy
544+
- [ ] Set up centralized logging and monitoring
545+
- [ ] Configure log retention and rotation
546+
- [ ] Keep Python and all dependencies up to date
547+
- [ ] Enable Dependabot or automated security scanning
548+
549+
**Recommended:**
550+
- [ ] Use systemd service with non-root user
551+
- [ ] Regular automated backups of config.json and application data
552+
- [ ] Monitor for suspicious activity and failed login attempts
553+
- [ ] Implement intrusion detection/prevention (fail2ban, OSSEC)
554+
- [ ] Run vulnerability scans (bandit, pip-audit) regularly
555+
- [ ] Document incident response procedures
556+
- [ ] Set up SSL/TLS certificate auto-renewal (Let's Encrypt)
557+
558+
### Environment Setup
559+
560+
**Generate SECRET_KEY:**
561+
```bash
562+
python3 -c 'import secrets; print(secrets.token_hex(32))'
563+
```
564+
565+
**Set Environment Variables:**
566+
```bash
567+
# Required for production
568+
export FLASK_SECRET_KEY="your-generated-secret-key-here"
569+
570+
# Optional: For custom CA certificates
571+
export EPT_CA_BUNDLE="/path/to/your/ca-bundle.crt"
572+
573+
# NEVER set this in production:
574+
# export EPT_DISABLE_SSL_VERIFY=true
575+
```
576+
577+
**systemd Service with Environment:**
578+
```ini
579+
[Service]
580+
Environment="FLASK_SECRET_KEY=your-secret-key-here"
581+
Environment="EPT_CA_BUNDLE=/path/to/ca-bundle.crt"
582+
```
526583

527584
### Nginx Configuration Example
528585

@@ -543,17 +600,43 @@ server {
543600
ssl_certificate /path/to/cert.pem;
544601
ssl_certificate_key /path/to/key.pem;
545602
603+
# Modern SSL configuration
604+
ssl_protocols TLSv1.2 TLSv1.3;
605+
ssl_ciphers HIGH:!aNULL:!MD5;
606+
ssl_prefer_server_ciphers on;
607+
546608
# Security headers
609+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
547610
add_header X-Frame-Options "SAMEORIGIN" always;
548611
add_header X-Content-Type-Options "nosniff" always;
549612
add_header X-XSS-Protection "1; mode=block" always;
613+
add_header Referrer-Policy "no-referrer-when-downgrade" always;
614+
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:;" always;
615+
616+
# Rate limiting
617+
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
550618
551619
location / {
552620
proxy_pass http://127.0.0.1:5000;
553621
proxy_set_header Host $host;
554622
proxy_set_header X-Real-IP $remote_addr;
555623
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
556624
proxy_set_header X-Forwarded-Proto $scheme;
625+
626+
# Timeouts
627+
proxy_connect_timeout 60s;
628+
proxy_send_timeout 60s;
629+
proxy_read_timeout 60s;
630+
}
631+
632+
# Apply rate limiting to login
633+
location /login {
634+
limit_req zone=login burst=3 nodelay;
635+
proxy_pass http://127.0.0.1:5000;
636+
proxy_set_header Host $host;
637+
proxy_set_header X-Real-IP $remote_addr;
638+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
639+
proxy_set_header X-Forwarded-Proto $scheme;
557640
}
558641
}
559642
```
@@ -596,9 +679,11 @@ server {
596679
- Check firewall rules
597680

598681
#### "SSL: CERTIFICATE_VERIFY_FAILED" error
599-
**Solution:**
600-
- EPT-MX-ADM automatically handles self-signed certificates
601-
- If error persists, verify server URL starts with `https://`
682+
**Solution (v1.0.1+):**
683+
- SSL verification is enabled by default for security
684+
- For development with self-signed certificates: `export EPT_DISABLE_SSL_VERIFY=true`
685+
- For production with custom CA: `export EPT_CA_BUNDLE=/path/to/ca-bundle.crt`
686+
- For production: use valid SSL certificates via reverse proxy
602687
- Check if Matrix server certificate is properly configured
603688

604689
#### "Invalid credentials" or "Not an admin"
@@ -640,26 +725,75 @@ server {
640725

641726
## Security
642727

728+
### Security Features (v1.0.1+)
729+
730+
EPT-MX-ADM v1.0.1 includes comprehensive security hardening:
731+
732+
**Authentication & Session:**
733+
- CSRF protection on all POST/PUT/DELETE requests
734+
- Rate limiting (5 login attempts per minute per IP)
735+
- Secure session cookies (HttpOnly, Secure, SameSite)
736+
- Required SECRET_KEY (min 32 bytes, env variable only)
737+
- Admin privilege verification via Matrix API
738+
739+
**Network Security:**
740+
- SSL/TLS verification enabled by default
741+
- Support for custom CA bundles
742+
- Security headers (X-Frame-Options, CSP, HSTS, etc.)
743+
- Input sanitization and validation
744+
745+
**Monitoring & Logging:**
746+
- All admin actions logged with IP addresses
747+
- Failed login attempt tracking
748+
- No sensitive data (passwords/tokens) in logs
749+
- Configurable log retention
750+
751+
**Development:**
752+
- Pre-commit hooks for secret detection
753+
- Automated dependency vulnerability scanning
754+
- Static security analysis (Bandit)
755+
- Comprehensive security test suite
756+
643757
### Best Practices
644758

645-
1. **Passwords**: Use strong, unique passwords for admin accounts
646-
2. **Session Secret**: Change `session.secret_key` to a random string
647-
3. **Debug Mode**: Disable debug mode in production
648-
4. **HTTPS**: Always use HTTPS in production (via reverse proxy)
649-
5. **Access Control**: Restrict access to the application via firewall or VPN
650-
6. **Updates**: Keep Python, Flask, and all dependencies up to date
651-
7. **Logs**: Monitor application and server logs regularly
652-
8. **Backups**: Regular backups of configuration and data
759+
1. **Environment Variables**: Use `FLASK_SECRET_KEY` env variable, never hardcode secrets
760+
2. **SSL/TLS**: Enable verification in production, use `EPT_CA_BUNDLE` for custom CAs
761+
3. **Passwords**: Enforce strong, unique passwords for all admin accounts
762+
4. **Debug Mode**: Always set `app.debug=false` in production
763+
5. **HTTPS**: Use HTTPS only via reverse proxy with valid certificates
764+
6. **Access Control**: Restrict network access (firewall, VPN, IP whitelist)
765+
7. **Updates**: Keep Python, Flask, and dependencies up to date (use Dependabot)
766+
8. **Monitoring**: Enable centralized logging and monitor for suspicious activity
767+
9. **Backups**: Regular automated backups of config and application data
768+
10. **Security Scanning**: Run `bandit` and `pip-audit` regularly
653769

654-
### SSL/TLS Support
770+
### SSL/TLS Configuration
655771

656-
EPT-MX-ADM automatically:
657-
- Supports self-signed SSL certificates
658-
- Disables SSL verification for local/development servers
659-
- Adds `https://` to server URLs if not present
660-
- Suppresses SSL warnings in logs
772+
**Production (Recommended):**
773+
```bash
774+
# Use system CA bundle (default, most secure)
775+
unset EPT_DISABLE_SSL_VERIFY
776+
unset EPT_CA_BUNDLE
777+
```
778+
779+
**Custom CA Certificates:**
780+
```bash
781+
# For internal/corporate CAs
782+
export EPT_CA_BUNDLE="/path/to/your/ca-bundle.crt"
783+
```
784+
785+
**Development Only (NOT for production):**
786+
```bash
787+
# ONLY for development with self-signed certificates
788+
export EPT_DISABLE_SSL_VERIFY=true
789+
```
790+
791+
### Security Documentation
661792

662-
For production, always use valid SSL certificates via reverse proxy.
793+
For comprehensive security information, see:
794+
- [SECURITY.md](SECURITY.md) - Security policy and vulnerability reporting
795+
- [DOCKER.md](DOCKER.md) - Secure Docker deployment
796+
- [CHANGELOG.md](CHANGELOG.md) - Security fixes and updates
663797

664798
---
665799

@@ -729,7 +863,7 @@ With the following conditions:
729863
## Project Information
730864

731865
- **Project Name**: EPT-MX-ADM
732-
- **Version**: 1.0.0
866+
- **Version**: 1.0.1
733867
- **Status**: Production Ready
734868
- **PyPI**: [pypi.org/project/ept-mx-adm](https://pypi.org/project/ept-mx-adm/)
735869
- **Company**: EasyProTech LLC

README_RU.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ EPT-MX-ADM автоматически:
427427
## Информация о проекте
428428

429429
- **Название проекта**: EPT-MX-ADM
430-
- **Версия**: 1.0.0
430+
- **Версия**: 1.0.1
431431
- **Статус**: Готов к продакшену
432432
- **PyPI**: [pypi.org/project/ept-mx-adm](https://pypi.org/project/ept-mx-adm/)
433433
- **Компания**: EasyProTech LLC

0 commit comments

Comments
 (0)