feat(guardrails): prompt-injection hardening for untrusted intake#19
Merged
Conversation
Ports two construction-time defenses from the factory's guardrail vocabulary (stxkxs/claudium) into fab's prompt assembly — defenses an inference-time content filter doesn't provide: - src/guardrails.ts — normalizeDelimiters() strips Claude reserved tags (<system>, <tool_use>, ...) from untrusted text; spotlight() fences it in a per-call random untrusted-<hex> delimiter the text can't forge. - src/workflows.ts — the untrusted intake brief that seeds the workflow context (executeWorkflow's `context`) is now delimiter-normalized + spotlight-fenced, with a treat-as-data instruction that travels with the context so every role reading it fences the brief as data, not instructions. Raw userPrompt is still used for intake-JSON parsing + branch pre-creation — only the seed context is wrapped. - src/prompts.ts — repo URLs / mount paths / source-dir paths are normalized before inlining into the system prompt. Verified: typecheck, vitest (+5 guardrails tests), build, prettier all green.
97ba55a to
924530f
Compare
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
Ports two construction-time prompt-injection defenses from the factory's guardrail vocabulary (
stxkxs/claudium) into fab's prompt assembly — defenses an inference-time content filter (e.g. Bedrock Guardrails) doesn't provide.Changes
src/guardrails.ts(new) —normalizeDelimiters()strips Claude reserved tags (<system>,<tool_use>, …) from untrusted text;spotlight()fences it in a per-call randomuntrusted-<hex>delimiter the text can't forge.src/workflows.ts— the untrusted intake brief seeding the workflow context (executeWorkflow'scontext, line 669) is now delimiter-normalized + spotlight-fenced, with a treat-as-data instruction that travels with the context so every role fences the brief as data, not instructions. RawuserPromptis still used for intake-JSON parsing + branch pre-creation — only the seed context is wrapped, so nothing downstream breaks.src/prompts.ts— repo URLs / mount paths / source-dir paths normalized before inlining into the system prompt.Verification
npm run lint,npm test(262 pass, +5 guardrails tests),npm run build,npm run format:check— all green.