-
Notifications
You must be signed in to change notification settings - Fork 0
Security Reference
m1ngsama edited this page Feb 8, 2026
·
1 revision
./tnt
# No password required
# Anyone can connectTNT_ACCESS_TOKEN="YourSecretPassword" ./tntConnect: sshpass -p "YourSecretPassword" ssh -p 2222 localhost
| Variable | Default | Description | Example |
|---|---|---|---|
TNT_ACCESS_TOKEN |
(none) | Require password | TNT_ACCESS_TOKEN="secret" |
TNT_BIND_ADDR |
0.0.0.0 |
Bind address | TNT_BIND_ADDR="127.0.0.1" |
TNT_SSH_LOG_LEVEL |
1 |
SSH logging (0-4) | TNT_SSH_LOG_LEVEL=3 |
TNT_RATE_LIMIT |
1 |
Rate limiting on/off | TNT_RATE_LIMIT=0 |
TNT_MAX_CONNECTIONS |
64 |
Total connection limit | TNT_MAX_CONNECTIONS=100 |
TNT_MAX_CONN_PER_IP |
5 |
Per-IP limit | TNT_MAX_CONN_PER_IP=3 |
./tnt- No authentication
- Rate limiting enabled
- 64 max connections
- 5 per IP
TNT_BIND_ADDR=127.0.0.1 ./tnt- Localhost access only
- Good for development
- No external access
TNT_ACCESS_TOKEN="MyPassword123" ./tnt- Requires password
- Rate limiting blocks brute force (5 failures → 5 min block)
- 3 auth attempts per session
TNT_ACCESS_TOKEN="StrongPass123" \
TNT_BIND_ADDR=127.0.0.1 \
TNT_MAX_CONNECTIONS=10 \
TNT_MAX_CONN_PER_IP=2 \
./tnt- Password required
- Localhost only
- Strict limits
- Rate limiting enabled
- Connection Rate: 10 connections per IP per 60 seconds
- Auth Failures: 5 failures → 5 minute IP block
- Window: 60 second rolling window
After 5 failed auth attempts:
IP 192.168.1.100 blocked due to 5 auth failures
Blocked IP 192.168.1.100 (blocked until 1234567890)
Auto-unblock after 5 minutes.
TNT_RATE_LIMIT=0 ./tntTNT_MAX_CONNECTIONS=50 ./tntRejects new connections when 50 total clients connected.
TNT_MAX_CONN_PER_IP=3 ./tntEach IP can have max 3 concurrent connections.
TNT_MAX_CONNECTIONS=100 TNT_MAX_CONN_PER_IP=10 ./tnt- Total: 100 connections
- Each IP: max 10 connections
First run automatically generates 4096-bit RSA key:
Generating new RSA 4096-bit host key...
-
Location:
./host_key -
Permissions:
0600(owner read/write only) - Size: 4096 bits RSA
rm host_key
./tnt # Generates new keyssh-keygen -l -f host_key
# Output: 4096 SHA256:... (RSA)./test_security_features.shExpected output: ✓ All security features verified!
Test 1: Check Key Size
./tnt &
sleep 8
ssh-keygen -l -f host_key
# Should show: 4096
kill %1Test 2: Test Access Token
TNT_ACCESS_TOKEN="test123" ./tnt &
sleep 5
sshpass -p "test123" ssh -p 2222 localhost # Success
sshpass -p "wrong" ssh -p 2222 localhost # Fails
kill %1Test 3: Test Rate Limiting
./tnt &
sleep 5
for i in {1..15}; do ssh -p 2222 localhost & done
# After 10 connections, should see rate limit blocks
kill %1# Check if port is in use
lsof -i :2222
# Kill existing instance
pkill -f tnt
# Check logs
./tnt 2>&1 | tee debug.log# Check server is listening
lsof -i :2222 | grep tnt
# Check bind address
# If TNT_BIND_ADDR=127.0.0.1, only localhost works
# Use 0.0.0.0 for all interfaces
# Test connection
ssh -v -p 2222 localhost# Check if token is set
env | grep TNT_ACCESS_TOKEN
# If token is set, password is required
# Use: sshpass -p "YourToken" ssh -p 2222 localhost
# If no token, any password works (or none)# Wait 5 minutes for auto-unblock
# Or restart server to clear blocks
pkill -f tnt
./tntBefore:
./tnt # Open accessAfter (Same Behavior):
./tnt # Still open access, backward compatible!New: Add Protection
TNT_ACCESS_TOKEN="secret" ./tnt # Now protected- Default behavior unchanged
- All new features opt-in via environment variables
- Existing scripts/deployments work as-is
#!/bin/bash
# /usr/local/bin/tnt-secure.sh
export TNT_ACCESS_TOKEN="$(cat /etc/tnt/access_token)"
export TNT_BIND_ADDR="0.0.0.0"
export TNT_MAX_CONNECTIONS=200
export TNT_MAX_CONN_PER_IP=10
export TNT_SSH_LOG_LEVEL=1
cd /opt/tnt
exec ./tnt[Unit]
Description=TNT Chat Server
After=network.target
[Service]
Type=simple
User=tnt
WorkingDirectory=/opt/tnt
EnvironmentFile=/etc/tnt/config
ExecStart=/opt/tnt/tnt
Restart=on-failure
[Install]
WantedBy=multi-user.targetTNT_ACCESS_TOKEN=YourProductionPassword
TNT_BIND_ADDR=0.0.0.0
TNT_MAX_CONNECTIONS=500
TNT_MAX_CONN_PER_IP=20
TNT_RATE_LIMIT=1
TNT_SSH_LOG_LEVEL=1✅ DO:
- Use
TNT_ACCESS_TOKENin production - Set
TNT_BIND_ADDR=127.0.0.1if local-only - Keep rate limiting enabled (
TNT_RATE_LIMIT=1) - Monitor
messages.logfor suspicious activity - Rotate access tokens periodically
- Use strong passwords (12+ chars, mixed case, numbers, symbols)
❌ DON'T:
- Disable rate limiting in production (
TNT_RATE_LIMIT=0) - Use weak passwords (e.g., "password", "123456")
- Expose to internet without access token
- Run as root (use dedicated user)
- Share access tokens in plain text
| Feature | Impact | Notes |
|---|---|---|
| 4096-bit RSA | First startup: +3s | Cached after generation |
| Rate Limiting | Minimal | Hash table lookup |
| Access Token | Minimal | Simple string compare |
| UTF-8 Validation | Minimal | Per-character check |
| Message Snapshot | Low | Only during render |
Expected overhead: <5% in normal usage
-
Documentation:
README.md,CHANGELOG.md -
Test Results:
TEST_RESULTS.md -
Test Suite:
./test_security_features.sh - Issues: https://github.com/m1ngsama/TNT/issues