Security hardening: prompt guardrails, input validation, CORS, error handling#10
Open
BrandonS7 wants to merge 1 commit intoBirmingham-AI:mainfrom
Open
Security hardening: prompt guardrails, input validation, CORS, error handling#10BrandonS7 wants to merge 1 commit intoBirmingham-AI:mainfrom
BrandonS7 wants to merge 1 commit intoBirmingham-AI:mainfrom
Conversation
… error sanitization
454be89 to
f141d11
Compare
ldanielkeysys
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Addresses several security gaps found during code review:
1. Prompt injection guardrails
Added a
Boundariessection to bothcarrie.txtandcarrie_voice.txtsystem prompts. This tells the model to:2. Input validation
max_length=4000to question field (prevents prompt stuffing / cost attacks)max_length=50to conversation history (prevents unbounded context injection)3. CORS configuration
Replaced hardcoded
allow_origins=["*"]with configurableALLOWED_ORIGINSenv var. Defaults to*for backward compatibility, but can now be locked down per environment.4. Error message sanitization
All
exceptblocks now log full error details server-side vialogger.error()but return generic"Internal server error"to clients. Previously,str(e)was returned directly, which could leak internal paths, stack traces, or API provider details.5. Conversation history context boundary
Added explicit boundary marker in
streaming_agent.pyso the model treats injected conversation history as user-provided content rather than system instructions. Mitigates a class of indirect prompt injection where crafted history messages could override system behavior.All changes are minimal and surgical. No new dependencies, no refactoring, no behavior changes beyond the security improvements.