dsh-redteam-model
SeaOf0
基于dsh web实现的多种模式,目的是服务于redteam进行授权的安全研究,覆盖渗透测试、红队评估、代码审计等范围领域,请勿用于非法行为。(允许二开,赋予模块各位自己的业务逻辑,方法论只有自己熟练的才好用,好的方法论=好的生态)
huangzuting/dsh-plugin-sql-security-validate
AI SQL 权限校验拦截插件 — DeepSeek Harness 通用 AI 数据库权限管控插件。 拦截智能体(Agent)生成的越权 SQL:不静默改写、直接拒绝执行,并把结构化权限 原因返回给模型,让模型自主剔除越权字段、更换统计口径,或用自然语言向用户解释权限不足。 插件 ID:dsh-plugin-sql-security-validate 适用框架:DeepSeek Harness(Cordis) 适配版本:DSH >= 0.1.x(本仓库验证于 0.2.0-rc.1) 开源协议:MIT
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:huangzuting/dsh-plugin-sql-security-validate
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
AI SQL permission guard for DeepSeek Harness — a general-purpose permission layer for agent-driven database access.
It intercepts SQL an agent generates that exceeds its permissions and refuses to execute it rather than silently rewriting it, returning a structured permission reason to the model. The agent can then drop the offending column, switch to an allowed aggregation, or explain the limitation to the user in plain language.
dsh-plugin-sql-security-validate| Problem | What this plugin does |
|---|---|
| An agent writes SQL that reads tables or columns it should not | Parses every resource through a real AST; a policy hit refuses execution |
| The error text is vague, so the question-answering loop breaks | The refusal carries SQL_PERMISSION_DENIED plus the exact refused resources |
| Silent rewriting makes the agent believe the data is complete | Never rewrites SQL; a refusal is explicit |
| Light personal use versus strict enterprise deployment | Every hardening option is off by default; enable what production needs |
| Another plugin overrides the refusal later in the chain | Optional monotonic guard ctx.tools.guard() makes the refusal final |
DESCRIBE / SHOW CREATE TABLE
are governed per table rather than refused outright. You can inspect the
shape of a table you are allowed to read, and not one you are not.Install the bundle from the DSH Web GUI under Plugin Market or Settings → Plugins, or ask an agent in a session:
Install the bundle from C:\path\to\dsh-plugin-sql-security-validate
The bundle ships a cordis.patch.yml that inserts one row named
sql-security-validate; no other configuration is required to start.
git clone <repository-url>
cd dsh-plugin-sql-security-validate
node tests/unit.mjs # verify the checkout is intact
Then install the directory as a bundle in DSH.
| Entry | Meaning |
|---|---|
demo.user |
The user table in demo — recommend always qualifying |
demo.orders |
Same, another table |
demo.user_private.phone |
A single column, when only that column may be read |
Write
database.table, not a bareuser. A bare name matches the same-named table in every database. See §7.
All fields are editable from the settings panel; the same values can be written
into cordis.patch.yml.
| Field | Default | Meaning |
|---|---|---|
enable |
true |
Master switch |
securityMode |
blacklist |
blacklist or whitelist_emulate |
enableStrictGuardMode |
false |
Install the monotonic guard so a refusal cannot be overridden by another plugin |
allowSchemaDiscovery |
true |
Permit table-less discovery (SHOW TABLES, SHOW DATABASES). Turn off where table names are confidential |
failOnParseError |
false |
Refuse statements the parser cannot interpret. Safer, but rejects valid legacy MySQL forms |
strictDatabaseQualification |
false |
Whether a bare whitelist grant may reach a qualified resource (see §7) |
| Field | Meaning |
|---|---|
localBlacklist.tables / .columns |
Entries refused in blacklist mode |
localWhitelist.tables / .columns |
Grants allowed in whitelist mode |
targetToolPrefixes |
Only tools starting with these prefixes are inspected; MCP tool names are mcp__<server>__<tool> |
includeNonMcpSqlTools |
Also inspect tools outside those prefixes |
sqlParamKeys |
Which argument keys are parsed as SQL |
Whitelist mode works fully offline. A central policy service is optional:
| Field | Default | Meaning |
|---|---|---|
remotePolicy.enabled |
false |
Fetch policy from a service |
remotePolicy.policyApiUrl |
'' |
Endpoint |
remotePolicy.policyApiToken |
'' |
Bearer token |
remotePolicy.cacheTtlMs |
30000 |
Cache lifetime |
remotePolicy.apiTimeoutMs |
3000 |
Request timeout; a failure fails closed |
| Field | Default | Meaning |
|---|---|---|
auditEnable |
true |
Record decisions |
audit.maxRecords |
5000 |
In-memory ring size |
audit.redactSql |
false |
Replace string literals with '***' |
audit.logPath |
'' |
Append-only JSONL path; empty means $DSH_HOME/sql-security-validate/audit.jsonl |
Agent emits a tool call
→ pre-execute hook (or the guard, in strict mode)
→ collect candidate SQL from the configured argument keys
→ parse each through the AST, collecting every table and column
→ merge local policy (and remote, if enabled)
→ a refused resource produces SQL_PERMISSION_DENIED and the call does not run
Two properties are deliberate:
On what a statement is judged by:
projection is refused when a column rule governs one of the tables it covers.** There is no column list to compare, so the statement cannot be shown to exclude the forbidden column; the refusal names it as| Path | Purpose |
|---|---|
src/index.js |
Host half: config, dual engines, audit route, turn tracking |
src/sql-parse.js |
AST-driven resource extraction |
src/policy.js |
Blacklist/whitelist matching and grant semantics |
src/audit.js |
Bounded ring buffer plus append-only JSONL |
src/client.js |
Settings panel and per-turn interception card |
vendor/node-sql-parser/ |
Vendored parser (see its README) |
MIT — see LICENSE.
The vendored node-sql-parser is Apache-2.0 and big-integer is MIT; both
licenses ship alongside their code under vendor/ and are not relicensed by
this project.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: security。