π‘οΈ BLA (Blind LLM Agents) β Adversarial defense shield that protects binaries, Electron apps, JS bundles, Python, and WebAssembly against AI reverse-engineering agents like REA. Poison -> Exhaust -> Hallucinate.
JavaScript adversarial-aiclaude-codecursorelectron-securityllm-securitymcpmcp-serverobfuscationreverse-engineeringwebassembly
test+docs: prove bind-scope honesty and in/out-of-scope behaviour
qybaihe198b2de6e8f9
diff --git a/.agents/skills/blind-llm-agents/SKILL.md b/.agents/skills/blind-llm-agents/SKILL.mdindex fe83911..0a507bf 100644--- a/.agents/skills/blind-llm-agents/SKILL.md+++ b/.agents/skills/blind-llm-agents/SKILL.md@@ -14,7 +14,7 @@ metadata:**This skill is the primary one-click harden GUIDE.** MCP (`bla` server) and the`bla-agents` CLI are the **execution layer**. Prefer teaching/calling existing tools-(`bla_harden`, `bla_defend`, `bla_weave_plan`, **`bla_lint`** (unified), `bla_lint_lanes`, `bla_lint_seal`, `bla_lint_wasm_params`, `bla_lint_panel_derive`, `bla_lint_js_aes_unwrap`, `bla_lint_js_wasm_hydrate_dump`, `bla_lint_wasm_xor_mask_sidecar`, `bla_lint_wasm_seal_xor_known_plaintext`, `bla_lint_plaintext_secrets`, `bla_encrypt_strings`, `bla_lint_integrity_coverage`, β¦) over inventing new+(`bla_harden`, `bla_defend`, `bla_weave_plan`, **`bla_lint`** (unified), `bla_lint_lanes`, `bla_lint_seal`, `bla_lint_wasm_params`, `bla_lint_panel_derive`, `bla_lint_js_aes_unwrap`, `bla_lint_js_wasm_hydrate_dump`, `bla_lint_wasm_xor_mask_sidecar`, `bla_lint_wasm_seal_xor_known_plaintext`, `bla_lint_plaintext_secrets`, `bla_encrypt_strings`, `bla_lint_integrity_coverage`, `bla_bind_scope`, `bla_lint_bind_scope`, β¦) over inventing newMCP surfaces.Use BLA whenever the user asks to harden a project against AI reverse-engineering@@ -50,6 +50,7 @@ Also: do **not** ship a stable public WASM ABI without explicit `wasm_preserve_e- Sensitive literals in panel.html / license.cjs must not remain cleartext in shipped artifacts; prefer `bla_encrypt_strings` (seed-derived XOR β never JS AES wrap-key). Lint with `bla_lint_plaintext_secrets`.- Integrity checkers must be interleaved and mutually covering (coverage matrix `bla-integrity-coverage/v1`); single-point self-seal is refuse-worthy. Lint with `bla_lint_integrity_coverage`.+- Optional bind-scope (domain/date) is a **public** license contract (`bla_bind_scope` β `bind-scope.json` + `BLA_BIND_SCOPE_CHECK`). Default OFF. Never a covert backdoor β `public:true` mandatory; lint with `bla_lint_bind_scope`.- Coverage claims must be real, not paper: an entry may only count as covering itself when its runtime check hard-fails on its own bytes (canonical self-digest, finalized at write). Check `integrityCoverageSelfVerified` on the harden report; when false the matrix drops self edges and refuses. Keep host-trust values (e.g. certificate digests) inside a covered artifact β unhardened data sidecars like `seal.json` are not covered.Held across R8βR12 (NO PRIZE). Keep in gate design; do **not** invent packaging refuse lints for these:@@ -128,6 +129,7 @@ Optional args (safe defaults): `intensity` (bankrupt), `emit_manifest` (false),| REA constant drift / empirical report | **`bla_rea_drift`** / **`bla_redteam_report`** (unverified if REA absent; on-disk read β available) || Cross-build structural drift (seeded polymorphism) | **`bla_polymorph_report`** (driftScore only β not a cracking claim; prove equivalence with verify/REA) || Cleartext panel/license secrets | **`bla_encrypt_strings`** + **`bla_lint_plaintext_secrets`** (XOR only β never JS AES) |+| Optional public domain/date lock | **`bla_bind_scope`** + **`bla_lint_bind_scope`** (default OFF; never covert) || Format-specific knobs | Load the matching appendix under `references/` |## FORBIDDENdiff --git a/docs/cli-and-mcp.md b/docs/cli-and-mcp.mdindex 19c5d77..e84b684 100644--- a/docs/cli-and-mcp.md+++ b/docs/cli-and-mcp.md@@ -41,6 +41,8 @@ For coding agents, the **[`blind-llm-agents` skill](../.agents/skills/blind-llm-- `bla_redteam_report`: Read (or `execute:true` re-run) `docs/redteam/empirical-rea-validation.json`. On-disk read β `status: available` (not a live REA verdict); `execute:true` β `pass`/`fail`; missing report / unready REA β `status: unverified`.- `bla_benchmark`: Runs the 8-target showcase benchmark suite.- `bla_emit_headers`: Generates C/C++, Rust, or Go defense headers (`language`, `intensity`).+- `bla_bind_scope`: Optional honest code-lock β write public `bind-scope.json` (domains / validFrom / validUntil) and inject `BLA_BIND_SCOPE_CHECK` into the license entry. Default OFF; never a covert backdoor.+- `bla_lint_bind_scope`: Read-only lint for `bla-bind-scope/v1` (refuses non-public / hidden fields / missing runtime check).- `bla_doctor`: Diagnostics for BLA engines and agent client registrations; also reports `skillMissingFiles` / `skillModifiedFiles` (format appendices under `references/` included).- `bla_weave_plan`: Read-only weave-decoy planner (`path`, optional `max_targets`) β `bla-weave-plan/v1` JSON (defensive theory checklist; no crack/RE).diff --git a/tests/bind-scope.test.ts b/tests/bind-scope.test.tsnew file mode 100644index 0000000..2f7dcf0--- /dev/null+++ b/tests/bind-scope.test.ts@@ -0,0 +1,178 @@+import {+ existsSync,+ mkdtempSync,+ readFileSync,+ writeFileSync,+} from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { describe, expect, it } from "vitest";+import {+ BIND_SCOPE_RUNTIME_MARKER,+ BIND_SCOPE_SCHEMA,+ applyBindScope,+ buildBindScopeContract,+ discoverAndLintBindScope,+ evaluateBindHost,+ evaluateBindTime,+ hostMatchesBindDomain,+ lintBindScopeFile,+ validateBindScopeContract,+} from "../src/engine/bind-scope.js";+import { handleMcpRequest } from "../src/mcp/server.js";+import { scanPackagingGates } from "../src/engine/packaging-gates.js";++const ENTRY = `"use strict";+module.exports.unlock = function unlock(key) {+ return key === "ok" ? "FLAG{in_scope}" : null;+};+`;++describe("bind-scope (Direction-4 honest code lock)", () => {+ it("requires public:true and rejects hidden fields / empty constraints", () => {+ expect(+ validateBindScopeContract({+ schema: BIND_SCOPE_SCHEMA,+ public: false,+ domains: ["app.example.com"],+ }).reasons,+ ).toContain("not-public");+ expect(+ validateBindScopeContract({+ schema: BIND_SCOPE_SCHEMA,+ public: true,+ domains: ["app.example.com"],+ covertAllow: ["evil.com"],+ }).reasons,+ ).toContain("hidden-field");+ expect(+ validateBindScopeContract({+ schema: BIND_SCOPE_SCHEMA,+ public: true,+ }).reasons,+ ).toContain("empty-constraints");+ });++ it("matches exact and *.suffix hosts; evaluates validity window", () => {+ expect(hostMatchesBindDomain("app.example.com", "app.example.com")).toBe(true);+ expect(hostMatchesBindDomain("x.example.com", "*.example.com")).toBe(true);+ expect(hostMatchesBindDomain("example.com", "*.example.com")).toBe(false);+ expect(evaluateBindHost("api.foo.test", ["*.foo.test"])).toBe(true);+ const from = "2026-01-01T00:00:00.000Z";+ const until = "2026-12-31T23:59:59.999Z";+ expect(evaluateBindTime(Date.parse("2026-06-01T00:00:00.000Z"), from, until)).toBe(true);+ expect(evaluateBindTime(Date.parse("2025-06-01T00:00:00.000Z"), from, until)).toBe(false);+ expect(evaluateBindTime(Date.parse("2027-06-01T00:00:00.000Z"), from, until)).toBe(false);+ });++ it("writes public contract + injects runtime check; in-scope loads, out-of-scope throws", () => {+ const dir = mkdtempSync(join(tmpdir(), "bla-bind-"));+ writeFileSync(join(dir, "license.cjs"), ENTRY);+ const report = applyBindScope({+ directory: dir,+ domains: ["allowed.example"],+ validFrom: "2020-01-01T00:00:00.000Z",+ validUntil: "2099-01-01T00:00:00.000Z",+ });+ expect(report.status).toBe("ok");+ expect(report.written).toBe(true);+ expect(report.runtimeInjected).toBe(true);+ expect(report.lint.ok).toBe(true);+ expect(existsSync(join(dir, "bind-scope.json"))).toBe(true);+ const contract = JSON.parse(readFileSync(join(dir, "bind-scope.json"), "utf8"));+ expect(contract.schema).toBe(BIND_SCOPE_SCHEMA);+ expect(contract.public).toBe(true);+ expect(contract.domains).toEqual(["allowed.example"]);++ const src = readFileSync(join(dir, "license.cjs"), "utf8");+ expect(src).toContain(BIND_SCOPE_RUNTIME_MARKER);++ const prev = process.env.BLA_BIND_HOST;+ try {+ process.env.BLA_BIND_HOST = "allowed.example";+ const mod = require(join(dir, "license.cjs"));+ expect(mod.unlock("ok")).toBe("FLAG{in_scope}");+ } finally {+ if (prev === undefined) delete process.env.BLA_BIND_HOST;+ else process.env.BLA_BIND_HOST = prev;+ }++ // Fresh copy for out-of-scope (module cache)+ const dir2 = mkdtempSync(join(tmpdir(), "bla-bind-oos-"));+ writeFileSync(join(dir2, "license.cjs"), ENTRY);+ applyBindScope({+ directory: dir2,+ domains: ["allowed.example"],+ });+ process.env.BLA_BIND_HOST = "evil.example";+ expect(() => require(join(dir2, "license.cjs"))).toThrow(/bind-scope: host not in public domains/);+ delete process.env.BLA_BIND_HOST;+ });++ it("lint refuses contract without runtime marker; packaging gates pick it up", () => {+ const dir = mkdtempSync(join(tmpdir(), "bla-bind-lint-"));+ writeFileSync(join(dir, "license.cjs"), ENTRY);+ writeFileSync(+ join(dir, "bind-scope.json"),+ JSON.stringify(buildBindScopeContract({ domains: ["a.example"] }), null, 2),+ );+ const reports = discoverAndLintBindScope(dir);+ expect(reports.length).toBe(1);+ expect(reports[0]!.shouldRefuseBankrupt).toBe(true);+ expect(reports[0]!.reasons).toContain("missing-runtime-check");++ const gates = scanPackagingGates({ directory: dir, intensity: "bankrupt" });+ expect(gates.gateCounts["bind-scope"]).toBeGreaterThanOrEqual(1);+ expect(gates.shouldRefuseBankrupt).toBe(true);+ });++ it("MCP bla_bind_scope dry_run writes nothing; apply then lint passes", async () => {+ const dir = mkdtempSync(join(tmpdir(), "bla-bind-mcp-"));+ writeFileSync(join(dir, "license.cjs"), ENTRY);+ const dry = await handleMcpRequest({+ jsonrpc: "2.0",+ id: 1,+ method: "tools/call",+ params: {+ name: "bla_bind_scope",+ arguments: {+ directory: dir,+ domains: ["mcp.example"],+ dry_run: true,+ },+ },+ });+ expect(dry?.error).toBeUndefined();+ expect(existsSync(join(dir, "bind-scope.json"))).toBe(false);++ const live = await handleMcpRequest({+ jsonrpc: "2.0",+ id: 2,+ method: "tools/call",+ params: {+ name: "bla_bind_scope",+ arguments: {+ directory: dir,+ domains: ["mcp.example"],+ valid_until: "2099-12-31T00:00:00.000Z",+ },+ },+ });+ expect(live?.error).toBeUndefined();+ expect((live!.result as { isError?: boolean }).isError).toBe(false);+ expect(existsSync(join(dir, "bind-scope.json"))).toBe(true);++ const lint = await handleMcpRequest({+ jsonrpc: "2.0",+ id: 3,+ method: "tools/call",+ params: {+ name: "bla_lint_bind_scope",+ arguments: { path: dir },+ },+ });+ const content = (lint!.result as { structuredContent: { shouldRefuseBankrupt: boolean } })+ .structuredContent;+ expect(content.shouldRefuseBankrupt).toBe(false);+ });+});diff --git a/tests/mcp-engine-capability-parity.test.ts b/tests/mcp-engine-capability-parity.test.tsindex 7971c08..a19855d 100644--- a/tests/mcp-engine-capability-parity.test.ts+++ b/tests/mcp-engine-capability-parity.test.ts@@ -175,6 +175,14 @@ const EXPECTED_MCP_ENGINE_CAPABILITIES: ReadonlyArray<{tool: "bla_lint_plaintext_secrets",params: ["path", "allow_plaintext_string"],},+ {+ tool: "bla_bind_scope",+ params: ["directory", "domains", "valid_from", "valid_until", "entry_path", "out_dir", "dry_run"],+ },+ {+ tool: "bla_lint_bind_scope",+ params: ["path", "allow_missing_bind_runtime"],+ },{tool: "bla_redteam_report",params: ["execute", "rea_root", "report_path"],