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.

Red/Blue round-9 ยท Blue

qybaihe7006226c2cf3
diff --git a/.agents/skills/blind-llm-agents/SKILL.md b/.agents/skills/blind-llm-agents/SKILL.md
index 83c3d61..faeb69d 100644
--- a/.agents/skills/blind-llm-agents/SKILL.md
+++ b/.agents/skills/blind-llm-agents/SKILL.md
@@ -7,7 +7,7 @@ description: >
Agents). Prefer this skill as the guide; call existing MCP tools / CLI โ€” do not invent
new MCP tools. Default verb: bla_harden. Refuse crack/RE of third-party software.
metadata:
- version: "1.5.14"
+ version: "1.5.15"
---
# BLA: Blind LLM Agents
@@ -24,7 +24,7 @@ model misjudgment on proprietary logic, or **one-click / ไธ€้”ฎๅŠ ๅ›บ** a build.
Defensive only: protect **their own** artifacts. Refuse crack, RE, bypass PoCs, or
attack playbooks against software they do not own.
-**Principles (red-blue round-1+2+3+4+5+6+7+7b+8):** do not ship a stable public WASM ABI without an explicit `wasm_preserve_exports` list; do not leave JS-side independent lane tables โ€” prefer whole-key chained mixing (`bla_lint_lanes` / harden refuse). **Do not** place plaintext seal/catalog JSON (`revision`, salts, certificate ciphertext) beside hardened outputs. Public compare targets must be **one-way** (SHA-256/HMAC/etc.); reversible ARX/Feistel digests as public `revision` are a key-recovery footgun (round-2 break โ€” **closed in round-3** when seal is digests-only). Enforce with `bla_lint_seal` / `bla lint-seal`; bankrupt harden **refuses** unless `allow_plaintext_seal` / `--allow-plaintext-seal`. Round-3 residual **gates**: `bla_lint_wasm_params` / `bla lint-wasm-params` โ€” bankrupt refuses clear `R2SEAL`/`R3PARM`/`R3CIPH`-class carriers unless `allow_wasm_clear_params`; `bla_lint_panel_derive` โ€” maximum/bankrupt **rewrites** `__vaultPanelDerive_*` to `_blaPd_*` unless `allow_stable_panel_derive`; bankrupt harden sets `selfSealRecommended` for multi-artifact trees (never auto for single-file) โ€” prefer **`self_seal`**. Round-4 gates: `bla_lint_js_aes_unwrap` / `bla lint-js-aes-unwrap` โ€” bankrupt **refuses** JS wrap-key + `create*iv` + fixed sealed hdr (e.g. `d17ea004`) unless `allow_js_aes_unwrap` (gate only โ€” **not** white-box AES; prefer in-WASM unwrap). `bla_lint_panel_derive` flags `deriveLocal` (rewritten to `_blaPdLocal_*`) and **refuses** `deriveLocal` + plaintext `panelTokenSha256` offline-oracle packaging unless `allow_panel_offline_oracle` (rename is not a crypto fix โ€” scrub digests / avoid derive UI). `self_seal` embeds **expected sibling SHA-256 hard-fail** when siblings exist at protect time (harden processes JS last); opaque-seed entanglement alone does **not** gate entitlement control flow. Round-5 gates: `bla_lint_js_wasm_hydrate_dump` / `bla lint-js-wasm-hydrate-dump` โ€” bankrupt **refuses** JS that copies salt/rounds/cipher from `WebAssembly.Memory` after hydrate/instantiate unless `allow_js_wasm_hydrate_dump` (host memory dump needs **no** Node `create*iv`; export rename alone does not close this โ€” prefer keep ARX+certify **inside** WASM so params never re-enter JS). Round-6 product pattern: export `unlock(keyPtr,keyLen)->outLen` (or equivalent) so ARX+compare+decrypt stay in WASM; JS only writes key bytes and reads the result โ€” do **not** call hydrate then decode salt/rounds/cipher in JS (closes the round-5 host memory-dump residual under bankrupt defaults). Honesty: WASM reverse-engineering of the unlock body remains a theoretical surface; gates do not claim white-box secrecy. Round-6 **break residual**: do **not** store a plaintext XOR mask adjacent to a masked entitlement pack (`salt||rounds||expected-words||cipher`) in WASM data โ€” static unmask needs no key; combined with invertible ARX expected-state compare this recovers the prize (`bla_lint_wasm_xor_mask_sidecar` / `bla lint-wasm-xor-mask-sidecar`; bankrupt refuses unless `allow_wasm_xor_mask_sidecar`). Prefer key-dependent unmask and **one-way** commitments inside WASM (not reversible expected words). Round-7 product pattern: keep unlock-in-WASM; derive the XOR mask from the key inside `unlock` (do **not** embed a plaintext mask beside the blob); store a SHA-256 commitment of the ARX state for compare (not invertible expected words). Round-7 **break residual**: do **not** place public `seal.revision` (or other public digests) as plaintext under a repeating XOR mask in WASM data โ€” `revision` XOR `masked[8..40)` recovers the mask with no key; combined with an algebraically weak key-dependent mask KDF this recovers the prize (`bla_lint_wasm_seal_xor_known_plaintext` / `bla lint-wasm-seal-xor-known-plaintext`; bankrupt refuses unless `allow_wasm_seal_xor_known_plaintext`). Prefer a one-way mask KDF (e.g. SHA-256(key||i)) and keep public digests **out** of the masked plaintext prefix (or bind revision differently). Round-8 product pattern: derive the XOR mask with a **one-way** KDF such as `SHA-256(key[16])` (never an algebraically invertible byte mix); put an entropy/random pad โ€” **not** `seal.revision` โ€” in the masked pack prefix; keep the SHA-256 ARX commitment in a **separate clear data segment** (or otherwise outside the XOR-masked layout) so public digests cannot serve as XOR known-plaintext. Honesty: full WASM reverse-engineering of unlock can still recover algorithms; gates close packaging footguns, not white-box secrecy. Round-8 **red (NO PRIZE)**: SHA-256(key) mask KDF + commitment-outside-XOR **held** against the round-7 seal.revision XOR known-plaintext oracle and algebraic mask invert; residuals โ€” structural KP of fixed rounds/zero pad3 leaks only a few mask bytes; arity-2 decoy aliases; bankrupt JS decoys may false-positive `bla_lint_lanes` on hardened *output*; online guessing after full WASM RE remains a theoretical surface (not a packaging refuse gate).
+**Principles (red-blue round-1+2+3+4+5+6+7+7b+8+9):** do not ship a stable public WASM ABI without an explicit `wasm_preserve_exports` list; do not leave JS-side independent lane tables โ€” prefer whole-key chained mixing (`bla_lint_lanes` / harden refuse). **Do not** place plaintext seal/catalog JSON (`revision`, salts, certificate ciphertext) beside hardened outputs. Public compare targets must be **one-way** (SHA-256/HMAC/etc.); reversible ARX/Feistel digests as public `revision` are a key-recovery footgun (round-2 break โ€” **closed in round-3** when seal is digests-only). Enforce with `bla_lint_seal` / `bla lint-seal`; bankrupt harden **refuses** unless `allow_plaintext_seal` / `--allow-plaintext-seal`. Round-3 residual **gates**: `bla_lint_wasm_params` / `bla lint-wasm-params` โ€” bankrupt refuses clear `R2SEAL`/`R3PARM`/`R3CIPH`-class carriers unless `allow_wasm_clear_params`; `bla_lint_panel_derive` โ€” maximum/bankrupt **rewrites** `__vaultPanelDerive_*` to `_blaPd_*` unless `allow_stable_panel_derive`; bankrupt harden sets `selfSealRecommended` for multi-artifact trees (never auto for single-file) โ€” prefer **`self_seal`**. Round-4 gates: `bla_lint_js_aes_unwrap` / `bla lint-js-aes-unwrap` โ€” bankrupt **refuses** JS wrap-key + `create*iv` + fixed sealed hdr (e.g. `d17ea004`) unless `allow_js_aes_unwrap` (gate only โ€” **not** white-box AES; prefer in-WASM unwrap). `bla_lint_panel_derive` flags `deriveLocal` (rewritten to `_blaPdLocal_*`) and **refuses** `deriveLocal` + plaintext `panelTokenSha256` offline-oracle packaging unless `allow_panel_offline_oracle` (rename is not a crypto fix โ€” scrub digests / avoid derive UI). `self_seal` embeds **expected sibling SHA-256 hard-fail** when siblings exist at protect time (harden processes JS last); opaque-seed entanglement alone does **not** gate entitlement control flow. Round-5 gates: `bla_lint_js_wasm_hydrate_dump` / `bla lint-js-wasm-hydrate-dump` โ€” bankrupt **refuses** JS that copies salt/rounds/cipher from `WebAssembly.Memory` after hydrate/instantiate unless `allow_js_wasm_hydrate_dump` (host memory dump needs **no** Node `create*iv`; export rename alone does not close this โ€” prefer keep ARX+certify **inside** WASM so params never re-enter JS). Round-6 product pattern: export `unlock(keyPtr,keyLen)->outLen` (or equivalent) so ARX+compare+decrypt stay in WASM; JS only writes key bytes and reads the result โ€” do **not** call hydrate then decode salt/rounds/cipher in JS (closes the round-5 host memory-dump residual under bankrupt defaults). Honesty: WASM reverse-engineering of the unlock body remains a theoretical surface; gates do not claim white-box secrecy. Round-6 **break residual**: do **not** store a plaintext XOR mask adjacent to a masked entitlement pack (`salt||rounds||expected-words||cipher`) in WASM data โ€” static unmask needs no key; combined with invertible ARX expected-state compare this recovers the prize (`bla_lint_wasm_xor_mask_sidecar` / `bla lint-wasm-xor-mask-sidecar`; bankrupt refuses unless `allow_wasm_xor_mask_sidecar`). Prefer key-dependent unmask and **one-way** commitments inside WASM (not reversible expected words). Round-7 product pattern: keep unlock-in-WASM; derive the XOR mask from the key inside `unlock` (do **not** embed a plaintext mask beside the blob); store a SHA-256 commitment of the ARX state for compare (not invertible expected words). Round-7 **break residual**: do **not** place public `seal.revision` (or other public digests) as plaintext under a repeating XOR mask in WASM data โ€” `revision` XOR `masked[8..40)` recovers the mask with no key; combined with an algebraically weak key-dependent mask KDF this recovers the prize (`bla_lint_wasm_seal_xor_known_plaintext` / `bla lint-wasm-seal-xor-known-plaintext`; bankrupt refuses unless `allow_wasm_seal_xor_known_plaintext`). Prefer a one-way mask KDF (e.g. SHA-256(key||i)) and keep public digests **out** of the masked plaintext prefix (or bind revision differently). Round-8 product pattern: derive the XOR mask with a **one-way** KDF such as `SHA-256(key[16])` (never an algebraically invertible byte mix); put an entropy/random pad โ€” **not** `seal.revision` โ€” in the masked pack prefix; keep the SHA-256 ARX commitment in a **separate clear data segment** (or otherwise outside the XOR-masked layout) so public digests cannot serve as XOR known-plaintext. Honesty: full WASM reverse-engineering of unlock can still recover algorithms; gates close packaging footguns, not white-box secrecy. Round-8 **red (NO PRIZE)**: SHA-256(key) mask KDF + commitment-outside-XOR **held** against the round-7 seal.revision XOR known-plaintext oracle and algebraic mask invert; residuals โ€” structural KP of fixed rounds/zero pad3 leaks only a few mask bytes; arity-2 decoy aliases; bankrupt JS decoys may false-positive `bla_lint_lanes` on hardened *output*; online guessing after full WASM RE remains a theoretical surface (not a packaging refuse gate). Round-9 product pattern: keep R8 SHA-256(key) mask KDF + commitment-outside-XOR; **randomize pack header `pad3`** and avoid fixed `rounds` immediates (seed-derived rounds in-range) so structural KP cannot leak `mask[4..7]`; emit bankrupt shadow-heap decoy shares/words in **non-lane-array shapes** (CSVโ†’map / 2+2 concat) so re-linting hardened output does not false-positive `bla_lint_lanes`; host probes all arity-2 exports for FLAG{-shaped results. Honesty: full WASM RE + online guessing remain theoretical; never embed harden `--seed` in artifacts.
## Prerequisites (once)
diff --git a/src/shields/deception/shadow-business-logic.ts b/src/shields/deception/shadow-business-logic.ts
index c117ddd..908f2b7 100644
--- a/src/shields/deception/shadow-business-logic.ts
+++ b/src/shields/deception/shadow-business-logic.ts
@@ -98,7 +98,8 @@ export function generateShadowBusinessLogic(
shadowProceduresCreated.push(fnName);
decoyConstantsCount += 4;
blocks.push(
- `function ${fnName}(frameBytes = [0x42, 0x4c, 0x41, 0x03], ratchetStep = 0) {`,
+ // Default frame as 2+2 concat โ€” avoids lane-lint BYTE_COMPARE_ARRAY (R9 blue)
+ `function ${fnName}(frameBytes = [0x42, 0x4c].concat([0x41, 0x03]), ratchetStep = 0) {`,
` const FRAME_MAGIC = 0x424c4103;`,
` const NONCE_MASK = 0x${prng.hex(6)};`,
` let crc = 0xffffffff;`,
diff --git a/src/shields/runtime/memory-diff-shield.ts b/src/shields/runtime/memory-diff-shield.ts
index 9ee57c9..71d0123 100644
--- a/src/shields/runtime/memory-diff-shield.ts
+++ b/src/shields/runtime/memory-diff-shield.ts
@@ -72,8 +72,9 @@ export function generateShadowHeapChurnShield(
: i % 4 === 2
? "tpm2_pcr_quote_digest"
: "enclave_session_ratchet";
+ // words as 2+2 concat โ€” avoids lane-lint BYTE_COMPARE_ARRAY ([n,n,n,n+] literals)
initialSlots.push(
- ` { slotId: ${i}, kind: "${kind}", epoch: ${w0}, words: [${w0}, ${w1}, ${w2}, ${w3}], hmacTag: 0x${prng.hex(6)} }`,
+ ` { slotId: ${i}, kind: "${kind}", epoch: ${w0}, words: [${w0}, ${w1}].concat([${w2}, ${w3}]), hmacTag: 0x${prng.hex(6)} }`,
);
}
@@ -105,8 +106,9 @@ export function generateShadowHeapChurnShield(
` cursor: 0,`,
` tick: 1,`,
` rollingMask: 0x${prng.hex(6)},`,
- ` splitShareA: [${decoySecret.shareA.join(", ")}],`,
- ` splitShareB: [${decoySecret.shareB.join(", ")}],`,
+ // CSVโ†’map avoids lane-lint BYTE_COMPARE_ARRAY on bankrupt output (R8 red residual / R9 blue)
+ ` splitShareA: "${decoySecret.shareA.join(",")}".split(",").map(function (n) { return n | 0; }),`,
+ ` splitShareB: "${decoySecret.shareB.join(",")}".split(",").map(function (n) { return n | 0; }),`,
` slots: [`,
initialSlots.join(",\n"),
` ],`,
diff --git a/tests/runtime-memory-diff-shield.test.ts b/tests/runtime-memory-diff-shield.test.ts
index 36d4052..eb15533 100644
--- a/tests/runtime-memory-diff-shield.test.ts
+++ b/tests/runtime-memory-diff-shield.test.ts
@@ -11,6 +11,7 @@ import { generateFridaCaptureSaturation } from "../src/shields/exhaustion/frida-
import { REA_BUDGET_BREAKER_MATRIX } from "../src/shields/exhaustion/rea-budget-matrix.js";
import { transformJavaScriptWithBlaShield } from "../src/shields/javascript/ast-shield.js";
import { emitCompileTimeNativeHeader } from "../src/shields/formats/headers.js";
+import { lintLaneIndependence } from "../src/engine/lane-independence-lint.js";
describe("Counter-REA Runtime Memory Diff & Heap Churn Shield", () => {
it("Floods M0 -> M1 differential memory snapshots with > 35 synchronized decoy mutations on every function call", () => {
@@ -128,6 +129,24 @@ describe("Counter-REA Runtime Memory Diff & Heap Churn Shield", () => {
}
});
+
+ it("R9: shadow-heap decoy tables avoid lane-lint BYTE_COMPARE_ARRAY even beside key identifiers", () => {
+ const prng = new SeededPrng("r9-lane-quiet-decoy");
+ const shield = generateShadowHeapChurnShield(prng, "bankrupt");
+ // Must not emit [n, n, n, n+] numeric literals (R8 red residual โ†’ R9 blue).
+ expect(shield.code).not.toMatch(
+ /\[\s*(?:0x[0-9a-fA-F]+|\d+)\s*(?:,\s*(?:0x[0-9a-fA-F]+|\d+)\s*){3,}\]/,
+ );
+ expect(shield.code).toContain('splitShareA: "');
+ expect(shield.code).toContain(".split(\",\").map");
+ expect(shield.code).toContain(".concat([");
+ const report = lintLaneIndependence(
+ "// key guess input lane entitlement gate\n" + shield.code,
+ );
+ expect(report.looksLaneIndependent).toBe(false);
+ expect(report.findings).toEqual([]);
+ });
+
it("Triggers Frida capture saturation and realm-agnostic ring churn even when globalThis.Frida is isolated in Frida Gum", () => {
const prng = new SeededPrng("frida-realm-isolated");
const sat = generateFridaCaptureSaturation(prng, "bankrupt");