Security Architecture
Guardway Gateway implements defense-in-depth security with multiple layers of protection:Container Security
Overview
All Guardway Gateway containers implement enterprise-grade security hardening following CIS Docker Benchmark and NIST 800-190 guidelines.Security Features by Container
Gateway Container
User:nodejs:1001 (non-root)
Security Options:
- Read-only root filesystem
- All capabilities dropped except
NET_BIND_SERVICE - Seccomp profile:
security/seccomp-mcp.json no-new-privilegesflag enabled- Resource limits: 2 CPU cores, 2GB RAM
/tmp(100MB tmpfs)/home/nodejs/.npm(50MB tmpfs)
Admin UI Container
User:nextjs:1001 (non-root)
Security Options:
- Read-only root filesystem
- All capabilities dropped except
NET_BIND_SERVICE - Seccomp profile enabled
no-new-privilegesflag enabled- Resource limits: 1 CPU core, 1GB RAM
MCP Containers
User:mcpuser:1001 (non-root)
Security Options:
- Read-only root filesystem
- All capabilities dropped (except
SYS_ADMINfor Playwright) - Seccomp profile enabled
- AppArmor profile:
security/apparmor-mcp-profile no-new-privilegesflag enabled
node,npm,npx(Node.js)uv,uvx,python,python3(Python)git,git-*(Git)dumb-init(Process init)
- All shells (
sh,bash,dash,zsh) - Network tools (
wget,curl,nc,telnet,ssh) - Privilege escalation (
su,sudo)
Seccomp Profile
File:/home/user/Guardway Gateway/security/seccomp-mcp.json
Purpose: Restricts syscalls to reduce kernel attack surface
Default action: Deny (SCMP_ACT_ERRNO)
Allowed syscalls: Only essential syscalls for Node.js/Python processes
- Networking:
socket,connect,bind,listen,accept - File I/O:
read,write,open,close,stat - Process management:
fork,exec,wait,kill
reboot,mount,umount,swapon,swapoffptrace,kexec_load,add_key,request_key
AppArmor Profile
File:/home/user/Guardway Gateway/security/apparmor-mcp-profile
Installation:
Verification
Test container security:Authentication Methods
Guardway Gateway supports five authentication methods with different use cases:- Master Key
- Session Token
- API Key
- Ephemeral Token
- Internal Key
Format: Usage:Security:
sk-master-...Use Case: Full administrative access, initial setupConfiguration:- Uses timing-safe comparison (
crypto.timingSafeEqual) to prevent timing attacks - Should be rotated regularly
- Store in secrets manager (AWS Secrets Manager, HashiCorp Vault, etc.)
- Never commit to version control
Authorization (RBAC)
Role-based access control with three roles:Roles
| Role | Permissions |
|---|---|
| admin | Full access to all endpoints including user/team/provider management |
| developer | Access to inference endpoints (/v1/*), read-only management endpoints |
| read-only | Read-only access to logs, metrics, and configuration |
Role Assignment
Permission Checks
Authorization is enforced at the middleware level:Secret Management
Encryption at Rest
Algorithm: AES-256-GCM (authenticated encryption) Configuration:- Provider API keys
- Webhook secrets
- OrionFence API keys
- OAuth client secrets
Secret Redaction in Logs
All API keys and sensitive headers are automatically redacted:apiKey,api_keyauthorizationpassword,passwdsecret,token*_api_keypatterns
Key Rotation
API Keys:- Generate new master key
- Update
AGSEC_MASTER_KEYenvironment variable - Restart gateway
- Update all admin scripts
Guardrails
Built-in SLM Guardrails
Types:- PII Detection - SSN, credit cards, emails, phone numbers, API keys
- Hate Speech Detection - Toxic content, slurs, threats
- Prompt Injection Detection - Adversarial prompt manipulation
PII Detection
Local (Regex-based):Hate Speech Detection
Prompt Injection Detection
IP Filtering
Keyword Filtering
Audit Logging
Complete audit trail for all administrative and security-relevant actions.Logged Events
- User Management: Create, update, delete users
- Team Management: Create, update, delete teams
- API Key Management: Create, rotate, delete keys
- Provider Management: Add, update, remove providers
- Guardrail Changes: Policy creation, updates, deletions
- Configuration Changes: Routing rules, settings updates
- Authentication Events: Login attempts, session creation
- Authorization Failures: Access denied events
Audit Log Format
Query Audit Logs
Network Security
Docker Network Isolation
All services communicate on private Docker network:TLS/HTTPS Configuration
Production setup (nginx):Firewall Rules
iptables example:Production Security Checklist
Pre-Deployment
- Generate strong master key (32+ characters, random)
- Generate encryption key for secrets (64 hex characters)
- Configure TLS/HTTPS certificates
- Set up secrets manager (AWS Secrets Manager, Vault, etc.)
- Review and configure CORS origins
- Enable audit logging
- Configure network firewall rules
- Set up intrusion detection (Fail2ban, OSSEC, etc.)
Container Security
- Verify all containers run as non-root (UID 1001)
- Confirm read-only filesystems enabled
- Test Seccomp profiles loaded correctly
- Install and verify AppArmor profiles (MCP containers)
- Set resource limits (CPU, memory)
- Enable container health checks
Authentication & Authorization
- Rotate default master key
- Configure session timeout (default: 24 hours)
- Set up API key expiration policy
- Enable RBAC for all users
- Configure MCP access restrictions per key
- Test authentication methods
Guardrails
- Enable PII detection for sensitive data
- Configure hate speech detection
- Enable prompt injection protection
- Set up IP allow/block lists
- Configure keyword filtering
- Test guardrail policies
Network & Infrastructure
- Enable TLS/HTTPS (production)
- Configure reverse proxy (nginx, AWS ALB)
- Set up Web Application Firewall (WAF)
- Enable DDoS protection (CloudFlare, AWS Shield)
- Configure private networks for internal services
- Disable unnecessary ports
Monitoring & Logging
- Enable audit logging
- Set up centralized log aggregation (ELK, CloudWatch)
- Configure security alerts
- Enable OpenTelemetry tracing
- Set up Prometheus metrics
- Configure anomaly detection
Data Protection
- Enable encryption at rest (AES-256-GCM)
- Verify TLS for data in transit
- Configure secret rotation schedule
- Set up Redis authentication
- Enable PostgreSQL SSL connections
- Test backup and recovery procedures
Security Best Practices
1. Principle of Least Privilege
Grant minimum necessary permissions:2. Defense in Depth
Implement multiple security layers:- Container security (non-root, read-only)
- Network security (firewalls, TLS)
- Application security (auth, RBAC)
- Data security (encryption)
- Content security (guardrails)
3. Regular Security Updates
4. Secret Management
5. Monitoring and Alerting
6. Incident Response Plan
- Detection: Monitor logs and alerts
- Containment: Disable compromised keys immediately
- Eradication: Rotate secrets, patch vulnerabilities
- Recovery: Restore from backups if needed
- Lessons Learned: Document and improve
Threat Model
Compromised API Key
Compromised API Key
Attack: Attacker obtains valid API keyMitigations:
- Per-key budget limits (prevent runaway costs)
- Per-key request limits (prevent abuse)
- Rate limiting (slow down attacks)
- Expiration dates (limit lifetime)
- Audit logging (detect unusual activity)
- IP restrictions (limit source IPs)
- Identify compromised key from logs
- Disable key immediately
- Rotate key
- Review audit logs for damage
- Notify affected users
Container Escape
Container Escape
Attack: Attacker escapes container to hostMitigations:
- Non-root user (cannot escalate to root)
- Read-only filesystem (cannot modify binaries)
- Seccomp (blocks dangerous syscalls)
- AppArmor (restricts executables)
- No capabilities (cannot perform privileged operations)
no-new-privileges(prevents privilege escalation)
Prompt Injection
Prompt Injection
Attack: Manipulate LLM via adversarial promptsMitigations:
- Prompt injection detection guardrail
- Input validation
- System prompt isolation
- Output moderation
- “Ignore previous instructions”
- “You are now in developer mode”
- Role manipulation attempts
Data Exfiltration
Data Exfiltration
Attack: Extract sensitive data from requests/responsesMitigations:
- PII detection and redaction
- Encryption at rest
- TLS in transit
- Access logging
- Audit trail
Denial of Service
Denial of Service
Attack: Overwhelm system with requestsMitigations:
- Rate limiting (token bucket algorithm)
- Request size limits
- Resource limits (CPU, memory)
- Connection limits
- Timeout enforcement
Compliance Considerations
SOC 2
Type II Controls:CC6.1 - Logical Access:
- Multi-factor authentication available
- Role-based access control (RBAC)
- API key management with expiration
- Audit logging of access events
- TLS for data in transit
- AES-256-GCM for data at rest
- Encrypted secrets storage
- OpenTelemetry tracing
- Prometheus metrics
- Audit logging
- Security event alerting
PCI DSS
Requirement 3 - Protect Stored Data:
- Encryption at rest (AES-256)
- Secure key management
- Credit card PII detection
- Unique user IDs
- Strong authentication
- RBAC implementation
- Audit trail for all access
- Tamper-proof logs (append-only)
- Log retention policies
HIPAA
Technical Safeguards:§164.312(a)(1) - Access Control:
- Unique user identification
- Emergency access procedure
- Automatic logoff (session timeout)
- Encryption and decryption
- Complete audit logging
- Activity monitoring
- Audit log review
- TLS/HTTPS encryption
- Integrity controls
GDPR
Data Protection Measures:Article 25 - Data Protection by Design:
- PII detection and redaction
- Minimal data retention
- Encryption by default
- Audit logging
- Data flow documentation
- Encryption at rest and in transit
- Pseudonymization capabilities
- Regular security testing
- Security event logging
- Real-time alerting
- Incident response procedures
Additional Resources
- OWASP Top 10
- CIS Docker Benchmark
- NIST 800-190: Container Security
- Docker Security Best Practices
- OWASP LLM Security Top 10
