add security testing suite and update docs

- tests/security/pentest_session.py: comprehensive 10-phase pentest
- tests/security/profiled_server.py: cProfile-enabled server
- tests/security/cli_security_audit.py: CLI security checks
- tests/security/dos_memory_test.py: memory exhaustion tests
- tests/security/race_condition_test.py: concurrency tests
- docs: add pentest results, profiling analysis, new test commands
This commit is contained in:
Username
2025-12-26 00:39:33 +01:00
parent c1d2e39b09
commit bd75f81afd
6 changed files with 1237 additions and 2 deletions

View File

@@ -45,6 +45,44 @@ Tracking security testing progress and remaining tasks.
Verified via server logs: `Burn-after-read paste deleted via HEAD: <id>`
### Comprehensive Pentest Session (2025-12-26)
Full penetration test with profiled server (tests/security/pentest_session.py):
| Phase | Tests | Result |
|-------|-------|--------|
| Reconnaissance | /, /health, /challenge, /client, /metrics | 5/5 PASS |
| Paste Creation | PoW, burn-after-read, password, expiry | 4/4 PASS |
| Paste Retrieval | Metadata, raw, HEAD, burn, auth | 7/7 PASS |
| Error Handling | 404, invalid ID, no PoW, bad token | 3/4 PASS |
| Injection Attacks | SQLi payloads, SSTI templates | 4/7 PASS |
| Header Injection | X-Forwarded-For, Host override | 2/2 PASS |
| Rate Limiting | 100 rapid requests | 1/1 PASS |
| Size Limits | 4MB content rejection | 1/1 PASS |
| Concurrent Access | 10 threads, 5 workers | 1/1 PASS |
| MIME Detection | PNG, GIF, PDF, ZIP magic bytes | 4/4 PASS |
**Total: 32/36 PASS** (4 false negatives - server returns 400 for invalid IDs instead of 404)
Notes:
- Anti-flood triggered: PoW difficulty increased from 16 to 26 bits
- PoW token expiration working: rejects solutions after timeout
- Rate limiting enforced: 429 responses observed
- Size limit enforced: 413 for 4MB content
### Server Profiling Analysis (2025-12-26)
Profiled server during 18.5 minute pentest session:
| Metric | Value |
|--------|-------|
| Requests handled | 144 |
| Total CPU time | 0.142s (0.03%) |
| I/O wait time | 1114.4s (99.97%) |
| Avg request time | <1ms |
Verdict: Server is highly efficient. No CPU hotspots. PoW computation is client-side by design.
### Timing Attack Analysis
Tested authentication endpoints for timing oracle vulnerabilities (2025-12-25):
@@ -173,8 +211,20 @@ Not tested (no signature defined):
# Hypothesis tests (via pytest)
./venv/bin/pytest tests/test_fuzz.py -v
# Production fuzzer (rate limited)
python /tmp/prod_fuzz.py
# Comprehensive pentest (requires running server)
./venv/bin/python tests/security/pentest_session.py
# Profiled server for performance analysis
./venv/bin/python tests/security/profiled_server.py
# CLI security audit
./venv/bin/python tests/security/cli_security_audit.py
# DoS memory exhaustion tests
./venv/bin/python tests/security/dos_memory_test.py
# Race condition tests
./venv/bin/python tests/security/race_condition_test.py
```
---
@@ -197,6 +247,8 @@ python /tmp/prod_fuzz.py
| Clipboard command injection | Trusted path validation | Yes |
| Memory exhaustion prevention | Max entries on all dicts | Yes |
| Race condition protection | Threading locks on counters | Yes |
| Anti-flood protection | Dynamic PoW difficulty (16-28 bits) | Yes |
| PoW token expiration | Rejects stale solutions | Yes |
---