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(harden/mcp): bankrupt refuse WASM carriers; rewrite panel; recommend self_seal

qybaiheac08781c4da2
diff --git a/src/cli.ts b/src/cli.ts
index 634f3bb..c1f431d 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -13,6 +13,8 @@ import { defendTarget } from "./engine/defender.js";
import { formatHardenProjectReport, hardenProject } from "./engine/harden.js";
import { lintLaneIndependence } from "./engine/lane-independence-lint.js";
import { lintSealCommitmentFile } from "./engine/seal-commitment-lint.js";
+import { lintWasmParamCarrierFile } from "./engine/wasm-param-carrier-lint.js";
+import { lintPanelDeriveAbiFile } from "./engine/panel-derive-abi-lint.js";
import { runShowcaseBenchmark } from "./engine/benchmark.js";
import {
emitCompileTimeNativeHeader,
@@ -53,6 +55,8 @@ Commands:
inspect-release <target> Read-only local source-map & symbol exposure check
audit <target> Pre-flight REA exposure & vulnerability scan
lint-lanes <file> Heuristic ERROR if gate code looks lane-independent (issue #40.1); exit 2
+ lint-wasm-params <file> Heuristic ERROR if WASM embeds clear R3PARM/R3CIPH/R2SEAL-class carriers; exit 2
+ lint-panel-derive <file> Heuristic ERROR if stable __vaultPanelDerive_* ABI remains; exit 2
lint-seal <file> Heuristic lint for plaintext/reversible seal sidecars (red-blue round-2); exit 2 on error
protect <target> Inject multi-layer Counter-REA adversarial shield
verify <target> [original] Verify Counter-REA defense invariants & token amplification
@@ -102,6 +106,8 @@ interface ParsedCliArgs {
readonly wasmPreserveExports: readonly string[];
readonly allowLaneIndependentGates: boolean;
readonly allowPlaintextSeal: boolean;
+ readonly allowWasmClearParamCarriers: boolean;
+ readonly allowStablePanelDeriveAbi: boolean;
readonly lang: NativeHeaderLanguage;
readonly clients: SupportedAgentClientId[];
readonly allDetected: boolean;
@@ -130,6 +136,8 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {
let wasmPreserveExports: string[] = [];
let allowLaneIndependentGates = false;
let allowPlaintextSeal = false;
+ let allowWasmClearParamCarriers = false;
+ let allowStablePanelDeriveAbi = false;
let lang: NativeHeaderLanguage = "c";
const clients: SupportedAgentClientId[] = [];
let allDetected = false;
@@ -174,6 +182,10 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {
allowLaneIndependentGates = true;
} else if (arg === "--allow-plaintext-seal") {
allowPlaintextSeal = true;
+ } else if (arg === "--allow-wasm-clear-params") {
+ allowWasmClearParamCarriers = true;
+ } else if (arg === "--allow-stable-panel-derive") {
+ allowStablePanelDeriveAbi = true;
} else if (arg.startsWith("--wasm-preserve-exports=")) {
wasmPreserveExports = arg
.slice("--wasm-preserve-exports=".length)
@@ -231,6 +243,8 @@ export function parseCliArgs(argv: readonly string[]): ParsedCliArgs {
wasmPreserveExports,
allowLaneIndependentGates,
allowPlaintextSeal,
+ allowWasmClearParamCarriers,
+ allowStablePanelDeriveAbi,
lang,
clients,
allDetected,
@@ -368,6 +382,12 @@ export async function runCli(argv: readonly string[] = process.argv.slice(2)): P
allowPlaintextSeal:
parsed.allowPlaintextSeal ||
loaded.config.allowPlaintextSeal === true,
+ allowWasmClearParamCarriers:
+ parsed.allowWasmClearParamCarriers ||
+ loaded.config.allowWasmClearParamCarriers === true,
+ allowStablePanelDeriveAbi:
+ parsed.allowStablePanelDeriveAbi ||
+ loaded.config.allowStablePanelDeriveAbi === true,
...(parsed.output !== undefined ? { outputDirectory: parsed.output } : {}),
});
if (parsed.json) {
@@ -414,6 +434,12 @@ export async function runCli(argv: readonly string[] = process.argv.slice(2)): P
allowPlaintextSeal:
parsed.allowPlaintextSeal ||
loaded.config.allowPlaintextSeal === true,
+ allowWasmClearParamCarriers:
+ parsed.allowWasmClearParamCarriers ||
+ loaded.config.allowWasmClearParamCarriers === true,
+ allowStablePanelDeriveAbi:
+ parsed.allowStablePanelDeriveAbi ||
+ loaded.config.allowStablePanelDeriveAbi === true,
});
if (parsed.sarif) {
console.log(
@@ -478,6 +504,54 @@ export async function runCli(argv: readonly string[] = process.argv.slice(2)): P
? 2
: 0;
}
+ case "lint-wasm-params": {
+ const target = parsed.positionals[0];
+ if (!target) {
+ console.error("Error: Missing <file> path for `bla lint-wasm-params <file>`.");
+ return 1;
+ }
+ const report = lintWasmParamCarrierFile(resolve(target));
+ if (parsed.json) {
+ console.log(JSON.stringify(report, null, 2));
+ } else {
+ console.log(`BLA wasm-param-carrier lint β€” ${report.path}`);
+ console.log(report.oneLineAdvice);
+ for (const f of report.findings) {
+ console.log(` [${f.severity}] ${f.id}: ${f.summary} @${f.offset}`);
+ if (f.evidence) console.log(` evidence: ${f.evidence}`);
+ }
+ if (report.findings.length === 0) {
+ console.log(" (no findings)");
+ }
+ }
+ return report.shouldRefuseBankrupt || report.findings.some((f) => f.severity === "error")
+ ? 2
+ : 0;
+ }
+ case "lint-panel-derive": {
+ const target = parsed.positionals[0];
+ if (!target) {
+ console.error("Error: Missing <file> path for `bla lint-panel-derive <file>`.");
+ return 1;
+ }
+ const report = lintPanelDeriveAbiFile(resolve(target));
+ if (parsed.json) {
+ console.log(JSON.stringify(report, null, 2));
+ } else {
+ console.log(`BLA panel-derive ABI lint β€” ${report.path}`);
+ console.log(report.oneLineAdvice);
+ for (const f of report.findings) {
+ console.log(` [${f.severity}] ${f.id}: ${f.summary}`);
+ if (f.evidence) console.log(` evidence: ${f.evidence}`);
+ }
+ if (report.findings.length === 0) {
+ console.log(" (no findings)");
+ }
+ }
+ return report.shouldRewriteOrRefuse || report.findings.some((f) => f.severity === "error")
+ ? 2
+ : 0;
+ }
case "audit": {
const loaded = loadBlaConfig(process.cwd(), parsed.configPath);
const target = parsed.positionals[0] ?? loaded.config.input;
@@ -530,6 +604,12 @@ export async function runCli(argv: readonly string[] = process.argv.slice(2)): P
allowPlaintextSeal:
parsed.allowPlaintextSeal ||
loaded.config.allowPlaintextSeal === true,
+ allowWasmClearParamCarriers:
+ parsed.allowWasmClearParamCarriers ||
+ loaded.config.allowWasmClearParamCarriers === true,
+ allowStablePanelDeriveAbi:
+ parsed.allowStablePanelDeriveAbi ||
+ loaded.config.allowStablePanelDeriveAbi === true,
});
if (parsed.json) console.log(JSON.stringify(res, null, 2));
else console.log(formatProtectionResult(res));
diff --git a/src/core/config.ts b/src/core/config.ts
index 12d1296..eabc1ab 100644
--- a/src/core/config.ts
+++ b/src/core/config.ts
@@ -26,6 +26,10 @@ export interface BlaProjectConfig {
readonly allowLaneIndependentGates?: boolean;
/** When true, allow bankrupt harden despite plaintext/reversible seal sidecars (red-blue round-2). Default false. */
readonly allowPlaintextSeal?: boolean;
+ /** When true, allow bankrupt despite clear WASM param/cipher carriers (red-blue round-3). Default false. */
+ readonly allowWasmClearParamCarriers?: boolean;
+ /** When true, keep stable __vaultPanelDerive_* ABI (red-blue round-3). Default false. */
+ readonly allowStablePanelDeriveAbi?: boolean;
}
/**
diff --git a/src/core/types.ts b/src/core/types.ts
index f7affb0..6aa6431 100644
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -185,6 +185,21 @@ export interface ProtectionOptions {
* sidecars (red-blue round-2). Default false β€” refuse.
*/
readonly allowPlaintextSeal?: boolean;
+ /**
+ * When true, allow bankrupt harden/protect despite clear WASM param/cipher
+ * ASCII carriers (R3PARM/R3CIPH/R2SEAL-class; red-blue round-3). Default false β€” refuse.
+ */
+ readonly allowWasmClearParamCarriers?: boolean;
+ /**
+ * When true, keep stable `__vaultPanelDerive_*` ABI (skip rewrite/refuse).
+ * Default false β€” maximum/bankrupt rewrite to seed-stable `_blaPd_*` (red-blue round-3).
+ */
+ readonly allowStablePanelDeriveAbi?: boolean;
+ /**
+ * Optional sibling paths for self-seal when `selfSeal` is true (multi-artifact harden).
+ * Relative paths are resolved from the protected module's directory at runtime.
+ */
+ readonly selfSealSiblingPaths?: readonly string[];
}
export interface ProtectionMetrics {
diff --git a/src/engine/auditor.ts b/src/engine/auditor.ts
index 061158a..e8cda43 100644
--- a/src/engine/auditor.ts
+++ b/src/engine/auditor.ts
@@ -15,6 +15,8 @@ import type {
} from "../core/types.js";
import { unpackAsarBuffer } from "../shields/formats/asar.js";
import { inspectWasmBinary } from "../shields/formats/wasm.js";
+import { lintWasmParamCarrierBuffer } from "./wasm-param-carrier-lint.js";
+import { lintPanelDeriveAbiSource } from "./panel-derive-abi-lint.js";
import { inspectPythonPyc } from "../shields/formats/python.js";
import { inspectNativeBinary } from "../shields/formats/native.js";
import { detectBunStandaloneGraph } from "../shields/formats/bun-standalone.js";
@@ -488,6 +490,20 @@ export function auditTarget(targetPath: string): AuditReport {
const res = analyzeJsSourceForAudit(text, basename(absPath));
sim = res.sim;
exposedItems.push(...res.exposed);
+ const panelLint = lintPanelDeriveAbiSource(text, { path: absPath });
+ for (const f of panelLint.findings) {
+ exposedItems.push({
+ id: `panel_derive_${f.id}`,
+ name: f.id,
+ kind: "export",
+ location: basename(absPath),
+ riskLevel: f.severity === "error" ? "high" : "medium",
+ reaToolUsed: "bla lint-panel-derive / static source scan",
+ estimatedTokensToReconstruct: 1_200,
+ estimatedCostUsd: 0.05,
+ reason: f.summary,
+ });
+ }
res.vectors.forEach((v) => vulnerableVectors.add(v));
} else if (format === "html-bundle") {
const htmlText = rawBytes.toString("utf8");
@@ -647,6 +663,20 @@ export function auditTarget(targetPath: string): AuditReport {
: "Unshielded WASM export directly decompilable to WAT by REA",
});
}
+ const parmLint = lintWasmParamCarrierBuffer(rawBytes, { path: absPath });
+ for (const f of parmLint.findings) {
+ exposedItems.push({
+ id: `wasm_parm_${f.magic}_${f.offset}`,
+ name: f.magic,
+ kind: "metadata-section",
+ location: `${basename(absPath)} (data @${f.offset})`,
+ riskLevel: "high",
+ reaToolUsed: "bla lint-wasm-params / static data-section scan",
+ estimatedTokensToReconstruct: 4_500,
+ estimatedCostUsd: 0.25,
+ reason: f.summary,
+ });
+ }
sim = {
...sim,
examinationStatus: isProtected ? "limited" : "complete",
diff --git a/src/engine/defender.ts b/src/engine/defender.ts
index a6a7e14..79e4ef9 100644
--- a/src/engine/defender.ts
+++ b/src/engine/defender.ts
@@ -33,6 +33,12 @@ export interface OneClickDefenseOptions {
readonly allowLaneIndependentGates?: boolean;
/** Allow bankrupt despite plaintext/reversible seal sidecars (red-blue round-2). Default false. */
readonly allowPlaintextSeal?: boolean;
+ /** Allow bankrupt despite clear WASM param/cipher carriers (red-blue round-3). Default false. */
+ readonly allowWasmClearParamCarriers?: boolean;
+ /** Keep stable __vaultPanelDerive_* ABI (red-blue round-3). Default false β€” rewrite. */
+ readonly allowStablePanelDeriveAbi?: boolean;
+ /** Sibling paths forwarded into self-seal when enabled (multi-artifact harden). */
+ readonly selfSealSiblingPaths?: readonly string[];
}
export interface OneClickDefenseStageSummary {
@@ -128,6 +134,16 @@ export function defendTarget(options: OneClickDefenseOptions): OneClickDefenseRe
? { allowLaneIndependentGates: true }
: {}),
...(options.allowPlaintextSeal === true ? { allowPlaintextSeal: true } : {}),
+ ...(options.allowWasmClearParamCarriers === true
+ ? { allowWasmClearParamCarriers: true }
+ : {}),
+ ...(options.allowStablePanelDeriveAbi === true
+ ? { allowStablePanelDeriveAbi: true }
+ : {}),
+ ...(options.selfSealSiblingPaths !== undefined &&
+ options.selfSealSiblingPaths.length > 0
+ ? { selfSealSiblingPaths: options.selfSealSiblingPaths }
+ : {}),
honeySourceMaps: true,
});
diff --git a/src/engine/harden.ts b/src/engine/harden.ts
index 0c32f1f..cbb1d94 100644
--- a/src/engine/harden.ts
+++ b/src/engine/harden.ts
@@ -18,6 +18,11 @@ import {
intensityEnforcesSealRefusal,
sealCommitmentRefuseMessage,
} from "./seal-commitment-lint.js";
+import {
+ discoverAndLintWasmParamCarriers,
+ intensityEnforcesWasmParamRefusal,
+ wasmParamCarrierRefuseMessage,
+} from "./wasm-param-carrier-lint.js";
import {
computeHardenRunId,
HARDEN_SUMMARY_FILE_NAME,
@@ -112,6 +117,10 @@ export interface HardenProjectOptions {
readonly allowLaneIndependentGates?: boolean;
/** Allow bankrupt despite plaintext/reversible seal sidecars (red-blue round-2). Default false β€” refuse. */
readonly allowPlaintextSeal?: boolean;
+ /** Allow bankrupt despite clear WASM param/cipher carriers (red-blue round-3). Default false β€” refuse. */
+ readonly allowWasmClearParamCarriers?: boolean;
+ /** Keep stable __vaultPanelDerive_* ABI (red-blue round-3). Default false β€” rewrite. */
+ readonly allowStablePanelDeriveAbi?: boolean;
/** Optional output root; defaults to `<dir>/.bla-hardened`. */
readonly outputDirectory?: string;
readonly maxArtifacts?: number;
@@ -135,6 +144,14 @@ export interface HardenProjectReport {
readonly oneSentenceUsage: string;
readonly weaveDecoys: boolean;
readonly selfSeal: boolean;
+ /**
+ * True when bankrupt discovered a multi-artifact JS/WASM/HTML tree and
+ * `selfSeal` was not enabled β€” agents should pass `self_seal: true`.
+ * Never auto-enables for single-file trees.
+ */
+ readonly selfSealRecommended: boolean;
+ /** Short advice when selfSealRecommended is true. */
+ readonly selfSealRecommendation?: string;
/** True when this report is a zero-write preview. */
readonly dryRun: boolean;
/** True when discovery stopped at `maxArtifacts`; more targets exist. */
@@ -341,6 +358,12 @@ export function hardenProject(
intensityEnforcesSealRefusal(intensity) && options.allowPlaintextSeal !== true
? sealReports.filter((r) => r.shouldRefuseBankrupt)
: [];
+ const wasmParmReports = discoverAndLintWasmParamCarriers(absDir);
+ const blockingWasmParms =
+ intensityEnforcesWasmParamRefusal(intensity) &&
+ options.allowWasmClearParamCarriers !== true
+ ? wasmParmReports.filter((r) => r.shouldRefuseBankrupt)
+ : [];
const outputRoot = resolve(
options.outputDirectory ??
(statSync(absDir).isDirectory()
@@ -353,6 +376,16 @@ export function hardenProject(
});
const wouldOverwrite = plannedOutputs.filter((p) => p.outputExisted).map((p) => p.outputPath);
+ const bindableFormats = new Set(["javascript", "typescript", "wasm", "html-bundle"]);
+ const bindable = discovered.filter((a) => bindableFormats.has(a.format));
+ const selfSealRecommended =
+ intensity === "bankrupt" &&
+ bindable.length >= 2 &&
+ options.selfSeal !== true;
+ const selfSealRecommendation = selfSealRecommended
+ ? "Multi-artifact entitlement tree detected β€” pass self_seal / --self-seal so Node entry modules bind sibling JS/WASM/HTML bytes. Single-file trees stay opt-in only (never auto-enabled)."
+ : undefined;
+
const runId = computeHardenRunId({
blaVersion: BLA_IDENTITY.version,
directory: absDir,
@@ -376,6 +409,10 @@ export function hardenProject(
'Harden my software against REA β€” call bla_harden with { "directory": "." } (or `bla harden .`).',
weaveDecoys: options.weaveDecoys === true,
selfSeal: options.selfSeal === true,
+ selfSealRecommended,
+ ...(selfSealRecommendation !== undefined
+ ? { selfSealRecommendation }
+ : {}),
dryRun,
truncated: discovery.truncated,
maxArtifacts: discovery.maxArtifacts,
@@ -383,7 +420,7 @@ export function hardenProject(
runId,
} as const;
- if (blockingSeals.length > 0) {
+ if (blockingSeals.length > 0 || blockingWasmParms.length > 0) {
const sealArtifacts = blockingSeals.map((r) => ({
inputPath: r.path,
relativePath: (relative(absDir, r.path) || basename(r.path)).split(sep).join("/"),
@@ -396,11 +433,30 @@ export function hardenProject(
outputExisted: false,
error: sealCommitmentRefuseMessage(r, r.path),
}));
+ const wasmArtifacts = blockingWasmParms.map((r) => ({
+ inputPath: r.path,
+ relativePath: (relative(absDir, r.path) || basename(r.path)).split(sep).join("/"),
+ format: "wasm" as const,
+ outputPath: r.path,
+ success: false,
+ defenseScore: 0,
+ tokenAmplificationFactor: 0,
+ costAmplificationFactor: 0,
+ outputExisted: false,
+ error: wasmParamCarrierRefuseMessage(r, r.path),
+ }));
+ const blockReason =
+ blockingSeals.length > 0 && blockingWasmParms.length > 0
+ ? "skipped: plaintext/reversible seal sidecar or clear WASM param carrier blocked bankrupt harden"
+ : blockingWasmParms.length > 0
+ ? "skipped: clear WASM param/cipher carrier blocked bankrupt harden"
+ : "skipped: plaintext/reversible seal sidecar blocked bankrupt harden";
+ const blockedExtras = [...sealArtifacts, ...wasmArtifacts];
return {
...reportBase,
overallSuccess: false,
hardenedCount: 0,
- failedCount: sealArtifacts.length,
+ failedCount: blockedExtras.length,
artifacts: [
...plannedOutputs.map(({ artifact, outputPath, outputExisted }) => ({
inputPath: artifact.path,
@@ -412,11 +468,9 @@ export function hardenProject(
tokenAmplificationFactor: 0,
costAmplificationFactor: 0,
outputExisted,
- error: dryRun
- ? "skipped: plaintext/reversible seal sidecar blocked bankrupt harden"
- : "skipped: plaintext/reversible seal sidecar blocked bankrupt harden",
+ error: blockReason,
})),
- ...sealArtifacts,
+ ...blockedExtras,
],
};
}
@@ -472,6 +526,35 @@ export function hardenProject(
? { allowLaneIndependentGates: true }
: {}),
...(options.allowPlaintextSeal === true ? { allowPlaintextSeal: true } : {}),
+ ...(options.allowWasmClearParamCarriers === true
+ ? { allowWasmClearParamCarriers: true }
+ : {}),
+ ...(options.allowStablePanelDeriveAbi === true
+ ? { allowStablePanelDeriveAbi: true }
+ : {}),
+ ...((() => {
+ if (options.selfSeal !== true) return {};
+ const siblings = plannedOutputs
+ .filter(
+ (p) =>
+ p.outputPath !== outputPath &&
+ bindableFormats.has(p.artifact.format),
+ )
+ .map((p) => relative(dirname(outputPath), p.outputPath).split(sep).join("/"))
+ .filter((rel) => rel.length > 0 && !rel.startsWith(".."));
+ // Prefer same-directory / nested siblings; still pass upward-relative
+ // paths when the mirror tree places artifacts beside each other.
+ const loose = plannedOutputs
+ .filter(
+ (p) =>
+ p.outputPath !== outputPath &&
+ bindableFormats.has(p.artifact.format),
+ )
+ .map((p) => relative(dirname(outputPath), p.outputPath).split(sep).join("/"))
+ .filter((rel) => rel.length > 0);
+ const list = siblings.length > 0 ? siblings : loose;
+ return list.length > 0 ? { selfSealSiblingPaths: list } : {};
+ })()),
emitManifest,
});
summaries.push({
@@ -560,6 +643,11 @@ export function formatHardenProjectReport(report: HardenProjectReport): string {
: "PARTIAL/FAILED"
}`,
];
+ if (report.selfSealRecommended) {
+ lines.push(
+ ` ⚠ self_seal recommended: ${report.selfSealRecommendation ?? "multi-artifact tree β€” pass --self-seal / self_seal:true"}`,
+ );
+ }
for (const a of report.artifacts) {
if (report.dryRun) {
lines.push(
diff --git a/src/engine/protector.ts b/src/engine/protector.ts
index f34a7ce..490f17e 100644
--- a/src/engine/protector.ts
+++ b/src/engine/protector.ts
@@ -57,6 +57,16 @@ import {
lintSealCommitmentFile,
sealCommitmentRefuseMessage,
} from "./seal-commitment-lint.js";
+import {
+ intensityEnforcesWasmParamRefusal,
+ lintWasmParamCarrierBuffer,
+ wasmParamCarrierRefuseMessage,
+} from "./wasm-param-carrier-lint.js";
+import {
+ intensityRewritesPanelDerive,
+ lintPanelDeriveAbiSource,
+ rewriteStablePanelDeriveSymbols,
+} from "./panel-derive-abi-lint.js";
/**
* Crash-safe output write: write to a temp file in the same directory, then
@@ -65,6 +75,38 @@ import {
* hardlink targets are written through directly so in-place protection of
* aliased paths reaches the real file.
*/
+
+function selfSealTransformOption(
+ options: ProtectionOptions,
+): boolean | { readonly siblingPaths: readonly string[] } | undefined {
+ if (options.selfSeal !== true) return undefined;
+ if (options.selfSealSiblingPaths && options.selfSealSiblingPaths.length > 0) {
+ return { siblingPaths: options.selfSealSiblingPaths };
+ }
+ return true;
+}
+
+function applyPanelDeriveRewrite(
+ source: string,
+ seed: string,
+ intensity: string,
+ options: ProtectionOptions,
+ fileLabel: string,
+): string {
+ if (options.allowStablePanelDeriveAbi === true) {
+ return source;
+ }
+ if (!intensityRewritesPanelDerive(intensity)) {
+ // Still surface refuse at bankrupt if somehow rewrite intensity is off but
+ // symbols remain β€” bankrupt always rewrites; other intensities only lint via CLI.
+ return source;
+ }
+ const lint = lintPanelDeriveAbiSource(source, { path: fileLabel });
+ if (!lint.shouldRewriteOrRefuse) return source;
+ const rw = rewriteStablePanelDeriveSymbols(source, seed);
+ return rw.code;
+}
+
function writeFileAtomicSync(
targetPath: string,
content: string | Buffer,
@@ -241,11 +283,13 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
throw new Error(laneIndependenceRefuseMessage(laneReport, absInput));
}
}
- const transformed = transformJavaScriptWithBlaShield(raw, {
+ const panelSafe = applyPanelDeriveRewrite(raw, seed, intensity, options, absInput);
+ const selfSealOpt = selfSealTransformOption(options);
+ const transformed = transformJavaScriptWithBlaShield(panelSafe, {
intensity,
seed,
filename: basename(absInput),
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealOpt !== undefined ? { selfSeal: selfSealOpt } : {}),
});
let finalCode = transformed.code;
@@ -288,11 +332,20 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
if (!tagKind.executable) return fullMatch;
const currentIndex = scriptIndex++;
try {
- const res = transformJavaScriptWithBlaShield(scriptBody, {
+ const scriptSeed = `${seed}:html-script-${currentIndex}`;
+ const panelSafe = applyPanelDeriveRewrite(
+ scriptBody,
+ scriptSeed,
+ intensity,
+ options,
+ `${absInput}#script-${currentIndex}`,
+ );
+ const selfSealOpt = selfSealTransformOption(options);
+ const res = transformJavaScriptWithBlaShield(panelSafe, {
intensity,
- seed: `${seed}:html-script-${currentIndex}`,
+ seed: scriptSeed,
sourceType: tagKind.isModule ? "module" : "script",
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealOpt !== undefined ? { selfSeal: selfSealOpt } : {}),
});
inlineScriptsTransformed++;
decoyFunctionsInjected += res.decoyFunctionsInjected;
@@ -317,7 +370,7 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
intensity,
seed: `${seed}:html-bootstrap`,
sourceType: "script",
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealTransformOption(options) !== undefined ? { selfSeal: selfSealTransformOption(options)! } : {}),
});
decoyFunctionsInjected += bootstrapRes.decoyFunctionsInjected;
fakeCrossReferencesCreated += bootstrapRes.fakeCrossReferencesCreated;
@@ -363,7 +416,7 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
intensity,
seed: `${seed}:${vf.relativePath}`,
filename: vf.relativePath,
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealTransformOption(options) !== undefined ? { selfSeal: selfSealTransformOption(options)! } : {}),
});
const honey = generateHoneySourceMap(
basename(vf.relativePath),
@@ -408,14 +461,14 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
{
intensity,
seed: `${seed}:enclave-decoy`,
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealTransformOption(options) !== undefined ? { selfSeal: selfSealTransformOption(options)! } : {}),
},
);
protectedFiles.push({
relativePath: "enclave/hardware-tee-bridge.js",
content: Buffer.from(decoyBridgeJs.code, "utf8"),
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealTransformOption(options) !== undefined ? { selfSeal: selfSealTransformOption(options)! } : {}),
});
// Flood ASAR Pickle JSON header past REA DEFAULT_ASAR_MAX_HEADER_BYTES at
@@ -437,6 +490,15 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
counteredVectors.add("asar-header-admission");
} else if (format === "wasm") {
const rawWasm = readFileSync(absInput);
+ if (
+ intensityEnforcesWasmParamRefusal(intensity) &&
+ options.allowWasmClearParamCarriers !== true
+ ) {
+ const wasmParm = lintWasmParamCarrierBuffer(rawWasm, { path: absInput });
+ if (wasmParm.shouldRefuseBankrupt) {
+ throw new Error(wasmParamCarrierRefuseMessage(wasmParm, absInput));
+ }
+ }
const res = protectWasmBinary(rawWasm, {
intensity,
seed,
@@ -652,7 +714,7 @@ function protectTargetInner(options: ProtectionOptions): ProtectionResult {
intensity,
seed: `${seed}:${entry.name}`,
filename: entry.name,
- ...(options.selfSeal === true ? { selfSeal: true as const } : {}),
+ ...(selfSealTransformOption(options) !== undefined ? { selfSeal: selfSealTransformOption(options)! } : {}),
});
const honey = generateHoneySourceMap(
entry.name,
diff --git a/src/index.ts b/src/index.ts
index fd63b85..e677956 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -304,6 +304,33 @@ export {
type SealCommitmentFindingId,
type SealCommitmentSeverity,
} from "./engine/seal-commitment-lint.js";
+export {
+ lintWasmParamCarrierBuffer,
+ lintWasmParamCarrierFile,
+ discoverAndLintWasmParamCarriers,
+ wasmParamCarrierRefuseMessage,
+ intensityEnforcesWasmParamRefusal,
+ buildTestWasmWithParamCarrier,
+ WASM_PARAM_CARRIER_SCHEMA,
+ type WasmParamCarrierFinding,
+ type WasmParamCarrierReport,
+ type WasmParamCarrierFindingId,
+ type WasmParamCarrierSeverity,
+} from "./engine/wasm-param-carrier-lint.js";
+export {
+ lintPanelDeriveAbiSource,
+ lintPanelDeriveAbiFile,
+ rewriteStablePanelDeriveSymbols,
+ panelDeriveSeedRoot,
+ panelDeriveReplacementName,
+ intensityRewritesPanelDerive,
+ PANEL_DERIVE_ABI_SCHEMA,
+ type PanelDeriveFinding,
+ type PanelDeriveAbiReport,
+ type PanelDeriveFindingId,
+ type PanelDeriveSeverity,
+ type PanelDeriveRewriteResult,
+} from "./engine/panel-derive-abi-lint.js";
export {
parseWasmExportSectionPayload,
renameWasmExports,
diff --git a/src/mcp/server.ts b/src/mcp/server.ts
index c8967c1..2473993 100644
--- a/src/mcp/server.ts
+++ b/src/mcp/server.ts
@@ -17,6 +17,14 @@ import {
lintSealCommitmentFile,
type SealCommitmentReport,
} from "../engine/seal-commitment-lint.js";
+import {
+ lintWasmParamCarrierFile,
+ type WasmParamCarrierReport,
+} from "../engine/wasm-param-carrier-lint.js";
+import {
+ lintPanelDeriveAbiFile,
+ type PanelDeriveAbiReport,
+} from "../engine/panel-derive-abi-lint.js";
import {
computeArtifactRunId,
readHardenRunSummary,
@@ -152,7 +160,7 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
self_seal: {
type: "boolean",
description:
- "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Injects a self-integrity preamble and entangles the opaque-predicate seed. Default false.",
+ "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Injects a self-integrity preamble and entangles the opaque-predicate seed. For multi-artifact entitlement trees, bankrupt harden sets selfSealRecommended when this is false; enabling it auto-binds sibling JS/WASM/HTML paths. Default false β€” never auto-enabled for single-file trees.",
},
wasm_preserve_exports: {
type: "array",
@@ -170,6 +178,16 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
description:
"Allow bankrupt harden/protect despite plaintext or reversible seal/entitlement JSON sidecars. Default false β€” refuse (red-blue round-2).",
},
+ allow_wasm_clear_params: {
+ type: "boolean",
+ description:
+ "Allow bankrupt harden/protect despite clear WASM param/cipher ASCII carriers (R3PARM/R3CIPH/R2SEAL-class). Default false β€” refuse (red-blue round-3). Full data-section encryption is a follow-up.",
+ },
+ allow_stable_panel_derive: {
+ type: "boolean",
+ description:
+ "Keep stable __vaultPanelDerive_* ABI (skip rewrite). Default false β€” maximum/bankrupt rewrite to seed-stable _blaPd_* (red-blue round-3).",
+ },
seed: {
type: "string",
description: "Optional deterministic seed; when omitted, BLA uses/persists a per-project random seed in .blarc",
@@ -252,7 +270,7 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
self_seal: {
type: "boolean",
description:
- "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Injects a self-integrity preamble and entangles the opaque-predicate seed. Default false.",
+ "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Injects a self-integrity preamble and entangles the opaque-predicate seed. For multi-artifact entitlement trees, bankrupt harden sets selfSealRecommended when this is false; enabling it auto-binds sibling JS/WASM/HTML paths. Default false β€” never auto-enabled for single-file trees.",
},
wasm_preserve_exports: {
type: "array",
@@ -270,6 +288,16 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
description:
"Allow bankrupt harden/protect despite plaintext or reversible seal/entitlement JSON sidecars. Default false β€” refuse (red-blue round-2).",
},
+ allow_wasm_clear_params: {
+ type: "boolean",
+ description:
+ "Allow bankrupt harden/protect despite clear WASM param/cipher ASCII carriers (R3PARM/R3CIPH/R2SEAL-class). Default false β€” refuse (red-blue round-3). Full data-section encryption is a follow-up.",
+ },
+ allow_stable_panel_derive: {
+ type: "boolean",
+ description:
+ "Keep stable __vaultPanelDerive_* ABI (skip rewrite). Default false β€” maximum/bankrupt rewrite to seed-stable _blaPd_* (red-blue round-3).",
+ },
seed: {
type: "string",
description: "Optional deterministic seed; when omitted, BLA uses/persists a per-project random seed in .blarc",
@@ -333,7 +361,7 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
self_seal: {
type: "boolean",
description:
- "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Injects a self-integrity preamble and entangles the opaque-predicate seed. Default false.",
+ "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Injects a self-integrity preamble and entangles the opaque-predicate seed. For multi-artifact entitlement trees, bankrupt harden sets selfSealRecommended when this is false; enabling it auto-binds sibling JS/WASM/HTML paths. Default false β€” never auto-enabled for single-file trees.",
},
wasm_preserve_exports: {
type: "array",
@@ -351,6 +379,16 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
description:
"Allow bankrupt harden/protect despite plaintext or reversible seal/entitlement JSON sidecars. Default false β€” refuse (red-blue round-2).",
},
+ allow_wasm_clear_params: {
+ type: "boolean",
+ description:
+ "Allow bankrupt harden/protect despite clear WASM param/cipher ASCII carriers (R3PARM/R3CIPH/R2SEAL-class). Default false β€” refuse (red-blue round-3). Full data-section encryption is a follow-up.",
+ },
+ allow_stable_panel_derive: {
+ type: "boolean",
+ description:
+ "Keep stable __vaultPanelDerive_* ABI (skip rewrite). Default false β€” maximum/bankrupt rewrite to seed-stable _blaPd_* (red-blue round-3).",
+ },
seed: {
type: "string",
description: "Optional deterministic seed; when omitted, BLA mints an ephemeral random seed (prefer project .blarc via CLI)",
@@ -566,6 +604,38 @@ export const BLA_MCP_TOOLS: readonly McpToolDefinition[] = Object.freeze([
additionalProperties: false,
},
},
+ {
+ name: "bla_lint_wasm_params",
+ description:
+ "Read-only WASM param/cipher carrier lint (same engine as CLI `bla lint-wasm-params`). Flags clear ASCII magics such as R3PARM/R3CIPH/R2SEAL with adjacent binary blobs. Bankrupt harden refuses unless allow_wasm_clear_params. Does not encrypt WASM data sections. Writes nothing.",
+ inputSchema: {
+ type: "object",
+ properties: {
+ path: {
+ type: "string",
+ description: "Path to a .wasm (or WASM-shaped) file to lint",
+ },
+ },
+ required: ["path"],
+ additionalProperties: false,
+ },
+ },
+ {
+ name: "bla_lint_panel_derive",
+ description:
+ "Read-only panel-derive ABI lint (same engine as CLI `bla lint-panel-derive`). Flags stable __vaultPanelDerive_* globals and classic FNV primes. Maximum/bankrupt protect rewrites the ABI unless allow_stable_panel_derive. Writes nothing.",
+ inputSchema: {
+ type: "object",
+ properties: {
+ path: {
+ type: "string",
+ description: "Path to a JS/TS/HTML file to lint",
+ },
+ },
+ required: ["path"],
+ additionalProperties: false,
+ },
+ },
{
name: "bla_run_lookup",
description:
@@ -819,6 +889,12 @@ function runDefend(handlers: McpEngineHandlers, args: Record<string, unknown>):
? { allowLaneIndependentGates: true }
: {}),
...(args.allow_plaintext_seal === true ? { allowPlaintextSeal: true } : {}),
+ ...(args.allow_wasm_clear_params === true
+ ? { allowWasmClearParamCarriers: true }
+ : {}),
+ ...(args.allow_stable_panel_derive === true
+ ? { allowStablePanelDeriveAbi: true }
+ : {}),
...(typeof args.seed === "string" ? { seed: args.seed } : {}),
});
}
@@ -844,6 +920,12 @@ function runProtect(handlers: McpEngineHandlers, args: Record<string, unknown>):
? { allowLaneIndependentGates: true }
: {}),
...(args.allow_plaintext_seal === true ? { allowPlaintextSeal: true } : {}),
+ ...(args.allow_wasm_clear_params === true
+ ? { allowWasmClearParamCarriers: true }
+ : {}),
+ ...(args.allow_stable_panel_derive === true
+ ? { allowStablePanelDeriveAbi: true }
+ : {}),
});
}
@@ -878,6 +960,22 @@ function runLintSeal(args: Record<string, unknown>): SealCommitmentReport {
return lintSealCommitmentFile(abs);
}
+function runLintWasmParams(args: Record<string, unknown>): WasmParamCarrierReport {
+ const abs = resolvePath(args.path as string);
+ if (!existsSync(abs)) {
+ throw new Error(`lint-wasm-params target not found: ${abs}`);
+ }
+ return lintWasmParamCarrierFile(abs);
+}
+
+function runLintPanelDerive(args: Record<string, unknown>): PanelDeriveAbiReport {
+ const abs = resolvePath(args.path as string);
+ if (!existsSync(abs)) {
+ throw new Error(`lint-panel-derive target not found: ${abs}`);
+ }
+ return lintPanelDeriveAbiFile(abs);
+}
+
export function validateMcpToolCall(
params: unknown,
):
@@ -1331,6 +1429,12 @@ export async function handleMcpRequest(
? { allowLaneIndependentGates: true }
: {}),
...(args.allow_plaintext_seal === true ? { allowPlaintextSeal: true } : {}),
+ ...(args.allow_wasm_clear_params === true
+ ? { allowWasmClearParamCarriers: true }
+ : {}),
+ ...(args.allow_stable_panel_derive === true
+ ? { allowStablePanelDeriveAbi: true }
+ : {}),
...(typeof args.seed === "string" ? { seed: args.seed } : {}),
});
// Dry-run / confirmation_required leave no write receipt; real writes do.
@@ -1447,6 +1551,12 @@ export async function handleMcpRequest(
} else if (name === "bla_lint_seal") {
payload = runLintSeal(args);
refused = (payload as SealCommitmentReport).shouldRefuseBankrupt;
+ } else if (name === "bla_lint_wasm_params") {
+ payload = runLintWasmParams(args);
+ refused = (payload as WasmParamCarrierReport).shouldRefuseBankrupt;
+ } else if (name === "bla_lint_panel_derive") {
+ payload = runLintPanelDerive(args);
+ refused = (payload as PanelDeriveAbiReport).shouldRewriteOrRefuse;
} else if (name === "bla_run_lookup") {
payload = readHardenRunSummary(
args.summary_path as string,
diff --git a/tests/mcp-engine-capability-parity.test.ts b/tests/mcp-engine-capability-parity.test.ts
index d32c6c8..088e8a7 100644
--- a/tests/mcp-engine-capability-parity.test.ts
+++ b/tests/mcp-engine-capability-parity.test.ts
@@ -24,6 +24,8 @@ const EXPECTED_MCP_ENGINE_CAPABILITIES: ReadonlyArray<{
"wasm_preserve_exports",
"allow_lane_independent",
"allow_plaintext_seal",
+ "allow_wasm_clear_params",
+ "allow_stable_panel_derive",
"seed",
"dry_run",
"max_artifacts",
@@ -48,6 +50,8 @@ const EXPECTED_MCP_ENGINE_CAPABILITIES: ReadonlyArray<{
"wasm_preserve_exports",
"allow_lane_independent",
"allow_plaintext_seal",
+ "allow_wasm_clear_params",
+ "allow_stable_panel_derive",
"seed",
"in_place",
"confirm_overwrite",
@@ -64,6 +68,8 @@ const EXPECTED_MCP_ENGINE_CAPABILITIES: ReadonlyArray<{
"wasm_preserve_exports",
"allow_lane_independent",
"allow_plaintext_seal",
+ "allow_wasm_clear_params",
+ "allow_stable_panel_derive",
"seed",
"llm_directives",
"in_place",
@@ -91,6 +97,14 @@ const EXPECTED_MCP_ENGINE_CAPABILITIES: ReadonlyArray<{
tool: "bla_lint_seal",
params: ["path"],
},
+ {
+ tool: "bla_lint_wasm_params",
+ params: ["path"],
+ },
+ {
+ tool: "bla_lint_panel_derive",
+ params: ["path"],
+ },
{
tool: "bla_run_lookup",
params: ["summary_path", "run_id"],
diff --git a/tests/mcp-lint-wasm-panel.test.ts b/tests/mcp-lint-wasm-panel.test.ts
new file mode 100644
index 0000000..b1a9855
--- /dev/null
+++ b/tests/mcp-lint-wasm-panel.test.ts
@@ -0,0 +1,60 @@
+import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { afterEach, describe, expect, it } from "vitest";
+import { handleMcpRequest, BLA_MCP_TOOLS } from "../src/mcp/server.js";
+import { buildTestWasmWithParamCarrier } from "../src/engine/wasm-param-carrier-lint.js";
+import { WASM_PARAM_CARRIER_SCHEMA } from "../src/engine/wasm-param-carrier-lint.js";
+import { PANEL_DERIVE_ABI_SCHEMA } from "../src/engine/panel-derive-abi-lint.js";
+
+const tempDirs: string[] = [];
+afterEach(() => {
+ for (const d of tempDirs.splice(0)) rmSync(d, { recursive: true, force: true });
+});
+
+async function call(name: string, args: Record<string, unknown>) {
+ return handleMcpRequest({
+ jsonrpc: "2.0",
+ id: 1,
+ method: "tools/call",
+ params: { name, arguments: args },
+ });
+}
+
+describe("MCP bla_lint_wasm_params / bla_lint_panel_derive", () => {
+ it("registers both tools once", () => {
+ expect(BLA_MCP_TOOLS.filter((t) => t.name === "bla_lint_wasm_params")).toHaveLength(1);
+ expect(BLA_MCP_TOOLS.filter((t) => t.name === "bla_lint_panel_derive")).toHaveLength(1);
+ });
+
+ it("flags clear WASM carriers with isError", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-mcp-wasm-"));
+ tempDirs.push(dir);
+ const file = join(dir, "core.wasm");
+ writeFileSync(file, buildTestWasmWithParamCarrier({}));
+ const res = await call("bla_lint_wasm_params", { path: file });
+ expect(res?.error).toBeUndefined();
+ const result = res!.result as {
+ isError?: boolean;
+ structuredContent: { schema: string; shouldRefuseBankrupt: boolean };
+ };
+ expect(result.structuredContent.schema).toBe(WASM_PARAM_CARRIER_SCHEMA);
+ expect(result.structuredContent.shouldRefuseBankrupt).toBe(true);
+ expect(result.isError).toBe(true);
+ });
+
+ it("flags stable panel derive with isError", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-mcp-panel-"));
+ tempDirs.push(dir);
+ const file = join(dir, "panel.js");
+ writeFileSync(file, "globalThis.__vaultPanelDerive_r3 = (x) => x;\n", "utf8");
+ const res = await call("bla_lint_panel_derive", { path: file });
+ const result = res!.result as {
+ isError?: boolean;
+ structuredContent: { schema: string; shouldRewriteOrRefuse: boolean };
+ };
+ expect(result.structuredContent.schema).toBe(PANEL_DERIVE_ABI_SCHEMA);
+ expect(result.structuredContent.shouldRewriteOrRefuse).toBe(true);
+ expect(result.isError).toBe(true);
+ });
+});
diff --git a/tests/wasm-param-harden-gate.test.ts b/tests/wasm-param-harden-gate.test.ts
new file mode 100644
index 0000000..ab3b809
--- /dev/null
+++ b/tests/wasm-param-harden-gate.test.ts
@@ -0,0 +1,117 @@
+import { mkdtempSync, rmSync, writeFileSync, mkdirSync, readFileSync } 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";
+import { hardenProject } from "../src/engine/harden.js";
+import { buildTestWasmWithParamCarrier } from "../src/engine/wasm-param-carrier-lint.js";
+import { rewriteStablePanelDeriveSymbols } from "../src/engine/panel-derive-abi-lint.js";
+
+const dirs: string[] = [];
+afterEach(() => {
+ for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true });
+});
+
+describe("red-blue round-3 residual gates", () => {
+ it("bankrupt protect refuses clear WASM param carriers unless allowed", () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-wasm-gate-"));
+ dirs.push(dir);
+ const input = join(dir, "core.wasm");
+ const output = join(dir, "core.out.wasm");
+ writeFileSync(input, buildTestWasmWithParamCarrier({}));
+ expect(() =>
+ protectTarget({
+ inputPath: input,
+ outputPath: output,
+ intensity: "bankrupt",
+ seed: "r3-wasm-gate",
+ }),
+ ).toThrow(/allowWasmClearParamCarriers|clear WASM param/);
+ const ok = protectTarget({
+ inputPath: input,
+ outputPath: output,
+ intensity: "bankrupt",
+ seed: "r3-wasm-gate",
+ allowWasmClearParamCarriers: true,
+ });
+ expect(ok.detectedFormat).toBe("wasm");
+ });
+
+ it("bankrupt harden refuses project trees with clear WASM carriers", () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-wasm-harden-"));
+ dirs.push(dir);
+ mkdirSync(join(dir, "dist"));
+ writeFileSync(join(dir, "dist", "core.wasm"), buildTestWasmWithParamCarrier({}));
+ writeFileSync(join(dir, "dist", "app.js"), "export const ok = 1;\n", "utf8");
+ const report = hardenProject({
+ directory: dir,
+ intensity: "bankrupt",
+ seed: "r3-harden-wasm",
+ dryRun: true,
+ });
+ expect(report.overallSuccess).toBe(false);
+ expect(report.artifacts.some((a) => /clear WASM param/i.test(a.error ?? ""))).toBe(true);
+ });
+
+ it("bankrupt protect rewrites stable panel derive ABI across JS seed roots", () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-panel-rw-"));
+ dirs.push(dir);
+ const input = join(dir, "panel.js");
+ const output = join(dir, "panel.out.js");
+ writeFileSync(
+ input,
+ `globalThis.__vaultPanelDerive_r3 = (x) => x;\nexport const poke = (sb) => sb.__vaultPanelDerive_r3(1);\n`,
+ "utf8",
+ );
+ const res = protectTarget({
+ inputPath: input,
+ outputPath: output,
+ intensity: "bankrupt",
+ seed: "r3-panel-seed",
+ honeySourceMaps: false,
+ });
+ const out = readFileSync(res.outputPath, "utf8");
+ expect(out).not.toContain("__vaultPanelDerive_r3");
+ const expected = rewriteStablePanelDeriveSymbols(
+ `globalThis.__vaultPanelDerive_r3 = (x) => x;`,
+ "r3-panel-seed",
+ ).renames[0]!.to;
+ expect(out).toContain(expected);
+ });
+
+ it("harden recommends self_seal for multi-artifact trees without enabling it", () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-selfseal-rec-"));
+ dirs.push(dir);
+ mkdirSync(join(dir, "dist"));
+ // Clean minimal wasm (no param magic) + two JS files
+ writeFileSync(
+ join(dir, "dist", "core.wasm"),
+ Buffer.from([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]),
+ );
+ writeFileSync(join(dir, "dist", "a.js"), "export const a = 1;\n", "utf8");
+ writeFileSync(join(dir, "dist", "b.js"), "export const b = 2;\n", "utf8");
+ const report = hardenProject({
+ directory: dir,
+ intensity: "bankrupt",
+ seed: "r3-selfseal-rec",
+ dryRun: true,
+ });
+ expect(report.selfSeal).toBe(false);
+ expect(report.selfSealRecommended).toBe(true);
+ expect(report.selfSealRecommendation).toMatch(/self_seal/);
+ });
+
+ it("single-file harden does not recommend self_seal", () => {
+ const dir = mkdtempSync(join(tmpdir(), "bla-selfseal-single-"));
+ dirs.push(dir);
+ mkdirSync(join(dir, "dist"));
+ writeFileSync(join(dir, "dist", "only.js"), "export const a = 1;\n", "utf8");
+ const report = hardenProject({
+ directory: dir,
+ intensity: "bankrupt",
+ seed: "r3-selfseal-single",
+ dryRun: true,
+ });
+ expect(report.selfSealRecommended).toBe(false);
+ });
+});
diff --git a/website/schemas/bla.config.v1.json b/website/schemas/bla.config.v1.json
index 1caf8bd..cd98f2d 100644
--- a/website/schemas/bla.config.v1.json
+++ b/website/schemas/bla.config.v1.json
@@ -50,12 +50,32 @@
"selfSeal": {
"type": "boolean",
"default": false,
- "description": "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Parity with CLI --self-seal / MCP self_seal."
+ "description": "Opt-in self-seal / sibling-module integrity binding for JS/Node targets (issue #40.5). Parity with CLI --self-seal / MCP self_seal. For multi-artifact trees, bankrupt harden recommends this (selfSealRecommended) but never auto-enables for single-file projects."
},
"wasmPreserveExports": {
"type": "array",
"items": { "type": "string" },
"description": "WASM export names that must remain the public ABI when export rename runs at maximum/bankrupt (issue #40.3)."
+ },
+ "allowWasmClearParamCarriers": {
+ "type": "boolean",
+ "default": false,
+ "description": "Allow bankrupt harden despite clear WASM param/cipher ASCII carriers (R3PARM/R3CIPH/R2SEAL-class; red-blue round-3). Default false."
+ },
+ "allowStablePanelDeriveAbi": {
+ "type": "boolean",
+ "default": false,
+ "description": "Keep stable __vaultPanelDerive_* ABI (skip rewrite). Default false β€” maximum/bankrupt rewrite to _blaPd_* (red-blue round-3)."
+ },
+ "allowPlaintextSeal": {
+ "type": "boolean",
+ "default": false,
+ "description": "Allow bankrupt harden despite plaintext/reversible seal sidecars (red-blue round-2). Default false."
+ },
+ "allowLaneIndependentGates": {
+ "type": "boolean",
+ "default": false,
+ "description": "Allow harden/defend of lane-independent JS gates (issue #40.1). Default false."
}
},
"additionalProperties": true