🛡️ 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
fix(engine): fail loudly when a directory child artifact cannot be protected
DeryFerd1d8e07c70dd7
diff --git a/src/engine/protector.ts b/src/engine/protector.tsindex bd67601..939ad82 100644--- a/src/engine/protector.ts+++ b/src/engine/protector.ts@@ -881,8 +881,15 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {chaffPayloadsEmbedded += subRes.metrics.chaffPayloadsEmbedded;binarySectionsPatched += subRes.metrics.binarySectionsPatched;for (const v of subRes.counteredReaVectors) counteredVectors.add(v);- } catch {- copyFileSync(srcFull, dstFull);+ } catch (err) {+ // A detected child artifact that failed protection must not be+ // silently replaced by an unprotected copy: the directory report+ // would claim success while shipping the original bytes.+ const reason = err instanceof Error ? err.message : String(err);+ throw new Error(+ `Directory protection failed for '${entry.name}': ${reason}`,+ { cause: err },+ );}} else {copyFileSync(srcFull, dstFull);diff --git a/tests/directory-fail-open.test.ts b/tests/directory-fail-open.test.tsnew file mode 100644index 0000000..da72376--- /dev/null+++ b/tests/directory-fail-open.test.ts@@ -0,0 +1,57 @@+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { afterEach, describe, expect, it } from "vitest";+import { protectTarget } from "../src/engine/protector.js";++const tempDirs: string[] = [];+function createTempDir(): string {+ const dir = mkdtempSync(join(tmpdir(), "bla-dir-fail-open-"));+ tempDirs.push(dir);+ return dir;+}++afterEach(() => {+ for (const dir of tempDirs.splice(0)) {+ rmSync(dir, { recursive: true, force: true });+ }+});++describe("directory protection reports child failures instead of copying unprotected bytes", () => {+ it("fails loudly when a detected child artifact cannot be protected", () => {+ const dir = createTempDir();+ const input = join(dir, "in");+ mkdirSync(input, { recursive: true });+ writeFileSync(join(input, "app.js"), "const x = 1;\n", "utf8");+ // Invalid WASM magic bytes: format detection routes this to the WASM shield,+ // which must refuse instead of silently emitting the original file.+ const brokenWasm = Buffer.from([0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]);+ writeFileSync(join(input, "broken.wasm"), brokenWasm);++ expect(() =>+ protectTarget({+ inputPath: input,+ outputPath: join(dir, "out"),+ intensity: "balanced",+ }),+ ).toThrow(/Directory protection failed for 'broken\.wasm'/);+ });++ it("still copies non-protectable file types as a documented pass-through", () => {+ const dir = createTempDir();+ const input = join(dir, "in");+ const output = join(dir, "out");+ mkdirSync(input, { recursive: true });+ writeFileSync(join(input, "app.js"), "const x = 1;\n", "utf8");+ writeFileSync(join(input, "notes.txt"), "plain text asset", "utf8");++ const result = protectTarget({+ inputPath: input,+ outputPath: output,+ intensity: "balanced",+ });++ expect(result.detectedFormat).toBe("directory");+ expect(readFileSync(join(output, "notes.txt"), "utf8")).toBe("plain text asset");+ });+});