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.

fix(lint-lanes): ignore all-zero init arrays as compare tables

qybaihebef271af6a12
diff --git a/src/engine/lane-independence-lint.ts b/src/engine/lane-independence-lint.ts
index 11fd035..6a60e20 100644
--- a/src/engine/lane-independence-lint.ts
+++ b/src/engine/lane-independence-lint.ts
@@ -82,13 +82,18 @@ export function lintLaneIndependence(source: string): LaneIndependenceReport {
if (BYTE_COMPARE_ARRAY.test(text) && /(?:key|guess|input|lane)/i.test(text)) {
const m = text.match(BYTE_COMPARE_ARRAY);
- findings.push(
- finding(
- "per-lane-byte-compare-array",
- "Literal multi-byte compare table near key/guess identifiers — may allow independent per-lane probes.",
- m?.[0] ?? "",
- ),
- );
+ // Round-2 blue: all-zero init arrays (e.g. pack buffers) are not compare tables.
+ const lit = m?.[0] ?? "";
+ const allZero = /^\[\s*0\s*(?:,\s*0\s*){3,}\]$/.test(lit);
+ if (!allZero) {
+ findings.push(
+ finding(
+ "per-lane-byte-compare-array",
+ "Literal multi-byte compare table near key/guess identifiers — may allow independent per-lane probes.",
+ lit,
+ ),
+ );
+ }
}
if (LANE_AND_REDUCE.test(text) || EVERY_INDEXED_LANE.test(text)) {
diff --git a/tests/lane-independence-lint.test.ts b/tests/lane-independence-lint.test.ts
index a1f6b56..1d9b6d2 100644
--- a/tests/lane-independence-lint.test.ts
+++ b/tests/lane-independence-lint.test.ts
@@ -59,6 +59,30 @@ describe("lane-independence footgun lint (#40.1 / red-blue round-1)", () => {
expect(report.findings[0]!.severity).toBe("error");
});
+ it("ignores all-zero init arrays used for whole-key packing (round-2 blue)", () => {
+ const src = `
+ function packWord(key, start) {
+ let w = 0;
+ for (let i = 0; i < 4; i++) w = (w << 8) | key.charCodeAt(start + i);
+ return w | 0;
+ }
+ function activate(key) {
+ let a = packWord(key, 0), b = packWord(key, 4), c = packWord(key, 8), d = packWord(key, 12);
+ // legacy-looking zero buffer that is NOT a compare table:
+ const scratch = [0, 0, 0, 0];
+ void scratch;
+ for (let r = 0; r < 24; r++) {
+ a = (a + b) | 0; b = (b ^ a) | 0; c = (c + d) | 0; d = (d ^ c) | 0;
+ a ^= c; b ^= d;
+ }
+ return (a ^ b ^ c ^ d) === 0x12345678;
+ }
+ `;
+ const report = lintLaneIndependence(src);
+ expect(report.findings.some((f) => f.id === "per-lane-byte-compare-array")).toBe(false);
+ expect(report.looksLaneIndependent).toBe(false);
+ });
+
it("errors on CrackMe v6-style per-byte WASM lane oracles", () => {
const tpl = readFileSync(
resolve(process.cwd(), "challenge/v6/src/vault.template.cjs"),