Keep adversarial or unreviewed corpus additions from becoming authoritative evidence merely because they rank well.
Corpus poisoning: admit evidence before ranking it
Separate relevance from authority
Corpus poisoning changes what the retriever can find. An attacker may add a plausible document that repeats the query terms, cites a fake update or embeds a misleading number, without writing an explicit instruction to the assistant. A high similarity score says the passage resembles the question; it says nothing about who published it or whether its claim is approved. Admit evidence through trusted ingestion metadata before ranking it for a consequential answer. Prompt-injection controls handle instructions inside retrieved text, but a false factual claim can be dangerous even when it contains no command.
Assign trust at ingestion
Capture source owner, collection, reviewer state, document signature or checksum, import channel and revision lineage outside the document body. A sentence inside the document claiming to be 'official' is not proof of authority. Give user uploads and external feeds a lower trust tier until their content is reviewed or corroborated under policy. Apply tenant and lifecycle rules before any trust comparison. Passage provenance should let an investigator trace an answer back to the exact admitted source and revision.
Guard candidate admission
A poisoned page can still consume the top candidate slots even if a downstream generator refuses its claims. Filter or partition sources by trust tier, then set candidate budgets so lower-trust material cannot crowd out the approved corpus. For exploratory search, show unreviewed material with a clear status; for a policy or safety answer, require an approved evidence tier. If a trusted source and an unreviewed source disagree, do not average their text or choose the one with the more fluent explanation. Context packing should preserve source diversity without confusing diversity with authority.
Detect suspicious change patterns
Watch for a burst of new documents that all answer the same rare question, unusual repetition of identifiers, copied authority language, and content whose owner cannot be verified. These signals are review triggers, not automatic proof of attack. Compare new-corpus and previous-corpus answers on stable judged queries, and record which admitted document changed each answer. Quarantine a source by source ID or ingest batch, then rebuild affected candidate stores and caches. Ingestion controls should make quarantine and deletion repeatable.
Evaluate the admission boundary
Test harmless user uploads, misleading but relevant documents, forged update notices and contradictions between two approved sources. Judge whether the system finds authorized evidence, labels uncertainty and abstains when approved evidence conflicts. A detector that blocks every new document may reduce attack success while destroying useful recall. Review false positives by source tier and query slice. Counterfactual tests can reveal when an answer changes only because a low-trust passage was introduced.
Worked contract
from dataclasses import dataclass
@dataclass(frozen=True)
class EvidenceCandidate:
source_id: str
policy_key: str
value: str
similarity: float
verified_origin: bool
approved_for_answers: bool
def admitted_value(candidates: list[EvidenceCandidate], policy_key: str) -> str | None:
eligible = [candidate for candidate in candidates
if candidate.policy_key == policy_key
and candidate.verified_origin
and candidate.approved_for_answers]
values = {candidate.value for candidate in eligible}
if len(values) > 1:
raise ValueError("approved sources conflict; require review")
return next(iter(values)) if values else None
records = [
EvidenceCandidate("signed-manual-r4", "pump-p47-limit", "83 kPa", .71, True, True),
EvidenceCandidate("unreviewed-upload-9", "pump-p47-limit", "67 kPa", .99, False, False),
]
assert admitted_value(records, "pump-p47-limit") == "83 kPa"
assert admitted_value(records, "unknown-policy") is NonePerformance and operating cost
Admission scans C candidates in O(C) time and stores at most O(C) distinct admitted values. In production, source status should usually be indexed so unapproved material is excluded before expensive retrieval and reranking. Provenance verification, review queues and quarantine rebuilds add operational cost, but accepting a high-scoring forged source can corrupt every downstream answer that cites it. Keep metadata server-controlled and audit changes to approval state.
Common Mistakes
- Reading an 'official' label from document text as if it were verified metadata.
- Letting low-trust candidates fill the entire top-K window before filtering.
- Assuming a prompt-injection detector also catches false factual claims.
- Picking one of two conflicting approved claims solely by similarity score.
Validation drill
Add 37 synthetic unreviewed documents to a judged corpus. Record which enter the candidate pool, which are admitted for answers, how many legitimate passages are displaced and whether conflicts trigger review.
