actionwall 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/dist/classifiers/injectionClassifier.d.ts +26 -0
- package/dist/classifiers/injectionClassifier.js +38 -0
- package/dist/classifiers/injectionClassifier.js.map +1 -0
- package/dist/core/engine.d.ts +11 -0
- package/dist/core/engine.js +63 -3
- package/dist/core/engine.js.map +1 -1
- package/dist/core/policy.d.ts +21 -0
- package/dist/core/policy.js +18 -0
- package/dist/core/policy.js.map +1 -1
- package/dist/core/types.d.ts +32 -0
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/scanners/injection.js +19 -1
- package/dist/scanners/injection.js.map +1 -1
- package/dist/util/homoglyphs.d.ts +31 -0
- package/dist/util/homoglyphs.js +56 -0
- package/dist/util/homoglyphs.js.map +1 -0
- package/docs/POLICY_REFERENCE.md +24 -0
- package/docs/ROADMAP.md +24 -21
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
All notable changes to this project are documented here.
|
|
4
4
|
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
|
|
6
|
-
## [0.
|
|
6
|
+
## [0.3.0] - 2026-10-25
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Rule tuning via the new `rules` policy section: `severities` overrides any rule's severity by ID (downgrades soften verdicts, upgrades harden them), and `exceptions` suppress a rule when its evidence matches a glob (for example, allow certificate reads for build agents). Protected rules are immune.
|
|
10
|
+
- Homoglyph and mixed-script evasion detection: the injection scanner flags words mixing Latin letters with lookalike characters (Cyrillic, Greek, fullwidth). Pure non-Latin text never triggers.
|
|
11
|
+
- Pluggable injection classifier with shadow and enforce modes: provide any scoring model through ShieldEngine options, and the `injection.ml` policy section decides whether it runs. Shadow records the score on the decision, enforce adds a HIGH finding at or above the threshold. A transparent keyword baseline ships as the reference classifier.
|
|
12
|
+
|
|
13
|
+
## [0.2.0] - 2026-10-24
|
|
7
14
|
|
|
8
15
|
### Added
|
|
9
16
|
- HTTP service mode: `actionwall serve` exposes `POST /v1/check` (returns the full Decision, with `x-actionwall-verdict` / `x-actionwall-risk` response headers) and `GET /healthz`. Built on Node's built-in `http` module, with zero new dependencies.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable injection classifier (v0.3).
|
|
3
|
+
*
|
|
4
|
+
* The interface lets you plug any scoring model into the engine: a local
|
|
5
|
+
* classifier, an API call wrapped in a sync adapter, or the transparent
|
|
6
|
+
* keyword baseline shipped below. Scores run from 0 (benign) to 1 (injection).
|
|
7
|
+
*
|
|
8
|
+
* The engine runs the classifier on untrusted text (tool output and user
|
|
9
|
+
* prompt) in two modes, controlled by the `injection.ml` policy section:
|
|
10
|
+
* shadow — record the score on the decision, never change the verdict
|
|
11
|
+
* enforce — a score at or above the threshold adds a HIGH finding
|
|
12
|
+
*
|
|
13
|
+
* The shipped baseline is a transparent keyword scorer, not machine learning.
|
|
14
|
+
* It exists to exercise the wiring and to give you a reference for what a
|
|
15
|
+
* real model should return. Plug your own model for production use.
|
|
16
|
+
*/
|
|
17
|
+
export interface InjectionClassifier {
|
|
18
|
+
/** Shown on decisions and in the audit trail. */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Score untrusted text from 0 (benign) to 1 (injection). */
|
|
21
|
+
score(text: string): number;
|
|
22
|
+
}
|
|
23
|
+
export declare class KeywordBaselineClassifier implements InjectionClassifier {
|
|
24
|
+
readonly name = "keyword-baseline";
|
|
25
|
+
score(text: string): number;
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable injection classifier (v0.3).
|
|
3
|
+
*
|
|
4
|
+
* The interface lets you plug any scoring model into the engine: a local
|
|
5
|
+
* classifier, an API call wrapped in a sync adapter, or the transparent
|
|
6
|
+
* keyword baseline shipped below. Scores run from 0 (benign) to 1 (injection).
|
|
7
|
+
*
|
|
8
|
+
* The engine runs the classifier on untrusted text (tool output and user
|
|
9
|
+
* prompt) in two modes, controlled by the `injection.ml` policy section:
|
|
10
|
+
* shadow — record the score on the decision, never change the verdict
|
|
11
|
+
* enforce — a score at or above the threshold adds a HIGH finding
|
|
12
|
+
*
|
|
13
|
+
* The shipped baseline is a transparent keyword scorer, not machine learning.
|
|
14
|
+
* It exists to exercise the wiring and to give you a reference for what a
|
|
15
|
+
* real model should return. Plug your own model for production use.
|
|
16
|
+
*/
|
|
17
|
+
const SIGNALS = [
|
|
18
|
+
{ regex: /\bignore\s+(?:all\s+|any\s+|the\s+|your\s+)?(?:previous|prior|above|earlier|past)\s+(?:instructions?|prompts?|rules?)/i, weight: 0.4 },
|
|
19
|
+
{ regex: /\bdisregard\s+(?:all\s+|your\s+|any\s+)?(?:instructions?|rules?|guardrails?)/i, weight: 0.35 },
|
|
20
|
+
{ regex: /\byou\s+are\s+now\b/i, weight: 0.25 },
|
|
21
|
+
{ regex: /\breveal\b|\brepeat\b|\bprint\b[^.]{0,30}\bsystem\s+prompt/i, weight: 0.3 },
|
|
22
|
+
{ regex: /!\[[^\]]*\]\(\s*(?:https?:)?\/\/[^)]*(?:[?&])(?:data|q|payload|token|secret)=[^)]*\)/i, weight: 0.4 },
|
|
23
|
+
{ regex: /\b(important|urgent|critical)\b[^.\n]{0,60}\b(execute|delete|send|upload|exfiltrate)\b/i, weight: 0.2 },
|
|
24
|
+
{ regex: /\bsend\b|\bupload\b|\bpost\b[^.\n]{0,40}\b(secret|credential|token|api[- ]?key|\.env)\b/i, weight: 0.2 },
|
|
25
|
+
{ regex: /\bexfiltrate\b|\bstealthily\b|\bwithout the user knowing\b/i, weight: 0.3 },
|
|
26
|
+
];
|
|
27
|
+
export class KeywordBaselineClassifier {
|
|
28
|
+
name = "keyword-baseline";
|
|
29
|
+
score(text) {
|
|
30
|
+
let total = 0;
|
|
31
|
+
for (const signal of SIGNALS) {
|
|
32
|
+
if (signal.regex.test(text))
|
|
33
|
+
total += signal.weight;
|
|
34
|
+
}
|
|
35
|
+
return Math.min(1, total);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=injectionClassifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectionClassifier.js","sourceRoot":"","sources":["../../src/classifiers/injectionClassifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,MAAM,OAAO,GAAqB;IAChC,EAAE,KAAK,EAAE,wHAAwH,EAAE,MAAM,EAAE,GAAG,EAAE;IAChJ,EAAE,KAAK,EAAE,+EAA+E,EAAE,MAAM,EAAE,IAAI,EAAE;IACxG,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,IAAI,EAAE;IAC/C,EAAE,KAAK,EAAE,6DAA6D,EAAE,MAAM,EAAE,GAAG,EAAE;IACrF,EAAE,KAAK,EAAE,uFAAuF,EAAE,MAAM,EAAE,GAAG,EAAE;IAC/G,EAAE,KAAK,EAAE,yFAAyF,EAAE,MAAM,EAAE,GAAG,EAAE;IACjH,EAAE,KAAK,EAAE,0FAA0F,EAAE,MAAM,EAAE,GAAG,EAAE;IAClH,EAAE,KAAK,EAAE,6DAA6D,EAAE,MAAM,EAAE,GAAG,EAAE;CACtF,CAAC;AAEF,MAAM,OAAO,yBAAyB;IAC3B,IAAI,GAAG,kBAAkB,CAAC;IAEnC,KAAK,CAAC,IAAY;QAChB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/core/engine.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* blocks instead of waving everything through.
|
|
14
14
|
*/
|
|
15
15
|
import type { Action, Decision, Scanner } from "./types.js";
|
|
16
|
+
import type { InjectionClassifier } from "../classifiers/injectionClassifier.js";
|
|
16
17
|
import type { PolicyDoc } from "./types.js";
|
|
17
18
|
import { AuditLogger } from "./audit.js";
|
|
18
19
|
export declare const DEFAULT_SCANNERS: Scanner[];
|
|
@@ -25,17 +26,27 @@ export interface ShieldEngineOptions {
|
|
|
25
26
|
audit?: AuditLogger | false;
|
|
26
27
|
/** Replace or extend the scanner set. */
|
|
27
28
|
scanners?: Scanner[];
|
|
29
|
+
/** Optional pluggable injection classifier. The `injection.ml` policy
|
|
30
|
+
* section decides whether it runs, and in which mode. */
|
|
31
|
+
injectionClassifier?: InjectionClassifier;
|
|
28
32
|
}
|
|
29
33
|
export declare class ShieldEngine {
|
|
30
34
|
readonly policy: PolicyDoc;
|
|
31
35
|
readonly audit?: AuditLogger;
|
|
32
36
|
private readonly scanners;
|
|
37
|
+
private readonly injectionClassifier?;
|
|
33
38
|
constructor(policy: PolicyDoc, options?: ShieldEngineOptions);
|
|
34
39
|
/** Inspect an action and return the decision. Never throws for policy reasons. */
|
|
35
40
|
check(action: Action): Decision;
|
|
36
41
|
/** `check` + throw ActionBlockedError on BLOCK — the integration shape for agents. */
|
|
37
42
|
guard(action: Action): Decision;
|
|
38
43
|
private verdictFor;
|
|
44
|
+
/**
|
|
45
|
+
* Rule tuning (v0.3): drop findings matched by `rules.exceptions` and apply
|
|
46
|
+
* `rules.severities` overrides. Protected rules (scanner/audit failures)
|
|
47
|
+
* are immune, so tuning can never open the firewall's own failure path.
|
|
48
|
+
*/
|
|
49
|
+
private tuneFindings;
|
|
39
50
|
}
|
|
40
51
|
/** Convenience: build an Action with sane defaults (used by CLI and demos). */
|
|
41
52
|
export declare function makeAction(input: {
|
package/dist/core/engine.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* blocks instead of waving everything through.
|
|
14
14
|
*/
|
|
15
15
|
import { randomUUID } from "node:crypto";
|
|
16
|
+
import { globToRegExp } from "../util/paths.js";
|
|
16
17
|
import { AuditLogger } from "./audit.js";
|
|
17
18
|
import { toolPermissionsScanner } from "../scanners/toolPermissions.js";
|
|
18
19
|
import { commandRiskScanner } from "../scanners/commandRisk.js";
|
|
@@ -41,9 +42,11 @@ export class ShieldEngine {
|
|
|
41
42
|
policy;
|
|
42
43
|
audit;
|
|
43
44
|
scanners;
|
|
45
|
+
injectionClassifier;
|
|
44
46
|
constructor(policy, options = {}) {
|
|
45
47
|
this.policy = policy;
|
|
46
48
|
this.scanners = options.scanners ?? DEFAULT_SCANNERS;
|
|
49
|
+
this.injectionClassifier = options.injectionClassifier;
|
|
47
50
|
if (policy.audit.enabled && options.audit !== false) {
|
|
48
51
|
this.audit =
|
|
49
52
|
options.audit ??
|
|
@@ -69,7 +72,33 @@ export class ShieldEngine {
|
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
|
-
const
|
|
75
|
+
const tuned = this.tuneFindings(findings);
|
|
76
|
+
// Pluggable classifier: runs on untrusted text when the policy enables
|
|
77
|
+
// it. Shadow mode records the score without touching the verdict;
|
|
78
|
+
// enforce mode adds a HIGH finding at or above the threshold.
|
|
79
|
+
let ml;
|
|
80
|
+
const classifier = this.injectionClassifier;
|
|
81
|
+
if (classifier && this.policy.injection.ml.enabled) {
|
|
82
|
+
const text = [action.context?.toolOutput, action.context?.userPrompt]
|
|
83
|
+
.filter((x) => Boolean(x && x.length > 0))
|
|
84
|
+
.join("\n");
|
|
85
|
+
if (text.length > 0) {
|
|
86
|
+
const score = classifier.score(text);
|
|
87
|
+
const { mode, threshold } = this.policy.injection.ml;
|
|
88
|
+
ml = { classifier: classifier.name, score: Math.round(score * 1000) / 1000, mode };
|
|
89
|
+
if (mode === "enforce" && score >= threshold) {
|
|
90
|
+
tuned.push({
|
|
91
|
+
scanner: "classifier",
|
|
92
|
+
ruleId: "INJ-ML",
|
|
93
|
+
severity: "HIGH",
|
|
94
|
+
title: "Injection classifier flagged the untrusted text",
|
|
95
|
+
reason: `The "${classifier.name}" classifier scored this context ${ml.score} against a threshold of ${threshold} (enforce mode).`,
|
|
96
|
+
policyRef: "injection.ml",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const risk = maxSeverity(tuned);
|
|
73
102
|
const verdict = this.verdictFor(risk);
|
|
74
103
|
const decision = {
|
|
75
104
|
actionId: action.id,
|
|
@@ -77,10 +106,11 @@ export class ShieldEngine {
|
|
|
77
106
|
tool: action.tool,
|
|
78
107
|
verdict,
|
|
79
108
|
risk,
|
|
80
|
-
findings,
|
|
81
|
-
summary: headline(
|
|
109
|
+
findings: tuned,
|
|
110
|
+
summary: headline(tuned, verdict),
|
|
82
111
|
latencyMs: Math.round((performance.now() - started) * 100) / 100,
|
|
83
112
|
timestamp,
|
|
113
|
+
...(ml ? { ml } : {}),
|
|
84
114
|
};
|
|
85
115
|
if (this.audit && (verdict !== "ALLOW" || this.policy.audit.log_allowed)) {
|
|
86
116
|
try {
|
|
@@ -113,7 +143,37 @@ export class ShieldEngine {
|
|
|
113
143
|
return "ASK_HUMAN";
|
|
114
144
|
return "ALLOW";
|
|
115
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Rule tuning (v0.3): drop findings matched by `rules.exceptions` and apply
|
|
148
|
+
* `rules.severities` overrides. Protected rules (scanner/audit failures)
|
|
149
|
+
* are immune, so tuning can never open the firewall's own failure path.
|
|
150
|
+
*/
|
|
151
|
+
tuneFindings(findings) {
|
|
152
|
+
const rules = this.policy.rules;
|
|
153
|
+
if (rules.exceptions.length === 0 && Object.keys(rules.severities).length === 0) {
|
|
154
|
+
return findings;
|
|
155
|
+
}
|
|
156
|
+
return findings
|
|
157
|
+
.filter((f) => {
|
|
158
|
+
if (PROTECTED_RULE_IDS.has(f.ruleId))
|
|
159
|
+
return true;
|
|
160
|
+
return !rules.exceptions.some((e) => {
|
|
161
|
+
if (e.ruleId !== f.ruleId)
|
|
162
|
+
return false;
|
|
163
|
+
const evidence = f.evidence ?? "";
|
|
164
|
+
return evidence.length > 0 && globToRegExp(e.matches).test(evidence);
|
|
165
|
+
});
|
|
166
|
+
})
|
|
167
|
+
.map((f) => {
|
|
168
|
+
const override = rules.severities[f.ruleId];
|
|
169
|
+
if (!override || PROTECTED_RULE_IDS.has(f.ruleId) || override === f.severity)
|
|
170
|
+
return f;
|
|
171
|
+
return { ...f, severity: override };
|
|
172
|
+
});
|
|
173
|
+
}
|
|
116
174
|
}
|
|
175
|
+
/** Rule tuning can never touch the firewall's own failure reporting. */
|
|
176
|
+
const PROTECTED_RULE_IDS = new Set(["SCANNER-FAILURE", "AUDIT-WRITE-FAILURE"]);
|
|
117
177
|
function headline(findings, verdict) {
|
|
118
178
|
if (findings.length === 0)
|
|
119
179
|
return "No policy violations detected";
|
package/dist/core/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAA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}
|
package/dist/core/policy.d.ts
CHANGED
|
@@ -88,6 +88,27 @@ export declare const policySchema: z.ZodObject<{
|
|
|
88
88
|
injection: z.ZodPreprocess<z.ZodObject<{
|
|
89
89
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
90
90
|
hits_for_high: z.ZodDefault<z.ZodNumber>;
|
|
91
|
+
ml: z.ZodPreprocess<z.ZodObject<{
|
|
92
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
94
|
+
enforce: "enforce";
|
|
95
|
+
shadow: "shadow";
|
|
96
|
+
}>>;
|
|
97
|
+
threshold: z.ZodDefault<z.ZodNumber>;
|
|
98
|
+
}, z.core.$strip>, unknown>;
|
|
99
|
+
}, z.core.$strip>, unknown>;
|
|
100
|
+
rules: z.ZodPreprocess<z.ZodObject<{
|
|
101
|
+
severities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
102
|
+
CRITICAL: "CRITICAL";
|
|
103
|
+
HIGH: "HIGH";
|
|
104
|
+
LOW: "LOW";
|
|
105
|
+
MEDIUM: "MEDIUM";
|
|
106
|
+
}>>>;
|
|
107
|
+
exceptions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
108
|
+
ruleId: z.ZodString;
|
|
109
|
+
matches: z.ZodString;
|
|
110
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>>;
|
|
91
112
|
}, z.core.$strip>, unknown>;
|
|
92
113
|
audit: z.ZodPreprocess<z.ZodObject<{
|
|
93
114
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
package/dist/core/policy.js
CHANGED
|
@@ -82,6 +82,24 @@ export const policySchema = z.object({
|
|
|
82
82
|
injection: section(z.object({
|
|
83
83
|
enabled: z.boolean().default(true),
|
|
84
84
|
hits_for_high: z.number().int().min(1).default(2),
|
|
85
|
+
ml: section(z.object({
|
|
86
|
+
enabled: z.boolean().default(false),
|
|
87
|
+
mode: z.enum(["shadow", "enforce"]).default("shadow"),
|
|
88
|
+
threshold: z.number().min(0).max(1).default(0.7),
|
|
89
|
+
})),
|
|
90
|
+
})),
|
|
91
|
+
rules: section(z.object({
|
|
92
|
+
/** ruleId → severity override (may not target protected rules). */
|
|
93
|
+
severities: z.record(z.string(), riskLevelSchema).default({}),
|
|
94
|
+
/** Findings whose ruleId matches and whose evidence matches the glob
|
|
95
|
+
* are dropped. Protected rules cannot be suppressed. */
|
|
96
|
+
exceptions: z
|
|
97
|
+
.array(z.object({
|
|
98
|
+
ruleId: z.string().min(1),
|
|
99
|
+
matches: z.string().min(1),
|
|
100
|
+
reason: z.string().optional(),
|
|
101
|
+
}))
|
|
102
|
+
.default([]),
|
|
85
103
|
})),
|
|
86
104
|
audit: section(z.object({
|
|
87
105
|
enabled: z.boolean().default(true),
|
package/dist/core/policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/core/policy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAG1C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAA6B,MAAS,EAAE,EAAE,CACxD,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B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F,CAAC;IACD,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,MAAO,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,IAAI,IAAI,IAAI;QAAE,IAAI,GAAG,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC,IAAiB,CAAC;AAClC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,aAAa;IAC3B,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,CAAc,CAAC;AAC7C,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,KAAgB;IAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -67,6 +67,12 @@ export interface Decision {
|
|
|
67
67
|
/** Wall-clock cost of the scan in milliseconds. */
|
|
68
68
|
latencyMs: number;
|
|
69
69
|
timestamp: string;
|
|
70
|
+
/** Present when a pluggable injection classifier ran for this action. */
|
|
71
|
+
ml?: {
|
|
72
|
+
classifier: string;
|
|
73
|
+
score: number;
|
|
74
|
+
mode: "shadow" | "enforce";
|
|
75
|
+
};
|
|
70
76
|
}
|
|
71
77
|
/** Contract every scanner implements. Scanners are pure: no I/O side effects
|
|
72
78
|
* beyond read-only filesystem counting performed by the file scanners. */
|
|
@@ -136,6 +142,23 @@ export interface PolicyDoc {
|
|
|
136
142
|
enabled: boolean;
|
|
137
143
|
/** Distinct patterns that must hit before severity escalates to HIGH. */
|
|
138
144
|
hits_for_high: number;
|
|
145
|
+
/** Pluggable classifier control. The classifier itself is provided in
|
|
146
|
+
* code (ShieldEngine options); the policy decides if it runs and how. */
|
|
147
|
+
ml: {
|
|
148
|
+
enabled: boolean;
|
|
149
|
+
mode: "shadow" | "enforce";
|
|
150
|
+
/** Enforce mode adds a HIGH finding at or above this score. */
|
|
151
|
+
threshold: number;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/** Rule tuning: override finding severities and suppress specific rules
|
|
155
|
+
* when their evidence matches an exception pattern. Protected rules
|
|
156
|
+
* (SCANNER-FAILURE, AUDIT-WRITE-FAILURE) cannot be tuned. */
|
|
157
|
+
rules: {
|
|
158
|
+
/** ruleId → severity override, e.g. { "CMD-WORLD-WRITABLE": "MEDIUM" }. */
|
|
159
|
+
severities: Record<string, RiskLevel>;
|
|
160
|
+
/** Findings whose ruleId and evidence match an exception are dropped. */
|
|
161
|
+
exceptions: RuleException[];
|
|
139
162
|
};
|
|
140
163
|
audit: {
|
|
141
164
|
enabled: boolean;
|
|
@@ -144,4 +167,13 @@ export interface PolicyDoc {
|
|
|
144
167
|
log_allowed: boolean;
|
|
145
168
|
};
|
|
146
169
|
}
|
|
170
|
+
/** Suppress one scanner rule when its evidence matches a glob pattern. */
|
|
171
|
+
export interface RuleException {
|
|
172
|
+
/** The scanner rule to suppress, e.g. "FP-PROTECTED-READ". */
|
|
173
|
+
ruleId: string;
|
|
174
|
+
/** Glob matched against the finding's evidence (the path or command). */
|
|
175
|
+
matches: string;
|
|
176
|
+
/** Why this exception exists, for the audit trail. */
|
|
177
|
+
reason?: string;
|
|
178
|
+
}
|
|
147
179
|
export declare function maxSeverity(findings: Finding[]): RiskLevel;
|
package/dist/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,CAAC,MAAM,UAAU,GAA8B;IACnD,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAA8B;IACnD,GAAG,EAAE,IAAI;IACT,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,IAAI;CACf,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,CAAC,MAAM,UAAU,GAA8B;IACnD,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAA8B;IACnD,GAAG,EAAE,IAAI;IACT,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,IAAI;CACf,CAAC;AAmLF,MAAM,UAAU,WAAW,CAAC,QAAmB;IAC7C,IAAI,KAAK,GAAc,KAAK,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC;YAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -26,3 +26,5 @@ export { injectionScanner } from "./scanners/injection.js";
|
|
|
26
26
|
export { redactText } from "./util/secretPatterns.js";
|
|
27
27
|
export { runDemo, demoSteps, setupSandbox, cleanupSandbox } from "./demo/mockAgent.js";
|
|
28
28
|
export { createActionWallServer, loadTenantsFile, type ServeOptions } from "./server/serve.js";
|
|
29
|
+
export { KeywordBaselineClassifier, type InjectionClassifier } from "./classifiers/injectionClassifier.js";
|
|
30
|
+
export { scanConfusables, type ConfusableScan } from "./util/homoglyphs.js";
|
package/dist/index.js
CHANGED
|
@@ -24,4 +24,6 @@ export { injectionScanner } from "./scanners/injection.js";
|
|
|
24
24
|
export { redactText } from "./util/secretPatterns.js";
|
|
25
25
|
export { runDemo, demoSteps, setupSandbox, cleanupSandbox } from "./demo/mockAgent.js";
|
|
26
26
|
export { createActionWallServer, loadTenantsFile } from "./server/serve.js";
|
|
27
|
+
export { KeywordBaselineClassifier } from "./classifiers/injectionClassifier.js";
|
|
28
|
+
export { scanConfusables } from "./util/homoglyphs.js";
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAElG,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EA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,MAAM,sBAAsB,CAAC"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* rather than pretending regex is a complete defense.
|
|
13
13
|
*/
|
|
14
14
|
import { truncate } from "../util/secretPatterns.js";
|
|
15
|
+
import { scanConfusables } from "../util/homoglyphs.js";
|
|
15
16
|
const PATTERNS = [
|
|
16
17
|
{
|
|
17
18
|
id: "IGNORE-PRIOR",
|
|
@@ -86,15 +87,32 @@ export const injectionScanner = {
|
|
|
86
87
|
hidden = true;
|
|
87
88
|
hits.push({ id: "HIDDEN-CHARS", label: "hidden/invisible characters (zero-width or word-joiner)", snippet: "(invisible characters present)" });
|
|
88
89
|
}
|
|
90
|
+
// Homoglyph evasion: words that mix Latin letters with lookalikes from
|
|
91
|
+
// other scripts (Cyrillic "а", Greek "ο"). Pure non-Latin text is fine.
|
|
92
|
+
const confusables = scanConfusables(text);
|
|
93
|
+
if (confusables.mixedScriptWordFound) {
|
|
94
|
+
hits.push({
|
|
95
|
+
id: "HOMOGLYPH",
|
|
96
|
+
label: `homoglyph lookalikes in mixed-script words (example: "${truncate(confusables.example ?? "", 40)}")`,
|
|
97
|
+
snippet: `(lookalike characters present, e.g. ${confusables.hits[0].latin})`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
89
100
|
if (hits.length === 0)
|
|
90
101
|
continue;
|
|
91
102
|
const exfil = hits.some((h) => h.id === "EXFIL-IMAGE");
|
|
92
103
|
const distinct = new Set(hits.map((h) => h.id)).size;
|
|
93
104
|
const severity = exfil || distinct >= policy.injection.hits_for_high ? "HIGH" : "MEDIUM";
|
|
94
105
|
const labels = hits.slice(0, 3).map((h) => h.label).join("; ");
|
|
106
|
+
const ruleId = exfil
|
|
107
|
+
? "INJ-EXFIL-IMAGE"
|
|
108
|
+
: distinct >= policy.injection.hits_for_high
|
|
109
|
+
? "INJ-MULTI-PATTERN"
|
|
110
|
+
: hits[0].id === "HOMOGLYPH"
|
|
111
|
+
? "INJ-HOMOGLYPH"
|
|
112
|
+
: "INJ-SINGLE-PATTERN";
|
|
95
113
|
findings.push({
|
|
96
114
|
scanner: this.name,
|
|
97
|
-
ruleId
|
|
115
|
+
ruleId,
|
|
98
116
|
severity,
|
|
99
117
|
title: exfil ? "Possible data exfiltration via markdown image" : "Possible prompt injection",
|
|
100
118
|
reason: `${severity === "HIGH" ? distinct : 1} injection pattern${distinct === 1 ? "" : "s"} detected in ${source.label}: ${labels}. ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../src/scanners/injection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"injection.js","sourceRoot":"","sources":["../../src/scanners/injection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQxD,MAAM,QAAQ,GAAuB;IACnC;QACE,EAAE,EAAE,cAAc;QAClB,KAAK,EAAE,8IAA8I;QACrJ,KAAK,EAAE,yCAAyC;KACjD;IACD;QACE,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,wHAAwH;QAC/H,KAAK,EAAE,iCAAiC;KACzC;IACD;QACE,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,qCAAqC;QAC5C,KAAK,EAAE,kCAAkC;KAC1C;IACD;QACE,EAAE,EAAE,uBAAuB;QAC3B,KAAK,EAAE,kGAAkG;QACzG,KAAK,EAAE,kCAAkC;KAC1C;IACD;QACE,EAAE,EAAE,oBAAoB;QACxB,KAAK,EAAE,qFAAqF;QAC5F,KAAK,EAAE,4BAA4B;KACpC;IACD;QACE,EAAE,EAAE,kBAAkB;QACtB,KAAK,EAAE,2EAA2E;QAClF,KAAK,EAAE,+BAA+B;KACvC;IACD;QACE,EAAE,EAAE,aAAa;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, and friends) so that malicious
|
|
6
|
+
* text looks harmless to a reviewer while reading differently to the model.
|
|
7
|
+
*
|
|
8
|
+
* Detection rule: a word that MIXES ordinary Latin letters with known
|
|
9
|
+
* confusable lookalikes is flagged. Pure non-Latin text (someone writing
|
|
10
|
+
* Russian or Greek on purpose) never triggers, which keeps the false-positive
|
|
11
|
+
* rate near zero for international users.
|
|
12
|
+
*/
|
|
13
|
+
export interface ConfusableHit {
|
|
14
|
+
/** The lookalike character itself. */
|
|
15
|
+
char: string;
|
|
16
|
+
/** The Latin letter it impersonates. */
|
|
17
|
+
latin: string;
|
|
18
|
+
/** Position in the inspected text. */
|
|
19
|
+
index: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ConfusableScan {
|
|
22
|
+
/** Lookalike characters found, in order. */
|
|
23
|
+
hits: ConfusableHit[];
|
|
24
|
+
/** True when at least one word mixes Latin letters with lookalikes,
|
|
25
|
+
* which is the actual evasion signal. */
|
|
26
|
+
mixedScriptWordFound: boolean;
|
|
27
|
+
/** First mixed word, for evidence. */
|
|
28
|
+
example?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Scan text for homoglyph evasion. Only mixed-script words count. */
|
|
31
|
+
export declare function scanConfusables(text: string): ConfusableScan;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Homoglyph and mixed-script detection.
|
|
3
|
+
*
|
|
4
|
+
* Attackers swap Latin characters with lookalikes from other scripts
|
|
5
|
+
* (Cyrillic "а" U+0430, Greek "ο" U+03BF, and friends) so that malicious
|
|
6
|
+
* text looks harmless to a reviewer while reading differently to the model.
|
|
7
|
+
*
|
|
8
|
+
* Detection rule: a word that MIXES ordinary Latin letters with known
|
|
9
|
+
* confusable lookalikes is flagged. Pure non-Latin text (someone writing
|
|
10
|
+
* Russian or Greek on purpose) never triggers, which keeps the false-positive
|
|
11
|
+
* rate near zero for international users.
|
|
12
|
+
*/
|
|
13
|
+
/** Common lookalikes that map onto Latin letters. Far from exhaustive:
|
|
14
|
+
* covers the characters seen in real evasion attempts (brand and command
|
|
15
|
+
* impersonation) without dragging in whole Unicode tables. */
|
|
16
|
+
const CONFUSABLES = {
|
|
17
|
+
// Cyrillic
|
|
18
|
+
"\u0430": "a", "\u0435": "e", "\u043e": "o", "\u0440": "p", "\u0441": "c",
|
|
19
|
+
"\u0443": "y", "\u0445": "x", "\u0432": "b", "\u043d": "h", "\u043a": "k",
|
|
20
|
+
"\u043c": "m", "\u0442": "t", "\u0438": "i", "\u0456": "i", "\u0455": "s",
|
|
21
|
+
// Greek
|
|
22
|
+
"\u03bf": "o", "\u03b1": "a", "\u03b5": "e", "\u03c1": "p", "\u03bd": "n",
|
|
23
|
+
"\u03ba": "k", "\u03c4": "t", "\u03c5": "u", "\u03b9": "i", "\u03c7": "x",
|
|
24
|
+
// Armenian and fullwidth lookalikes seen in the wild
|
|
25
|
+
"\u0561": "a", "\u0575": "y", "\u0585": "o", "\uFF41": "a", "\uFF4F": "o",
|
|
26
|
+
"\uFF50": "p", "\uFF52": "r", "\uFF43": "c", "\uFF53": "s",
|
|
27
|
+
};
|
|
28
|
+
/** Scan text for homoglyph evasion. Only mixed-script words count. */
|
|
29
|
+
export function scanConfusables(text) {
|
|
30
|
+
const hits = [];
|
|
31
|
+
for (let i = 0; i < text.length; i++) {
|
|
32
|
+
const mapped = CONFUSABLES[text[i]];
|
|
33
|
+
if (mapped)
|
|
34
|
+
hits.push({ char: text[i], latin: mapped, index: i });
|
|
35
|
+
}
|
|
36
|
+
let mixedScriptWordFound = false;
|
|
37
|
+
let example;
|
|
38
|
+
// Split into letter runs so we can inspect each word in isolation.
|
|
39
|
+
const words = text.match(/[\p{L}\p{N}]+/gu) ?? [];
|
|
40
|
+
for (const word of words) {
|
|
41
|
+
let latin = 0;
|
|
42
|
+
let lookalike = 0;
|
|
43
|
+
for (const ch of word) {
|
|
44
|
+
if (CONFUSABLES[ch])
|
|
45
|
+
lookalike++;
|
|
46
|
+
else if (/[a-zA-Z]/.test(ch))
|
|
47
|
+
latin++;
|
|
48
|
+
}
|
|
49
|
+
if (latin > 0 && lookalike > 0) {
|
|
50
|
+
mixedScriptWordFound = true;
|
|
51
|
+
example ??= word;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { hits, mixedScriptWordFound, example };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=homoglyphs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"homoglyphs.js","sourceRoot":"","sources":["../../src/util/homoglyphs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;8DAE8D;AAC9D,MAAM,WAAW,GAA2B;IAC1C,WAAW;IACX,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IACzE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IACzE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IACzE,QAAQ;IACR,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IACzE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IACzE,qDAAqD;IACrD,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IACzE,QAAQ,EAAE,GAAG,E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POLICY_REFERENCE.md
CHANGED
|
@@ -112,6 +112,30 @@ Built-in signatures: AWS access/secret keys, GitHub tokens, OpenAI/Anthropic key
|
|
|
112
112
|
|
|
113
113
|
Scans `context.toolOutput` and `context.userPrompt`. Pattern families: instruction overrides, fake system markers, prompt-extraction requests, role overrides, urgent-execute directives, impersonated assistant turns, markdown-image exfiltration (⇒ HIGH immediately), hidden zero-width characters.
|
|
114
114
|
|
|
115
|
+
## `rules`
|
|
116
|
+
|
|
117
|
+
Tune individual scanner rules without touching scanner code. Both subsections are optional. Protected rules (`SCANNER-FAILURE`, `AUDIT-WRITE-FAILURE`) can never be tuned.
|
|
118
|
+
|
|
119
|
+
| Field | Type | Default | Meaning |
|
|
120
|
+
|---|---|---|---|
|
|
121
|
+
| `severities` | map of ruleId to RiskLevel | `{}` | Override the severity of any finding by rule ID. Downgrades soften the verdict, upgrades harden it. |
|
|
122
|
+
| `exceptions` | `{ruleId, matches, reason?}[]` | `[]` | Drop findings whose rule ID matches and whose evidence (the path or command text) matches the glob in `matches`. |
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
rules:
|
|
126
|
+
severities:
|
|
127
|
+
CMD-WORLD-WRITABLE: MEDIUM # world-writable files are acceptable here
|
|
128
|
+
exceptions:
|
|
129
|
+
- ruleId: FP-PROTECTED-READ
|
|
130
|
+
matches: "**/*.pem"
|
|
131
|
+
reason: build agents may read certificates
|
|
132
|
+
- ruleId: CMD-PRIVILEGE-ESCALATION
|
|
133
|
+
matches: "sudo systemctl restart *"
|
|
134
|
+
reason: ops runbook restarts
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Exceptions are evidence-scoped: `.env` stays denied even when `**/*.pem` is excepted. The scanner-failure and audit-failure paths are always immune, so tuning can never disable the firewall's own failure reporting.
|
|
138
|
+
|
|
115
139
|
## `audit`
|
|
116
140
|
|
|
117
141
|
| Field | Type | Default | Meaning |
|
package/docs/ROADMAP.md
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
# ActionWall: Roadmap
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Milestones record what shipped. Versions snapshot the work at release time, so unfinished items simply carry forward.
|
|
4
4
|
|
|
5
|
+
## Shipped
|
|
6
|
+
|
|
7
|
+
### v0.1
|
|
5
8
|
- Core engine: 6 scanners, YAML/JSON policies with zod validation, fail-closed defaults
|
|
6
9
|
- CLI: check / validate / log / demo, CI-friendly exit codes
|
|
7
10
|
- Hash-chained JSONL audit log with `--verify`
|
|
8
|
-
-
|
|
11
|
+
- Presets: default / strict / readonly
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
### v0.2
|
|
14
|
+
- HTTP service mode (`actionwall serve`): POST /v1/check with `x-actionwall-verdict` / `x-actionwall-risk` headers, GET /healthz, per-tenant policies via a tenants file
|
|
15
|
+
- Dependency refresh: commander 15, zod 4, vitest 5, typescript 7, @types/node 26
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
17
|
+
### v0.3 (current)
|
|
18
|
+
- Rule tuning: `rules.severities` overrides and `rules.exceptions` evidence-scoped suppression
|
|
19
|
+
- Homoglyph and mixed-script evasion detection in the injection scanner
|
|
20
|
+
- Pluggable injection classifier with shadow and enforce modes (keyword baseline included)
|
|
16
21
|
|
|
17
|
-
##
|
|
22
|
+
## Next
|
|
18
23
|
|
|
19
|
-
- [ ]
|
|
20
|
-
- [ ]
|
|
21
|
-
- [ ]
|
|
22
|
-
- [ ]
|
|
24
|
+
- [ ] **MCP guard**: run ActionWall as an MCP gateway/proxy so Claude Desktop and friends are protected without code changes
|
|
25
|
+
- [ ] Official middleware packages: OpenAI tool-calling, Anthropic tool-use, LangChain/LangGraph, Vercel AI SDK
|
|
26
|
+
- [ ] Async audit writer (batched, back-pressured) for high-throughput service mode
|
|
27
|
+
- [ ] Approvals workflow for ASK_HUMAN (queue, TTL, auto-deny, Slack/webhook)
|
|
28
|
+
- [ ] Remote audit sink (S3 Object Lock / syslog) + periodic signed Merkle checkpoints
|
|
23
29
|
|
|
24
|
-
##
|
|
30
|
+
## Exploring
|
|
25
31
|
|
|
26
|
-
- [ ] Real approvals workflow for ASK_HUMAN (queue, TTL, auto-deny, Slack/webhook)
|
|
27
|
-
- [ ] Remote audit sink (S3 Object Lock / syslog) + periodic signed Merkle checkpoints, tamper-*proof* rather than tamper-evident
|
|
28
32
|
- [ ] `actionwall replay`: re-run past actions under a new policy ("what would have been blocked?")
|
|
29
|
-
- [ ] Metrics endpoint (Prometheus)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
- [ ]
|
|
34
|
-
- [ ] Policy inheritance & org/team composition
|
|
33
|
+
- [ ] Metrics endpoint (Prometheus)
|
|
34
|
+
- [ ] Homoglyph coverage expansion: fuller Unicode confusables tables
|
|
35
|
+
- [ ] Real-model benchmarking for the injection classifier
|
|
36
|
+
- [ ] Differential shell parsing (exchange the tokenizer behind the same interface)
|
|
37
|
+
- [ ] Policy inheritance and org/team composition
|
|
35
38
|
- [ ] Fuzzing harness for the tokenizer and glob walker
|
|
36
39
|
- [ ] WASM build for browser/edge agent runtimes
|
package/package.json
CHANGED