Kill the browser's local reading of "unsigned", and mutate the browser too
Soul replaced the shared `isUnsignedCertificate` call in the browser's session-acceptance check with a local empty-string comparison and every one of the 18 browser tests still passed, because every test used an empty signature. A whitespace signature is where the two readings part: the shared route verifier accepts such a route as unsigned on a loopback local-development endpoint, and an inline comparison then demands a provider proof for the session the verifier just let through. The test now opens that session with three spaces, U+0085 and a no-break-space/tab/newline mix as well as the empty string, and asserts U+FEFF the other way, since it is whitespace to JavaScript and a signature to C#. The mutation runner grew a second target. `shared` is the one verifier, killed by the cultnet-ts tests; `browser` is `packages/cultmesh-browser/src/index.ts`, killed by the browser tests. A browser mutation cannot be killed by cultnet-ts tests, so the killer is the target's own workspace, and each target carries its own sidecar, control, sentinel and post-restore dist assertion. Two repairs this pass earned: - The sidecar is now removed inside the `finally`, right after the verified restore. A throw mid-run left it behind holding the pre-run bytes, and the next run "repaired" the file from them, silently reverting everything fixed in between. That happened here, twice, before it was noticed. - The NUL in the loopback pre-check's strip regex had been written as a literal byte rather than an escape. It read the same, but git classified the file as binary and stopped normalising its line endings, so the whole file diffed as rewritten. Escaped, along with the ASCII host range beside it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
803ee12a7a
commit
dfe582edbc
3 changed files with 153 additions and 91 deletions
|
|
@ -245,26 +245,43 @@ test("browser client opens an unsigned-certificate loopback session under local-
|
|||
trust,
|
||||
socketFactory: () => handshakeOnlySocket(route),
|
||||
});
|
||||
const blank = (route: CultMeshBrowserRoute) => ({ ...route, certificate: { ...route.certificate!, signature: "" } });
|
||||
const blank = (route: CultMeshBrowserRoute, signature: string) =>
|
||||
({ ...route, certificate: { ...route.certificate!, signature } });
|
||||
|
||||
const loopback = await createSignedRoute("ws://127.0.0.1:4501/mesh");
|
||||
const localTrust = { mode: "local-development" as const, odinRoots: [loopback.odinPublic] };
|
||||
const client = await connect(blank(loopback.route), localTrust);
|
||||
assert.equal(client.state, "connected");
|
||||
await client.dispose();
|
||||
const remote = await createSignedRoute("wss://provider.example/mesh");
|
||||
|
||||
// Empty is the easy case. The whitespace signatures are the ones that catch a
|
||||
// local re-reading of "unsigned" here: an inline `signature === ""` passes
|
||||
// every other test in this file and fails these, and U+0085 also separates
|
||||
// `String.prototype.trim` from the C# `char.IsWhiteSpace` the shared
|
||||
// `isUnsignedCertificate` uses. Both sides of the session check have to read
|
||||
// "unsigned" the same way, or the route verifier accepts a session the
|
||||
// acceptance check then demands a provider proof for.
|
||||
for (const signature of ["", " ", "\u0085", "\u00a0\t\n"]) {
|
||||
const label = JSON.stringify(signature);
|
||||
const client = await connect(blank(loopback.route, signature), localTrust);
|
||||
assert.equal(client.state, "connected", label);
|
||||
await client.dispose();
|
||||
await assert.rejects(
|
||||
connect(blank(remote.route, signature), { mode: "local-development", odinRoots: [remote.odinPublic] }),
|
||||
/Odin-signed authority certificate/,
|
||||
label,
|
||||
);
|
||||
await assert.rejects(
|
||||
connect(blank(remote.route, signature), { mode: "authenticated-remote", odinRoots: [remote.odinPublic] }),
|
||||
/Odin-signed authority certificate/,
|
||||
label,
|
||||
);
|
||||
}
|
||||
// U+FEFF is whitespace to JavaScript and not to C#, so it is a signature, not
|
||||
// an unsigned route, and the loopback route is refused for its bytes.
|
||||
await assert.rejects(connect(blank(loopback.route, "\ufeff"), localTrust), /not base64|not IEEE P1363/);
|
||||
|
||||
// A signed loopback certificate is an authenticated route even under
|
||||
// local-development; the provider must still prove its key.
|
||||
await assert.rejects(connect(loopback.route, localTrust), /did not prove possession/);
|
||||
|
||||
const remote = await createSignedRoute("wss://provider.example/mesh");
|
||||
await assert.rejects(
|
||||
connect(blank(remote.route), { mode: "local-development", odinRoots: [remote.odinPublic] }),
|
||||
/Odin-signed authority certificate/,
|
||||
);
|
||||
await assert.rejects(
|
||||
connect(blank(remote.route), { mode: "authenticated-remote", odinRoots: [remote.odinPublic] }),
|
||||
/Odin-signed authority certificate/,
|
||||
);
|
||||
});
|
||||
|
||||
test("browser client rejects a mutated or expired signed route before opening a provider socket", async () => {
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ function ownedBytes(view: Uint8Array): ArrayBuffer {
|
|||
* accepts them: " ws://127.0.0.1/mesh" is loopback to both.
|
||||
*/
|
||||
function refusedByCSharpUriShape(value: string): boolean {
|
||||
const raw = value.replace(/^[ | ||||