🛡️ 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(fs): use cryptographic temp names and exclusive create for atomic writes
DeryFerd279cb5474adc
diff --git a/src/engine/protector.ts b/src/engine/protector.tsindex bd67601..1dfa1ad 100644--- a/src/engine/protector.ts+++ b/src/engine/protector.ts@@ -1,4 +1,4 @@-import { createHash } from "node:crypto";+import { createHash, randomBytes } from "node:crypto";import {chmodSync,copyFileSync,@@ -180,10 +180,12 @@ function writeFileAtomicSync(} catch {/* target does not exist yet — proceed with the atomic path */}- const tmpPath = `${targetPath}.bla-tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 8)}`;+ const tmpPath = `${targetPath}.bla-tmp-${process.pid}-${randomBytes(8).toString("hex")}`;try {- if (encoding) writeFileSync(tmpPath, content, encoding);- else writeFileSync(tmpPath, content);+ // Exclusive create: a pre-planted symlink or file at the temp path must+ // fail (EEXIST) instead of being followed.+ if (encoding) writeFileSync(tmpPath, content, { encoding, flag: "wx" });+ else writeFileSync(tmpPath, content, { flag: "wx" });renameSync(tmpPath, targetPath);} catch (err) {try {diff --git a/src/setup/setup.ts b/src/setup/setup.tsindex de86c0b..d4b6aa6 100644--- a/src/setup/setup.ts+++ b/src/setup/setup.ts@@ -1,4 +1,4 @@-import { createHash } from "node:crypto";+import { createHash, randomBytes } from "node:crypto";import {existsSync,mkdirSync,@@ -174,9 +174,9 @@ function isBlaOwnedMcpEntry(entry: McpServerRegistration): boolean {function writeFileAtomicSync(targetPath: string, content: string | Buffer): void {const dir = dirname(targetPath);mkdirSync(dir, { recursive: true });- const tmpPath = `${targetPath}.bla-tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2, 8)}`;+ const tmpPath = `${targetPath}.bla-tmp-${process.pid}-${randomBytes(8).toString("hex")}`;try {- writeFileSync(tmpPath, content);+ writeFileSync(tmpPath, content, { flag: "wx" });renameSync(tmpPath, targetPath);} catch (err) {try {