Skip to content

armgit / bla

Public Imported from GitHub
0

🛡️ 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.

feat(engine): surface wasmExportRenameApplied and feed honesty into defend verify

qybaihe6fe26a009ddb
diff --git a/src/core/types.ts b/src/core/types.ts
index cb2ba9f..2478e0d 100644
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -196,6 +196,8 @@ export interface ProtectionResult {
readonly weaveDecoys?: boolean;
/** Present when protect was called with selfSeal:true (JS self-integrity binding active). */
readonly selfSeal?: boolean;
+ /** Present when WASM export rename actually rewrote at least one non-preserved export (#40.3). */
+ readonly wasmExportRenameApplied?: boolean;
readonly seed: string;
readonly originalSha256: string;
readonly protectedSha256: string;
diff --git a/src/engine/defender.ts b/src/engine/defender.ts
index c93acfc..44097df 100644
--- a/src/engine/defender.ts
+++ b/src/engine/defender.ts
@@ -119,7 +119,10 @@ export function defendTarget(options: OneClickDefenseOptions): OneClickDefenseRe
});
// Stage 4: Verify Counter-REA Invariants
- const verification = verifyTarget(protection.outputPath, absInput);
+ const verification = verifyTarget(protection.outputPath, absInput, {
+ selfSealEnabled: options.selfSeal === true || protection.selfSeal === true,
+ wasmExportRenameApplied: protection.wasmExportRenameApplied === true,
+ });
const afterEst = protection.afterAudit.agentEstimates[0]!;
const exhaustionSummary = {
diff --git a/src/engine/protector.ts b/src/engine/protector.ts
index 1da5916..7436b58 100644
--- a/src/engine/protector.ts
+++ b/src/engine/protector.ts
@@ -189,6 +189,7 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
let chaffPayloadsEmbedded = 0;
let honeySourceMapsGenerated = 0;
let binarySectionsPatched = 0;
+ let wasmExportsRenamed = 0;
/** Inline `<script>` bodies whose AST shield threw and were shipped unchanged. */
let inlineScriptsFailed = 0;
const counteredVectors = new Set<ReaAttackVectorId>();
@@ -391,12 +392,18 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
counteredVectors.add("asar-header-admission");
} else if (format === "wasm") {
const rawWasm = readFileSync(absInput);
- const res = protectWasmBinary(rawWasm, { intensity, seed });
+ const res = protectWasmBinary(rawWasm, {
+ intensity,
+ seed,
+ // Issue #40.3: rename internal-looking exports at maximum/bankrupt by default;
+ // customers can pass preserveExports via future config — public ABI names stay.
+ });
writeFileAtomicSync(absOutput, res.buffer);
decoyFunctionsInjected = 16;
fakeCrossReferencesCreated = 24;
chaffPayloadsEmbedded = res.chaffPayloadsEmbedded;
binarySectionsPatched = res.customSectionsAdded;
+ wasmExportsRenamed = res.exportsRenamed.length;
counteredVectors.add("wasm-wat-interface");
counteredVectors.add("obligation-ledger-cloning");
} else if (format === "python-source") {
@@ -685,6 +692,7 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
intensity,
...(options.weaveDecoys === true ? { weaveDecoys: true as const } : {}),
...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(wasmExportsRenamed > 0 ? { wasmExportRenameApplied: true as const } : {}),
seed,
originalSha256: beforeAudit.sha256,
protectedSha256: afterAudit.sha256,