# Phase 3: E2E Security Testing Plan
**Document Status:** Active Planning Phase
**Created:** February 10, 2026
**Target Execution:** Following Phase 2.3 Validation (Post-Approval)
**Approval Gate:** Supervisor Review + Security Team Sign-off
---
## 1. Executive Summary
### Objective
Validate that all security middleware components properly enforce their intended security policies during extended E2E test sessions. Phase 3 transforms theoretical security architecture into verified, tested operational security.
### Scope
- **Test Coverage:** Core, Settings, Tasks, Monitoring test suites with security enforcement validation
- **Middleware Stack:** Cerberus ACL, Coraza WAF, Rate Limiting, CrowdSec integration
- **Session Duration:** 60+ minute extended test runs with automatic token refresh
- **User Roles:** Admin, Regular User, Guest (role-based access validation)
- **Attack Vectors:** SQL injection, XSS, CSRF, DDoS, bot patterns, unauthorized access
### Duration & Resources
- **Estimated Execution Time:** 2-3 hours (includes 60-minute session test)
- **Test Count:** 60-90 distributed across 5 test suites
- **Infrastructure:** Docker container with all security modules enabled
- **Team:** Playwright QA Engineers + Security Infrastructure team
### Risk & Success Criteria
#### Success Criteria (PASS)
- ✅ All 60-90 security tests pass at 100% rate
- ✅ 60-minute session test completes without 401/403 errors
- ✅ All middleware properly logging security events
- ✅ No unauthorized access detected
- ✅ All attack vectors properly blocked
- ✅ Rate limiting enforced consistently
#### Failure Criteria (FAIL)
- ❌ Any security test fails (indicates bypass or misconfiguration)
- ❌ 401/403 errors during 60-minute test (session instability)
- ❌ Unauthorized access allowed (ACL bypass)
- ❌ Malicious requests not blocked (WAF bypass)
- ❌ Rate limit not enforced (abuse vulnerability)
- ❌ CrowdSec fails to block blacklisted IPs
- ❌ Data leakage between user roles
### Entry Criteria
- ✅ Phase 2.3 Critical Fixes Completed:
- CVE-2024-45337 patched (golang.org/x/crypto updated)
- InviteUser async email refactored (non-blocking)
- Auth token refresh implemented (60+ min session support)
- All validation gates passed (100% success rate)
- ✅ Docker environment ready with all security modules enabled
- ✅ Test database seeded with admin, user, and guest accounts
- ✅ Caddy reverse proxy configured with all plugins
- ✅ Cerberus ACL rules loaded
- ✅ Coraza WAF signatures up-to-date
- ✅ CrowdSec running with decision list synced
### Exit Criteria
- Phase 3 Go/No-Go decision made
- All test results documented in validation report
- Security middleware configurations logged
- Recommendations for Phase 4 (UAT/Integration) prepared
---
## 2. Test Environment Setup
### Pre-Execution Verification Checklist
#### Container & Infrastructure Readiness
- [ ] Docker image rebuilt with latest security modules
- Golang base image with latest security patches
- Caddy with Cerberus plugin
- Coraza WAF signatures updated
- [ ] `charon-e2e` container running and healthy
- [ ] All required ports exposed:
- `8080` - Application UI/API
- `2019` - Caddy admin API
- `2020` - Emergency server
- [ ] Health check passes for all services
#### Security Module Configuration
- [ ] **Cerberus ACL Module:** ENABLED
- Admin role configured with full permissions
- User role configured with limited permissions
- Guest role configured with read-only permissions
- All policies loaded and active
- [ ] **Coraza WAF Module:** ENABLED
- OWASP ModSecurity Core Rule Set (CRS) loaded
- Paranoia level configured (default: 2)
- Log engine active
- [ ] **Rate Limiting Module:** ENABLED
- Rate limit thresholds configured per endpoint
- Storage backend (Redis) active if distributed
- Headers configured for response
- [ ] **CrowdSec Integration:** ENABLED
- CrowdSec service running
- Decision list synced and populated
- Bouncer middleware active in Caddy
- Support plans activated (Community minimum)
- **Verify with:**
```bash
# Check CrowdSec decisions are populated (should show >0 decisions)
docker exec charon-e2e cscli decisions list | head -20
# Expected: List of IP/scenario decisions with counts > 0
# Alternative if cscli not available:
docker exec charon-e2e curl -s http://127.0.0.1:8081/v1/decisions \
-H "X-Api-Key: $BOUNCER_KEY" | jq '.decisions | length'
# Expected: Integer > 0 (number of decisions in database)
# Whitelist test container IP in CrowdSec bouncer (avoids blocking test traffic)
# Add to .docker/compose/.env or runtime:
CROWDSEC_BOUNCER_WHITELIST="127.0.0.1/32,172.17.0.0/16"
# Then verify bouncer config:
docker exec charon-e2e grep -A5 "whitelist:" /etc/crowdsec/bouncers/caddy.yaml || echo "Config check complete"
```
#### Application Configuration
- [ ] Emergency token configured and validated
- Format: Bearer token, 32+ characters
- Used only for bootstrap/recovery operations
- [ ] Database state confirmed
- Test users exist with correct roles
- No test contamination from previous runs
- Backup created for recovery
- [ ] Environment variables loaded
- `.env` file configured for test environment
- Security headers enabled
- HTTPS/TLS properly configured
- CORS rules appropriate for testing
#### Test User Configuration
```
TEST USERS REQUIRED:
1. Admin User
- Username: admin@test.local
- Password: [Securely stored in .env]
- Role: Administrator
- Permissions: Full access to all endpoints
2. Regular User
- Username: user@test.local
- Password: [Securely stored in .env]
- Role: User
- Permissions: Limited to personal data + read proxy hosts
3. Guest User
- Username: guest@test.local
- Password: [Securely stored in .env]
- Role: Guest
- Permissions: Read-only dashboard access
4. Rate Limit Test User
- Username: ratelimit@test.local
- Password: [Securely stored in .env]
- Role: User
- Purpose: Dedicated account for rate limit testing
```
#### Caddy Configuration Verification
```bash
# Verify all modules loaded
curl -s http://localhost:2019/config/apps/http/servers/default/routes
# Verify ACL policies are set
curl -s http://localhost:2019/config/apps/http/middleware/access_control_lists
# Verify WAF rules are set
curl -s http://localhost:2019/config/apps/http/middleware/waf
# Verify rate limits are set
curl -s http://localhost:2019/config/apps/http/middleware/rate_limit
```
#### Log Access & Monitoring
- [ ] Caddy logs accessible at `/var/log/caddy/` (or mounted volume)
- [ ] Application logs accessible at `/var/log/charon/`
- [ ] Security event logs separate and monitored
- [ ] Real-time log tailing available:
```bash
docker logs -f charon-e2e
docker exec charon-e2e tail -f /var/log/caddy/access.log
```
---
## 3. Cerberus ACL Testing (Access Control)
### Overview
Cerberus ACL module enforces role-based access control (RBAC) at the middleware layer. All API endpoints and protected resources require role verification before processing.
### Test Strategy
#### Admin Access Enforcement
- Verify admin users can access all protected endpoints
- Confirm admin portal loads with full permissions
- Validate admin can modify security settings
- Ensure admin operations logged
#### User Access Restrictions
- Verify regular users cannot access admin-only endpoints
- Confirm regular users receive 403 Forbidden for blocked endpoints
- Validate regular users can only access personal/assigned resources
- Ensure user can read but not modify advanced settings
#### Guest User Capabilities
- Verify guest users can view dashboard (read-only)
- Confirm guest cannot access settings or admin panels
- Validate guest cannot perform any write operations
- Ensure guest access properly logged
#### Role Transition Testing
- Test permission changes when role is updated
- Verify session updates reflect new permissions
- Confirm re-login required for permission elevation (admin check)
### Required Tests
#### API Endpoint Tests
**Admin-Only Endpoints** (Should return 200 for admin, 403 for others)
- [ ] `GET /api/v1/users` - List all users (admin only)
- [ ] `POST /api/v1/users` - Create user (admin only)
- [ ] `DELETE /api/v1/users/{id}` - Delete user (admin only)
- [ ] `GET /api/v1/access-lists` - View ACL policies (admin only)
- [ ] `POST /api/v1/access-lists` - Create ACL (admin only)
- [ ] `PUT /api/v1/settings/advanced` - Modify advanced settings (admin only)
**User-Accessible Endpoints** (Should return 200 for authenticated users)
- [ ] `GET /api/v1/users/me` - Get current user info
- [ ] `PUT /api/v1/users/me` - Update own profile
- [ ] `GET /api/v1/proxy-hosts` - List proxy hosts (read)
- [ ] `GET /api/v1/dashboard/stats` - View personal stats
- [ ] `GET /api/v1/logs?filter=personal` - View personal logs
**Guest-Readonly Endpoints** (Should return 200 for guest, data filtered)
- [ ] `GET /api/v1/dashboard` - View dashboard (limited data)
- [ ] `GET /api/v1/proxy-hosts` - List proxy hosts (read-only labels)
- [ ] Cannot perform: POST, PUT, DELETE operations
#### UI Navigation Tests
**Dashboard Access by Role**
- [ ] Admin dashboard loads with all widgets
- [ ] User dashboard loads with limited widgets
- [ ] Guest dashboard loads with read-only UI
- [ ] Settings page shows/hides fields by role
- [ ] Admin panel only accessible to admins
- [ ] Unauthorized access attempts redirected to 403 page
**Permission-Based UI Elements**
- [ ] Edit buttons hidden for read-only users
- [ ] Delete buttons hidden for non-admin users
- [ ] Advanced settings only visible to admins
- [ ] User invitation form only visible to admins
- [ ] Security settings only accessible to admins
#### Cross-Role Isolation Tests
**Data Visibility Boundaries**
- [ ] Admin user cannot access other admin's private logs
- [ ] User A cannot see User B's data
- [ ] Guest cannot see any user data
- [ ] API filters enforce role boundaries (not just UI)
- [ ] Database queries include role-based WHERE clauses
**Permission Elevation Prevention**
- [ ] User cannot elevate own role via API
- [ ] User cannot modify admin flag in API calls
- [ ] Guest cannot bypass to user via token manipulation
- [ ] Role changes require logout/re-login
- [ ] Token refresh does not grant elevated permissions
### Success Criteria
| Criterion | Expected | Test Count |
|-----------|----------|-----------|
| Admin access to protected endpoints | ✅ 200 OK for all 5 admin endpoints | 5 |
| User receives 403 for admin endpoints | ✅ 0 unauthorized access | 5 |
| Guest can view dashboard | ✅ Dashboard loads with filtered data | 3 |
| Role-based UI elements | ✅ Buttons/fields show/hide correctly | 8 |
| Cross-role data isolation | ✅ No data leakage in API responses | 6 |
| Permission elevation prevented | ✅ All attempts blocked | 4 |
| **Total Cerberus Tests** | | **31** |
### Phase 3A: Cerberus ACL Validation
**File:** `tests/phase3/cerberus-acl.spec.ts`
**Test Count:** 15-20 tests
**Risk Level:** MEDIUM (affects usability)
**Execution Duration:** ~10 minutes
---
## 4. Coraza WAF Testing (Web Application Firewall)
### Overview
Coraza WAF protects against malicious requests including SQL injection, XSS, CSRF, and other OWASP Top 10 vulnerabilities. Uses OWASP ModSecurity Core Rule Set (CRS).
### Test Strategy
#### SQL Injection Detection & Blocking
- Inject common SQL patterns into API parameters
- Attempt database enumeration via UNION SELECT
- Test time-based boolean blindness patterns
- Verify requests blocked with 403 Forbidden
- Confirm attack logged and attributed
#### Cross-Site Scripting (XSS) Prevention
- Submit JavaScript payload in form fields
- Test HTML entity encoding
- Attempt DOM-based XSS via API
- Verify malicious scripts blocked
- Confirm sanitization logs
#### CSRF Token Validation
- Attempt POST requests without CSRF token
- Verify token presence required for state-changing operations
- Test token expiration handling
- Confirm token rotation after use
- Validate mismatched tokens rejected
#### Malformed Request Handling
- Submit oversized payloads (>100MB)
- Send invalid Content-Type headers
- Test null byte injection
- Submit double-encoded payloads
- Verify safe error responses
#### WAF Rule Enforcement
- Verify OWASP CRS rules active
- Test anomaly score evaluation
- Confirm rule exceptions configured
- Validate phase-based rule execution
- Test logging of matched rules
### Required Tests
#### SQL Injection Tests
```
TEST CASES:
1. POST /api/v1/proxy-hosts with param:
?id=1' OR '1'='1
EXPECTED: 403 Forbidden, logged as SQL_INJECTION
2. GET /api/v1/users?search=admin' UNION SELECT...
EXPECTED: 403 Forbidden, mode=BLOCK
3. POST /api/v1/users name="'; DROP TABLE users; --"
EXPECTED: 403 Forbidden, rules.matched logged
4. Malformed URL encoding: %2527 patterns
EXPECTED: 403 Forbidden or 400 Bad Request (configurable)
```
#### XSS Payload Tests
```
TEST CASES:
1. POST /api/v1/proxy-hosts with body:
{"description": ""}
EXPECTED: 403 Forbidden, XSS rule matched
2. GET /api/v1/dashboard?filter=
EXPECTED: 403 Forbidden, HTML attack pattern
3. Form field: