Skip to main content

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)

RequirementPriorityOWASPDescription
mTLS supportP0A01Client certificate authentication for service-to-service
JWT validationP0A01Bearer token validation with JWKS
API key authP1A01Fallback authentication mechanism
Token refreshP1A01Support for token refresh flow
Auth bypass preventionP0A01No 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)

RequirementPriorityOWASPDescription
Namespace isolationP0A01Clients can only access their namespaces
Role-based accessP0A01Admin vs operator vs reader roles
Per-operation authzP1A01Read vs write permissions
Audit loggingP0A09Log 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)

InputValidationMax SizePattern
NamespaceDNS-safe63 chars^[a-z][a-z0-9-]*[a-z0-9]$
KeyUTF-8, no null bytes1KBConfigurable
ValueBinary safe10MBConfigurable
TTLPositive integerN/A0-31536000 (1 year)
MetadataJSON64KBValid 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)

RequirementPriorityDescription
TLS 1.3 minimumP0No TLS 1.2 or below
Strong cipher suitesP0AEAD ciphers only
Certificate rotationP1Support hot reload
ALPN negotiationP1h2 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 TypeDefaultScopeDescription
Requests/second1000Per clientOverall request rate
Connections100Per client IPMax concurrent connections
Bandwidth100 MB/sPer namespaceData transfer rate
Payload size10 MBPer requestMax 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)

MetricTypeLabelsDescription
proxy_requests_totalCountermethod, status, namespaceRequest count
proxy_request_duration_secondsHistogrammethod, namespaceLatency
proxy_auth_failures_totalCounterreasonAuth failure count
proxy_active_connectionsGaugeCurrent 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)

RequirementDescription
No stack tracesNever expose internal errors to clients
Generic error messages"Invalid request" not "SQL error at line..."
Error codesConsistent error codes for client handling
LoggingFull 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)

RequirementDescription
No unsafe codeAvoid unsafe blocks unless absolutely necessary
Bounded allocationsUse bounded channels and pools
Timeout all operationsPrevent resource exhaustion
Graceful degradationShed load under pressure

Security Test Plan

Unit Tests

CategoryTest CasesCoverage Target
AuthToken validation, mTLS verification90%
Input validationBoundary values, injection attempts95%
Rate limitingToken bucket behavior, overflow85%
Error handlingSafe error mapping90%

Integration Tests

TestDescription
E2E auth flowFull authentication cycle
Namespace isolationCross-tenant access prevention
TLS negotiationCertificate verification
Backend failoverError handling on backend failure

Security Tests (Penetration)

TestOWASPDescription
Auth bypassA01Attempt unauthenticated access
JWT manipulationA01Algorithm confusion, expired tokens
Input fuzzingA03Malformed requests, oversized payloads
DoS resilienceA07Connection exhaustion, slowloris
TLS downgradeA02Protocol version negotiation

Compliance Checklist

Before Implementation

  • Security requirements reviewed and approved
  • Threat model documented
  • Test plan approved

During Implementation

  • No unsafe code 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

PurposeCrateNotes
gRPCtonicWith TLS support
JWTjsonwebtokenVerify only, no signing
TLSrustlsMemory-safe TLS
Rate limitinggovernorToken bucket implementation
MetricsprometheusStandard metrics format
LoggingtracingStructured logging

Crates to Avoid

CrateReason
opensslMemory safety concerns
Unmaintained cratesSecurity 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:

  1. Authentication at the transport layer (mTLS) AND application layer (JWT)
  2. Strict input validation before any processing
  3. Namespace-based authorization for multi-tenancy
  4. Comprehensive observability for security monitoring

This document should be updated as the implementation progresses and specific design decisions are made.