Skip to content

security: harden LLM prompts and infrastructure secrets#29

Merged
marinone94 merged 1 commit into
mainfrom
fix/llm-infra-hardening
Mar 30, 2026
Merged

security: harden LLM prompts and infrastructure secrets#29
marinone94 merged 1 commit into
mainfrom
fix/llm-infra-hardening

Conversation

@marinone94

Copy link
Copy Markdown
Owner

Summary

  • LLM-H1: Wrap user queries with wrap_external_content in query_agent.py
  • LLM-H2: Sanitize dataset content + wrap query/results in reranker.py
  • SEC-H5: Add Qdrant API key env var to docker-compose.yml
  • SEC-H6 + SEC-M7: Add auth/billing/CORS/Qdrant secrets to Helm chart (values, secret template, deployment env vars)

Files changed

  • agents/query_agent.py — wrap user query in safety boundary markers
  • agents/reranker.py — sanitize snippets + wrap query and results block
  • docker-compose.ymlQDRANT__SERVICE__API_KEY env var
  • deploy/helm/cherry-evals/values.yaml — auth/billing/CORS/Qdrant config keys, remove hardcoded password
  • deploy/helm/cherry-evals/templates/secret.yaml — Supabase, Polar, Qdrant secrets
  • deploy/helm/cherry-evals/templates/deployment-api.yaml — all new env vars
  • tests/unit/test_prompt_safety.py — 18 new tests

Test plan

  • uv run pytest passes (595 passed, 1 skipped)
  • Prompt functions include UNTRUSTED_DATA boundary markers
  • Injection patterns stripped from dataset content
  • Helm templates render with new values

🤖 Generated with Claude Code

- Wrap raw user queries in UNTRUSTED_DATA boundary markers in query_agent.py
  and reranker.py using wrap_external_content from core.safety.content_wrapper
- Sanitize dataset content (question/answer/subject snippets) in reranker
  prompts using sanitize_prompt_literal to strip injection patterns and
  Unicode control characters
- Add QDRANT__SERVICE__API_KEY env var support to docker-compose.yml (SEC-H5)
- Replace hardcoded postgres password in Helm values.yaml with empty required
  placeholder (SEC-H6)
- Add auth/billing/CORS/Qdrant config fields to Helm values.yaml (SEC-M7)
- Expose SUPABASE_URL, SUPABASE_JWT_SECRET, POLAR_WEBHOOK_SECRET, QDRANT_API_KEY
  as k8s Secrets in Helm secret.yaml and deployment-api.yaml
- Add 18 unit tests in tests/unit/test_prompt_safety.py covering injection
  stripping, boundary marker wrapping, and unicode control char removal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marinone94
marinone94 merged commit 4b44bab into main Mar 30, 2026
4 checks passed
marinone94 added a commit that referenced this pull request Mar 30, 2026
30/46 findings now fixed. All Critical and High security vulnerabilities resolved.
Remaining items: GDPR endpoints, DPAs, rate limiter Redis, Langfuse instrumentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
marinone94 pushed a commit that referenced this pull request Mar 30, 2026
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant