TAP verification fails when signatures cover @method, @scheme, or @query

Aperta
#1,357 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@brendanjryan ci sta già lavorando.

Dal 24/11/2026.

  • #1362 di @brendanjryan — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nodejs, typescript

Direzione di ricerca

The bug is in componentValue in src/extensions/identity/internal/HttpMessageSignature.ts, which derives only @authority and @path. Run the minimal script from the issue against the TAP server verifier to reproduce the failures for @method, @scheme and @query. Done when those three components verify with valid signatures, tampered or unsupported parameters still fail, and the identity test suite passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Expected Behavior

A TAP request whose signature covers the required @authority and @path plus @method, @scheme, or @query can be verified by deriving those values from the request according to RFC 9421.

The public TAP merchant specification defines authority and path as the minimum and permits agents or payment schemes to cover additional fields. The three component definitions are public: method (§2.2.1), scheme (§2.2.4), and query (§2.2.7).

Current Behavior

Reproduced on the published [email protected] package using Node.js 24.15.0 on 2026-11-24. An independently signed Ed25519 request verifies with the minimum components. Adding any one of the three components returns invalid / The HTTP message signature is invalid.

The signature uses lowercase alg="ed25519", so this is separate from compatibility with the capitalized spelling in Visa's examples.

In componentValue, only @authority and @path are derived. Other identifiers fall through to HTTP header lookup. The relevant implementation on current main is unchanged as of this report.

Possible Solution

Derive the method without changing its case, the lowercase scheme without :, and the query including its leading ? (or ? alone when absent). Preserve encoded octets and query ordering. TAP's minimum required components and prover defaults can stay the same.

A tested implementation is available on our fork. It includes a patch changeset and 10 regression tests that fail on the original code, including exact signing bytes, independently signed requests, tampering, replay, and unsupported parameters. The complete identity test selection passes: 295 tests across 16 files; build, lint/format, types, and package checks also pass.

Minimal Reproducible Example

In a temporary directory, install [email protected], save this as components.mjs, and run node components.mjs with Node.js 24. The script generates an ephemeral key and verifies requests locally.

import { Store } from 'mppx/identity'
import { Server } from 'mppx/extensions/identity/tap'

const keys = await crypto.subtle.generateKey('Ed25519', false, ['sign', 'verify'])
const values = {
  '@authority': 'merchant.example',
  '@path': '/resource',
  '@method': 'GET',
  '@scheme': 'https',
  '@query': '?x=1',
}

for (const extra of [undefined, '@method', '@scheme', '@query']) {
  const components = ['@authority', '@path', ...(extra ? [extra] : [])]
  const created = Math.floor(Date.now() / 1000) - 1
  const input = `(${components.map(id => `"${id}"`).join(' ')});created=${created};expires=${created + 60};keyid="repro-agent";alg="ed25519";nonce="${crypto.randomUUID()}";tag="agent-browser-auth"`
  const base = [
    ...components.map(id => `"${id}": ${values[id]}`),
    `"@signature-params": ${input}`,
  ].join('\n')
  const signature = await crypto.subtle.sign(
    'Ed25519', keys.privateKey, new TextEncoder().encode(base),
  )
  const request = new Request('https://merchant.example/resource?x=1', {
    headers: {
      'Signature-Input': `test=${input}`,
      Signature: `test=:${Buffer.from(signature).toString('base64')}:`,
    },
  })
  const result = await Server.verifier({
    keyResolver: () => keys.publicKey,
    nonceStore: Store.memory(),
  }).verify(request)
  console.log(extra ?? 'minimum', result.status, result.reason ?? '')
}

Observed output:

minimum valid 
@method invalid The HTTP message signature is invalid.
@scheme invalid The HTTP message signature is invalid.
@query invalid The HTTP message signature is invalid.

Context

This prevents TAP merchants using mppx from recognizing agents that cover these additional request components, including Visa CLI signing profiles. The request is to support these component values; it does not require making them mandatory for every TAP signature or changing payment-authorization policy.

Lingua principale
TypeScript
Stelle
196
Fork
79
Merge medio
15h 20m
PR unite (30g)
156

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wevm/mppx

Tutte le issue di wevm/mppx

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.