Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/ccv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
},
"devDependencies": {
"@apidevtools/swagger-parser": "^13.1.0",
"@cloudflare/vitest-plugin": "1.8.0",
"@cloudflare/vitest-plugin": "1.8.2",
"@types/node": "26.6.6",
"typescript": "7.0.2",
"vitest": "5.1.0",
"wrangler": "4.160.1"
"wrangler": "4.162.0"
}
}
7 changes: 5 additions & 2 deletions apps/ccv2/test/security.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { env, exports as worker } from "cloudflare:workers";
import { importPKCS8, SignJWT } from "jose";
import { base64url, importPKCS8, SignJWT } from "jose";
import { describe, expect, it } from "vitest";

import { createRun, issueToken, sapHeaders } from "./helpers";
Expand Down Expand Up @@ -34,7 +34,10 @@ describe("authentication and abuse boundaries", () => {
const payload = parts[1];
const signature = parts[2] ?? "";
if (!header || !payload || !signature) throw new Error("Issued token is malformed");
const corrupted = `${header}.${payload}.${signature.slice(0, -2)}aa`;
// Change leading bits so tampering cannot affect only unused base64url padding bits.
const corruptedSignature = `${signature.startsWith("A") ? "B" : "A"}${signature.slice(1)}`;
expect(base64url.decode(corruptedSignature)).not.toEqual(base64url.decode(signature));
const corrupted = `${header}.${payload}.${corruptedSignature}`;
expect((await worker.default.fetch(builds, { headers: sapHeaders(corrupted) })).status).toBe(
401,
);
Expand Down
Loading