ai icon indicating copy to clipboard operation
ai copied to clipboard

Remove legacy tool approval signature fallback in v8

Open dnukumamras opened this issue 4 months ago • 1 comments

Background

PR #17493 made the tool approval HMAC payload injective: it changed buildPayload in packages/ai/src/generate-text/tool-approval-signature.ts from newline-joined field concatenation to JSON.stringify with a domain-separation prefix, so distinct field tuples can no longer serialize to identical signed bytes.

Because tool approval signatures live in client-supplied message history, a pending approval signed by a pre-#17493 server could straddle an upgrade and fail verification on the new server. To avoid breaking those, verifyToolApprovalSignature keeps a legacy fallback: on a failed JSON-format check it re-verifies against the old newline-joined payload, but only when no signed field contains the \n delimiter — the exact condition that made the old format ambiguous — so the collision stays closed while benign old signatures still verify.

That fallback is deliberate scaffolding for the v7 line. In the next major we can drop it: any approval signed that long ago is no longer pending, so only the injective format needs to be accepted.

Goal (v8)

Remove the legacy newline-format verification fallback so only the injective JSON payload is accepted, and delete the compatibility code and its tests.

Tasks

  • [ ] packages/ai/src/generate-text/tool-approval-signature.ts: delete buildLegacyPayload and the TODO: remove in v8 fallback branch in verifyToolApprovalSignature; the function should verify against buildPayload only.
  • [ ] packages/ai/src/generate-text/tool-approval-signature.test.ts: remove the signLegacy helper and the two legacy-fallback tests (should still verify a legacy newline-format signature … and should not accept a legacy signature through the retupling collision). Keep the injective/collision regression tests.
  • [ ] Add a major changeset noting that signatures produced before the injective format (pre-#17493) are no longer accepted.

References

  • #17493 — injective payload + legacy fallback (this scaffolding)

dnukumamras avatar Jul 17 '26 17:07 dnukumamras

Identify issue type

Identified as Feature
Confidence: High

Rationale

This is a planned breaking behavior change for the next major version, not a failure of existing behavior.

Evidence

  • Requests a v8 behavior change so verification accepts only the injective JSON payload.
  • Calls for removing the legacy signature fallback, compatibility tests, and adding a major changeset.
  • Does not report broken or incorrect current behavior; the fallback is described as deliberate v7 compatibility scaffolding.

lgrammel avatar Jul 22 '26 10:07 lgrammel