Prism Proxy Security Requirements and Assessment Plan
Executive Summary
This memo defines the security requirements and assessment framework for the Prism Proxy (Rust), the high-performance data access gateway that routes client requests to backend drivers. As the proxy is the primary entry point for all client traffic, it requires comprehensive security controls.
Status: The proxy is planned but not yet implemented. This document serves as security requirements for the implementation phase.
Architecture Context
+-------------------+ +----------------+ +------------------+
| Client Apps | ---->| Prism Proxy | ---->| Backend Drivers |
| (gRPC clients) | | (Rust/tonic) | | (Go plugins) |
+-------------------+ +----------------+ +------------------+
| | |
v v v
mTLS Auth Rate Limiting Redis, NATS
JWT validation Connection Pool PostgreSQL, etc.
Security Requirements
1. Authentication (Required)
| Requirement | Priority | OWASP | Description |
|---|---|---|---|
| mTLS support | P0 | A01 | Client certificate authentication for service-to-service |
| JWT validation | P0 | A01 | Bearer token validation with JWKS |
| API key auth | P1 | A01 | Fallback authentication mechanism |
| Token refresh | P1 | A01 | Support for token refresh flow |
| Auth bypass prevention | P0 | A01 | No unauthenticated access to data endpoints |
Implementation Guidance:
// Suggested authentication interceptor pattern
pub struct AuthInterceptor {
jwks_cache: JWKSCache,
mtls_verifier: MtlsVerifier,
}
impl Interceptor for AuthInterceptor {
fn call(&mut self, request: Request<()>) -> Result<Request<()>, Status> {
// 1. Check mTLS certificate if present
// 2. Validate JWT Bearer token
// 3. Extract claims and attach to request context
// 4. Return Unauthenticated on failure
}
}
2. Authorization (Required)
| Requirement | Priority | OWASP | Description |
|---|---|---|---|
| Namespace isolation | P0 | A01 | Clients can only access their namespaces |
| Role-based access | P0 | A01 | Admin vs operator vs reader roles |
| Per-operation authz | P1 | A01 | Read vs write permissions |
| Audit logging | P0 | A09 | Log all access decisions |
Implementation Guidance:
// Namespace-scoped authorization check
async fn authorize_request(
claims: &UserClaims,
namespace: &str,
operation: Operation,
) -> Result<(), Status> {
// 1. Verify namespace ownership or delegation
// 2. Check role permissions for operation
// 3. Log access decision
}
3. Input Validation (Required)
| Input | Validation | Max Size | Pattern |
|---|---|---|---|
| Namespace | DNS-safe | 63 chars | ^[a-z][a-z0-9-]*[a-z0-9]$ |
| Key | UTF-8, no null bytes | 1KB | Configurable |
| Value | Binary safe | 10MB | Configurable |
| TTL | Positive integer | N/A | 0-31536000 (1 year) |
| Metadata | JSON | 64KB | Valid JSON |
Implementation Guidance:
// Request validation at ingress
fn validate_request(req: &DataRequest) -> Result<(), ValidationError> {
validate_namespace(&req.namespace)?;
validate_key(&req.key, max_key_size)?;
validate_value(&req.value, max_value_size)?;
validate_ttl(req.ttl)?;
Ok(())
}
4. Transport Security (Required)
| Requirement | Priority | Description |
|---|---|---|
| TLS 1.3 minimum | P0 | No TLS 1.2 or below |
| Strong cipher suites | P0 | AEAD ciphers only |
| Certificate rotation | P1 | Support hot reload |
| ALPN negotiation | P1 | h2 protocol negotiation |
Implementation Guidance:
// TLS configuration for tonic
let tls_config = ServerTlsConfig::new()
.identity(identity)
.client_ca_root(client_ca) // For mTLS
.with_protocol_versions(&[ProtocolVersion::TLSv1_3])
.with_ciphersuites(&[
CipherSuite::TLS13_AES_256_GCM_SHA384,
CipherSuite::TLS13_CHACHA20_POLY1305_SHA256,
]);
5. Rate Limiting (Required)
| Limit Type | Default | Scope | Description |
|---|---|---|---|
| Requests/second | 1000 | Per client | Overall request rate |
| Connections | 100 | Per client IP | Max concurrent connections |
| Bandwidth | 100 MB/s | Per namespace | Data transfer rate |
| Payload size | 10 MB | Per request | Max request body |
Implementation Guidance:
// Token bucket rate limiter
pub struct RateLimiter {
buckets: DashMap<ClientId, TokenBucket>,
config: RateLimitConfig,
}
impl RateLimiter {
pub fn check(&self, client: &ClientId) -> Result<(), RateLimitExceeded> {
// 1. Get or create bucket for client
// 2. Try to consume token
// 3. Return remaining quota in headers
}
}
6. Observability (Required)
| Metric | Type | Labels | Description |
|---|---|---|---|
proxy_requests_total | Counter | method, status, namespace | Request count |
proxy_request_duration_seconds | Histogram | method, namespace | Latency |
proxy_auth_failures_total | Counter | reason | Auth failure count |
proxy_active_connections | Gauge | Current connections |
Implementation Guidance:
// Prometheus metrics
lazy_static! {
static ref REQUEST_COUNTER: IntCounterVec = register_int_counter_vec!(
"proxy_requests_total",
"Total requests processed",
&["method", "status", "namespace"]
).unwrap();
}
7. Error Handling (Required)
| Requirement | Description |
|---|---|
| No stack traces | Never expose internal errors to clients |
| Generic error messages | "Invalid request" not "SQL error at line..." |
| Error codes | Consistent error codes for client handling |
| Logging | Full details in server logs only |
Implementation Guidance:
// Safe error mapping
fn map_error(err: InternalError) -> Status {
// Log full error internally
tracing::error!(?err, "Internal error");
// Return safe error to client
match err {
InternalError::NotFound => Status::not_found("Resource not found"),
InternalError::Unauthorized => Status::unauthenticated("Authentication required"),
_ => Status::internal("Internal server error"),
}
}
8. Memory Safety (Rust-specific)
| Requirement | Description |
|---|---|
| No unsafe code | Avoid unsafe blocks unless absolutely necessary |
| Bounded allocations | Use bounded channels and pools |
| Timeout all operations | Prevent resource exhaustion |
| Graceful degradation | Shed load under pressure |
Security Test Plan
Unit Tests
| Category | Test Cases | Coverage Target |
|---|---|---|
| Auth | Token validation, mTLS verification | 90% |
| Input validation | Boundary values, injection attempts | 95% |
| Rate limiting | Token bucket behavior, overflow | 85% |
| Error handling | Safe error mapping | 90% |
Integration Tests
| Test | Description |
|---|---|
| E2E auth flow | Full authentication cycle |
| Namespace isolation | Cross-tenant access prevention |
| TLS negotiation | Certificate verification |
| Backend failover | Error handling on backend failure |
Security Tests (Penetration)
| Test | OWASP | Description |
|---|---|---|
| Auth bypass | A01 | Attempt unauthenticated access |
| JWT manipulation | A01 | Algorithm confusion, expired tokens |
| Input fuzzing | A03 | Malformed requests, oversized payloads |
| DoS resilience | A07 | Connection exhaustion, slowloris |
| TLS downgrade | A02 | Protocol version negotiation |
Compliance Checklist
Before Implementation
- Security requirements reviewed and approved
- Threat model documented
- Test plan approved
During Implementation
- No
unsafecode without review - All inputs validated at ingress
- All errors mapped to safe responses
- Metrics instrumented
Before Release
- Security test suite passing
- Penetration test completed
- Dependency audit clean
- Security documentation updated
Dependencies and Libraries
Recommended Crates
| Purpose | Crate | Notes |
|---|---|---|
| gRPC | tonic | With TLS support |
| JWT | jsonwebtoken | Verify only, no signing |
| TLS | rustls | Memory-safe TLS |
| Rate limiting | governor | Token bucket implementation |
| Metrics | prometheus | Standard metrics format |
| Logging | tracing | Structured logging |
Crates to Avoid
| Crate | Reason |
|---|---|
openssl | Memory safety concerns |
| Unmaintained crates | Security patches delayed |
Conclusion
This document defines the security requirements for the Prism Proxy implementation. The proxy is a critical security boundary and must implement defense-in-depth with multiple layers of protection.
Key priorities:
- Authentication at the transport layer (mTLS) AND application layer (JWT)
- Strict input validation before any processing
- Namespace-based authorization for multi-tenancy
- Comprehensive observability for security monitoring
This document should be updated as the implementation progresses and specific design decisions are made.