All 8 injection samples passed the offline tests, but one obfuscated sample was deliberately allowed through. This shows that prompt-injection protection cannot be achieved with a keyword blacklist alone. When AI applications go live, security capabilities must become part of the engineering process rather than remain confined to system prompts.
What this is
Prompt injection occurs when external input tries to alter a model’s original task, for example by instructing it to ignore system directives, switch roles, or reveal internal configuration. It is especially common after an AI application connects to web search or an enterprise knowledge base, because the content read by the model may contain malicious commands.
The article adopts a two-layer defense. The first layer filters obvious attacks before the model is invoked. Requests that trigger a rule are rejected immediately, so the model never runs and incurs no inference cost. The second layer inspects model output and replaces sensitive content, such as keys or system prompts, with safe messages. The two layers are not redundant: one controls the attack entry point, while the other limits the consequences of information leakage.
The accompanying code also includes a continuously updated injection test set. To its credit, the test does not disguise a known bypass as a success: the pinyin-obfuscated sample INJ-08 is marked as expected to pass, explicitly documenting that rule-based filtering alone cannot cover every variant.
Industry view
Our judgment is that this approach is suitable as the minimum configuration for productionizing AI applications. Input filtering can reduce inference costs, while output validation provides a backstop against more subtle leaks. Together, they are far more reliable than merely asking the model not to be attacked. The practice of continuously iterating on the test set also aligns more closely with real-world security engineering.
The risks are equally clear. Keyword and pattern matching naturally produce both false negatives and false positives: attackers can change encodings, tone, and context, and defenders have difficulty enumerating every possibility. The article’s “better to falsely block” approach may also harm the normal user experience, particularly when legitimate questions about system prompts or access controls are intercepted. More importantly, output validation can only recognize known leakage patterns and may not be effective against new types of attacks.
Therefore, a two-layer defense cannot replace permission isolation, key custody, and least-privilege authorization. The system prompt itself should not be treated as a security boundary. Once the model exposes it, excessive permissions remain the hardest problem to remedy.
Impact on regular people
For enterprise IT: As enterprises deploy customer-service systems, knowledge-base assistants, and similar applications, security requirements are shifting from prompt guidelines toward code, testing, and permission management. Existing systems need to examine whether external content can trigger privilege escalation and whether model outputs contain keys or internal configuration.
For workplace users: People who frequently use AI assistants will be more likely to encounter suspicious documents and deceptive instructions. When handling contracts, customer data, or internal files, users should avoid pasting sensitive information directly and watch for abnormal role changes or leaked content in model responses.
For the consumer market: Office software, customer-service products, and smart devices with AI features will gradually add this kind of security protection, but false positives and bypasses may still occur. Consumers may not receive a completely risk-free experience; instead, multiple layers will intercept attack paths and keep risks within a certain range.