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
5 changes: 5 additions & 0 deletions .changeset/fix-cross-version-sig-verify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@resciencelab/agent-world-sdk": patch
---

Fix cross-version HTTP signature verification: use sender's X-AgentWorld-Version header instead of local PROTOCOL_VERSION when reconstructing signing input, so gateway and peers running different SDK minor versions can still verify each other's signatures.
10 changes: 8 additions & 2 deletions packages/agent-world-sdk/src/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ function buildRequestSigningInput(opts: {
authority: string;
path: string;
contentDigest: string;
v?: string;
}): Record<string, string> {
return {
v: PROTOCOL_VERSION,
v: opts.v ?? PROTOCOL_VERSION,
from: opts.from,
kid: opts.kid,
ts: opts.ts,
Expand Down Expand Up @@ -232,6 +233,7 @@ export function verifyHttpRequestHeaders(
const kid = h["x-agentworld-keyid"] as string | undefined;
const ts = h["x-agentworld-timestamp"] as string | undefined;
const cd = h["content-digest"] as string | undefined;
const senderVersion = h["x-agentworld-version"] as string | undefined;

if (!sig || !from || !kid || !ts || !cd) {
return { ok: false, error: "Missing required AgentWorld headers" };
Expand All @@ -258,6 +260,7 @@ export function verifyHttpRequestHeaders(
authority,
path,
contentDigest: cd,
v: senderVersion,
});
const ok = verifyWithDomainSeparator(
DOMAIN_SEPARATORS.HTTP_REQUEST,
Expand Down Expand Up @@ -287,9 +290,10 @@ function buildResponseSigningInput(opts: {
ts: string;
status: number;
contentDigest: string;
v?: string;
}): Record<string, unknown> {
return {
v: PROTOCOL_VERSION,
v: opts.v ?? PROTOCOL_VERSION,
from: opts.from,
kid: opts.kid,
ts: opts.ts,
Expand Down Expand Up @@ -351,6 +355,7 @@ export function verifyHttpResponseHeaders(
const kid = h["x-agentworld-keyid"];
const ts = h["x-agentworld-timestamp"];
const cd = h["content-digest"];
const senderVersion = h["x-agentworld-version"];

if (!sig || !from || !kid || !ts || !cd) {
return { ok: false, error: "Missing required AgentWorld response headers" };
Expand All @@ -375,6 +380,7 @@ export function verifyHttpResponseHeaders(
ts,
status,
contentDigest: cd,
v: senderVersion ?? undefined,
});
const ok = verifyWithDomainSeparator(
DOMAIN_SEPARATORS.HTTP_RESPONSE,
Expand Down