Introduction¶
The DSH plugin mechanism allows hooking new capabilities into the execution flow. For LLM streaming responses, a practical issue is that model outputs arrive in shards at token granularity. While a single delta may appear short and benign, the combined output could contain control characters, protocol markers, anomalous scripts, or spam keywords.
dsh-llm-injection-filter addresses this problem. It hooks into the llm/stream waterfall to inspect and handle responses before they enter the agent, without modifying any runtime source code.
What is this¶
The following section outlines the basic positioning of this plugin.
- Plugin Name:
dsh-llm-injection-filter - Maintainer:
XiaoYuOvO - License:
MIT - Runtime Environment:
Node >=18 - Delivery Form: Dynamic plugin / npm package, pure JS, no imports, no runtime dependencies
- Scope: Hooks into the
llm/streamwaterfall, effective for all adapters - Core Objective: Detect suspected prompt injection / contamination and handle it based on configuration
It is automatically added to dsh.profile.bundles via dsh.bundle.patch and is mounted through the DSH plugin mechanism upon installation.
Core Functions¶
Track A: Hard Block on Rare Scripts¶
Track A handles script-level anomalies.
When Unicode characters not belonging to the allowed script set appear in the model output, the plugin interrupts the stream immediately. Track A has the highest priority; when triggered, it does not perform strip / reject but directly interrupts the response stream.
The default allowed scripts are:
Latin
Han
Common
Inherited
Greek
This means the default allowed set does not include scripts like Japanese Kana, Korean Hangul, or Russian Cyrillic. If legitimate output contains these scripts, it will be hard-blocked by Track A. You can allow the corresponding scripts via allowedScripts.
maxScanLen only constrains the segment-by-segment scanning/replacement of Track B; Track A has no upper limit.
Track B: Scoring Rule Disposition¶
Track B processes content based on scoring rules. Rule types include:
CTRL
PROTO
SCRIPT
KW
It also supports combined bonuses. The trigger threshold is minScore, with a default value of:
100
Track B supports the following disposition modes:
audit
strip
reject
There are two restrictions:
KWnever triggers alone.SCRIPTis only counted towards the total score if it co-occurs with at least onePROTO/CTRL.
The reject mode relies on block-end carrying the complete arguments. In delta-only streams that do not send block-end, tool-call arguments cannot be rewritten as a whole block; in this case, only auditing is performed.
Auditing and WebUI¶
The plugin outputs structured audit logs with the following rule types:
HARD_BLOCK | CTRL | PROTO | SCRIPT | KW
Interception records are not persisted to disk; they are output to the structured logging channel via the plugin fiber. The in-process ring buffer is limited by maxRecords.
In the WebUI, you can navigate to:
Settings → LLM Injection Filter
to query and adjust configurations. The settings page supports real-time configuration adjustments, with changes taking effect immediately without requiring a restart.
Please note that configuration state is persisted in localStorage. After a Host restart, configurations revert to default values and must be saved again in the settings page.
When stopping/unloading the plugin, listeners are automatically cleaned up along with the plugin fiber, leaving no timers or global subscriptions behind.
Installation and Activation¶
Below are several installation methods.
Install from GitHub default branch¶
dsh plugin --profile web add github:XiaoYuOvO/dsh-llm-injection-filter
Install by tag¶
Installing by tag allows locking to a verified version.
dsh plugin --profile web add github:XiaoYuOvO/dsh-llm-injection-filter#v1.1.0
Install via local link¶
dsh plugin --profile web add "link:G:/DEEPSE~1/data/dsh/plugins/LLM-IN~1"
Verify Installation¶
After installation, execute:
dsh --profile web --dump-config
This step is used to confirm that the plugin has been included in the current profile’s configuration / bundle composition.
Typical Usage¶
After installation, you can first open the WebUI settings page to view the configuration.
Settings → LLM Injection Filter
Configurable items include:
CFG.enabled
CFG.hardBlockRareScripts
CFG.allowedScripts
CFG.mode
CFG.minScore
CFG.applyToProviders
CFG.applyToModels
CFG.skipProviders
CFG.skipModels
CFG.maxRecords
CFG.extraKeywords
CFG.maxScanLen
CFG.maxSampleLen
CFG.recordMaxLen
Common adjustment paths are as follows:
- First, confirm whether
CFG.enabledis turned on. - If legitimate output contains scripts like Japanese, Korean, or Russian, append the corresponding scripts to
CFG.allowedScripts. - If you only want to observe without modifying output, set
CFG.modetoaudit. - If you need to raise the trigger threshold, adjust
CFG.minScore. - If you only want to inspect specific providers/models, configure
CFG.applyToProvidersandCFG.applyToModels. - If you need to skip certain providers/models, configure
CFG.skipProvidersandCFG.skipModels. - Query recent interception records in the WebUI to confirm rule hit situations.
Use Cases and Notes¶
This plugin is suitable for users utilizing DSH’s LLM streaming responses who wish to perform a layer of security filtering before responses enter the agent.
Please note before use:
- The plugin runs with the current DSH process privileges; check the source code and license before installation.
- Track A’s default allowed scripts are relatively strict, not including Japanese Kana, Korean Hangul, Russian Cyrillic, etc., by default.
- Track B only triggers when the total score reaches
minScore. KWdoes not trigger alone;SCRIPTis only counted if it co-occurs withPROTO/CTRL.rejectmode relies on completearguments; for some delta-only streams, only auditing is possible.- Interception records are not persisted to disk; they are only kept in the in-process ring buffer, limited by
maxRecords. - WebUI configurations are saved in
localStorageand must be saved again after a Host restart.
Conclusion¶
dsh-llm-injection-filter provides injection/contamination filtering capabilities at the DSH LLM response stream level. Its core consists of Track A’s hard blocking of rare scripts and Track B’s scoring rule disposition, complemented by structured audit logs and the WebUI settings page.
GitHub Repository Address:
https://github.com/XiaoYuOvO/dsh-llm-injection-filter
If you need to find it in the DSH community directory, you can search for the plugin name:
dsh-llm-injection-filter