Deterministic advisor prompt-injection gate (D-0048) #123
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/advisor-injection-gate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What does this PR do?
Adds a deterministic prompt-injection gate for the local-model advisor (ADR D-0048), the prerequisite D-0042 required before any de-escalation because both candidate models are prompt-injectable.
A detector scans only the untrusted observed data the advisor would hand to the model (incident evidence descriptions and extracted event strings, the prompt variables marked
UntrustedObservedData), never the trusted base fields. It matches two tiers of patterns:LocalModelAdvisorBaseInjectionPatterns): six categories - InstructionOverride, RoleOrSystemImpersonation, OutputControlHijack, DelimiterOrFenceBreakout, EncodedPayload, ExfiltrationOrToolAbuse - seeded from a catalogue produced by a second model (Fable-5) and curated for precision against genuine security-incident text.local_model_advisor_injection_patterns) edited on/configuration(step-up gated, audited). Operators can add and validate extra patterns but cannot edit, disable, or remove any base pattern, so the control cannot be weakened from the UI. Invalid stored rows are skipped without throwing.A new
InjectionActionsetting selects the behaviour on a positive detection:RecordOnlyruns the consult and records the detection, orSkipAdvisor(default) skips the model call entirely so the deterministic base classification stands. Either way the detection is recorded on the consult asInjectionDetected,AdvisorSkippedForInjection, and a matched-category JSON column, and surfaced on/advisorand/api/v1/advisor. An escalating flagged consult (only possible underRecordOnly) also carries an[advisor]injection reason within the existing two-slot reason cap. The detector runs before the response cache (D-0046) and ensemble (D-0047), and the escalate-only clamp (D-0042) remains enforced on every path.How was this tested?
dotnet build- 0 errors, 0 warningsdotnet test- 916 pass, 0 fail, 0 skip (+18 from 898)Checklist