Security · Defense in Depth

Security Architecture

Every layer of the Condrox AI system is built with explicit security controls. From input validation to container isolation, from API key authentication to Kubernetes pod security, the system defaults to blocking on error and logs every security decision.

Security Principles

Four principles guide every security decision in the system. They are not aspirational. They are enforced in code and verified by tests.

PrincipleImplementation
Defense in depthMultiple layers of security from input to output. Input validation, authentication, rate limiting, output sanitization, and container isolation all operate independently.
Least privilegeDocker non-root user (UID 1000). Kubernetes securityContext with runAsNonRoot. API key auth with minimum required scope per endpoint group.
Fail safeSecurity checks default to blocking on error, not allowing. If the SecurityEngine throws, the request is rejected. If auth fails to resolve, access is denied.
AuditableAll security decisions are logged. All API calls require authentication. No endpoint is anonymous by default.

Authentication

API key authentication is the single entry point for every protected endpoint. Keys are never stored in plaintext.

# Auth flow
1. Extract X-API-Key header
2. Look up user record in SQLite
3. bcrypt.verify(provided_key, stored_hash)
4. secrets.compare_digest on resolved key
5. Attach user context to request
6. Reject with 401 if any step fails

Rate Limiting

The slowapi library throttles requests at the application layer. Two tiers of limits apply depending on endpoint cost.

ScopeLimitRationale
Global (all endpoints)100 requests / minuteDefault ceiling for any authenticated client
/process endpoint30 requests / minuteStricter limit on compute-heavy cognitive pipeline invocations

When a client exceeds the limit, the API returns 429 Too Many Requests with a Retry-After header indicating how many seconds to wait. Both limits are configurable via environment variables, so operators can tune them for their deployment without code changes.

CORS

Cross-origin requests are controlled at the framework layer. Nothing is open by default.

Input Security

File: SecurityEngine.check_input()

Every user input passes through the SecurityEngine before it reaches the cognitive pipeline. The engine runs pattern-based detection across five threat categories.

Threat CategoryDetected Patterns
Prompt injection"ignore previous instructions", "you are now", "system prompt", and similar override attempts
SQL injectionUnion-based, boolean-based, and time-based injection patterns
XSSScript tag injection, event handler attributes, javascript: URIs
Path traversal../ sequences, absolute path escapes, encoded traversal variants
Command injectionShell metacharacters, command chaining, subshell invocation patterns

All detected threats are logged with the matched pattern and the raw input hash. The request is blocked. No partial processing occurs.

Output Security

File: SecurityEngine.check_output()

Output security operates on a different threat model than input security. The system checks generated output before it reaches the client. This runs as Stage 12 in the 18-stage pipeline.

CheckWhat It Catches
PII detectionEmail addresses, phone numbers, credit card numbers (pattern-matched, not heuristic)
Secret leakageAPI keys, bearer tokens, passwords, and other credential patterns in generated text
Prompt injection echoChecks whether an input injection attempt is reflected in the output, which would indicate the pipeline was subverted

Input and output security are separate by design. A clean input does not guarantee a clean output. Both must pass independently.

Docker Security

The container image is built to minimize attack surface. Build tools and development dependencies never reach the runtime image.

Kubernetes Security

Pod-level security controls enforce isolation and resource boundaries in production deployments.

ControlConfiguration
securityContextrunAsNonRoot: true, runAsUser: 1000, readOnlyRootFilesystem: true. The pod filesystem is immutable at runtime.
NetworkPolicyIngress restricted to the API port (8000) only. Egress restricted to required services (database, knowledge store). No wildcard egress.
Resource limitsCPU and memory requests and limits are defined. The pod cannot consume unbounded resources on the node.
Pod security standardsRestricted profile enforced. Privilege escalation is blocked. Host namespaces are disabled.
Service accountDedicated service account with minimum required permissions. No cluster-admin, no wildcard RBAC rules.

CI/CD Security

Security scans run on every pull request and every push to the main branch. No merge lands without passing all checks.

ToolTypeScope
BanditSAST (Static Application Security Testing)Python source code. Detects common security issues like assert statements, hardcoded passwords, unsafe YAML loading.
TrivyContainer vulnerability scanningRuns on every container build. Scans the final image for known CVEs in OS packages and Python dependencies.
GitHub ActionsCI pipelineSecurity scans run on every pull request and push. Failures block merge.
Dependency reviewSupply chainAutomated checks for known vulnerabilities in new dependencies added to requirements files.
Secret scanningCredential leakageGitHub's built-in secret scanner. Detects API keys, tokens, and private keys committed to the repository.

Ethics and Content Policy

File: EthicsEngine

Content policy checks run on both input and output. The EthicsEngine evaluates generated content for harmful, biased, or inappropriate material before it reaches the user.

Security Testing

Security is verified by automated tests on every CI run. The test suite covers authentication, rate limiting, CORS, input injection, and output PII detection.

Test GroupCountCoverage
API security tests11Auth required, invalid keys, rate limiting, CORS headers
Output security tests5PII detection, secret leakage, prompt injection echo
Total16All pass on every CI run

Tests cover the negative paths. Missing authentication returns 401. Invalid keys return 401. Rate limit violations return 429. Input injection attempts are blocked. Output PII is caught. These tests run on every pull request. A regression in any of them blocks the merge.

Known Limitations

No security architecture is finished. The following limitations are documented here so operators can plan around them.

LimitationCurrent StateMitigation
No OAuth2 or JWT supportAPI key authentication only. No token refresh, no scoped grants, no delegation.Use an API gateway or reverse proxy with OAuth2 support in front of the application.
No TLS termination in the applicationThe application serves HTTP. TLS is not handled in process.Terminate TLS at the reverse proxy or load balancer. The application never sees the private key.
No audit log persistenceSecurity logs go to stdout. They are not written to a persistent store by the application.Forward stdout to a log aggregation service (ELK, Loki, CloudWatch). Retention is handled at the infrastructure layer.
Rate limiting is per-processEach worker process maintains its own counter. A client hitting multiple workers gets an effective limit multiplied by the worker count.Use an external rate limiter (Redis, API gateway) for distributed enforcement in multi-replica deployments.

Responsible Disclosure Policy

If you believe you have found a security vulnerability in Condrox AI, the pre-release chat, or this website, please report it responsibly. We take all reports seriously and will work with you to understand and address the issue.

How to Report

What We Commit To

Scope

This policy applies to:

This policy does not apply to:

Rewards

We do not currently operate a paid bug bounty program. Valid vulnerability reports will be acknowledged publicly (with your permission) and we will work with you on coordinated disclosure. As the project matures, a formal bug bounty program may be introduced.