A verifier that accepts good requests can still be wrong: what matters is what it refuses, and whether it can tell a refusal from an outage. These are 94 test cases in one JSON file, which you can run against a verifier in any language. Most of them are cases it has to refuse.
Run them:
DOCS="${DOCS:-https://app.visacli.sh}"
curl -fsSO "$DOCS/examples/verify-agent.mjs"
curl -fsSO "$DOCS/examples/run-vectors.mjs"
curl -fsSO "$DOCS/conformance/tap-http-request-v1.json"
less verify-agent.mjs run-vectors.mjs
node run-vectors.mjsThe docs serve these files themselves, so you can also download verify-agent.mjs, run-vectors.mjs and the test vectors from this page. DOCS defaults to https://app.visacli.sh; if you're reading these docs at another address, run export DOCS=<that address> first. While the docs are private, add -H "Authorization: Bearer <your docs key>" to each curl.
There's no published checksum or signature, so read the code before you run it: the less line opens what you saved. verify-agent.mjs is the same file as the one printed in full on Verifier code, and run-vectors.mjs the same as the one printed below, because the downloads are served from that printed code, byte for byte. The JSON file is data, and What's in the file describes every field.
94 of 94 passed: 18 accepted, 52 refused, 24 could not checkThat's the example verifier from Verify a signed request, checked on every build of these docs.
Does your verifier pass?
| Verifier | Result | How we know |
|---|---|---|
| The example on Verify a signed request | 94 of 94 | run-vectors.mjs, on every docs build |
This table lists the verifiers we maintain. To add yours, ask your Visa CLI partner contact, as Before you start explains.
What's in the file
| Field | What it holds |
|---|---|
profile | tap-http-request-v1, the profile being tested |
key | The public test key. It's RFC 8032 test vector 1, so anyone can sign with it, and it's listed nowhere |
origin | The public origin to pin, unless a case sets its own |
listing | What the registry returns for the test key |
listings | Other listings some cases use, named by their registry value |
cases[].name | What the case tests |
cases[].now | The time to use, in Unix seconds, so the cases don't expire |
cases[].registry | How the stand-in registry should answer. See below |
cases[].request | url, method, headers as pairs, and body. url is what the agent signed for. When a case also has target, send that as the request target in place of the path and query of url |
cases[].repeat | When true, send the request twice and judge the second |
cases[].expect | ok, or code, reason and judged |
cases[].mode | directory when the case reads the Visa Agent Directory instead of Visa CLI's registry. Create the verifier with directory.origin, and answer with the entry under directory.answers named by registry |
directory | origin, which Visa Agent Directory the verifier reads, sandbox or production, and answers, each a status and body for GET {origin}/.well-known/jwks/keys/{keyid} |
registry value | The stand-in registry answers |
|---|---|
listed | 200 with listing |
not_listed | 404 |
paused | 200 with isActive: false. Visa CLI's registry never sends this: it answers 404 for a paused agent. The case is for verifiers that also read other sources |
key_revoked | 200 with the key's status set to revoked |
down_503 | 503 with Retry-After: 7 |
redirect_302 | 302 to another origin. A verifier must not follow it: with fetch, pass redirect: 'error' |
malformed | 200 with a body that isn't a listing |
status_missing, algorithm_missing | 200 with listing, its key missing that field. Both are under listings |
simulated | 200 with simulated: true |
| Any other value | 200 with the listing under that name in listings, such as one holding an Ed448 or DSA key |
In words: listed answers 200 with the test listing and not_listed answers 404. A verifier must treat down_503 and redirect_302 as couldn't check with tap_trust_unavailable, and a malformed listing, a revoked key or a key missing its status or algorithm as couldn't check with tap_trust_invalid.
A verifier passes a case when it gives the same code and judged. reason is finer, and a verifier can use its own, so the runner prints a different reason as a note rather than a failure. What a verifier mustn't do is turn a judged: false case into a refusal: an outage says nothing about the agent.
Run the vectors against your verifier
Save this beside verify-agent.mjs and the JSON file. To test your own verifier, swap createVerifier for an adapter around yours. The Python tab runs the same cases against verify_agent.py, the Python port, with python3 run_vectors.py, and prints the same last line.
import { readFileSync } from 'node:fs'
import { createVerifier, memoryNonceStore } from './verify-agent.mjs'
const file = JSON.parse(readFileSync('tap-http-request-v1.json', 'utf8'))
const json = (doc, status = 200, headers = {}) => new Response(JSON.stringify(doc), { status, headers })
const answers = {
listed: () => json(file.listing),
not_listed: () => json({ code: 'not_found' }, 404),
paused: () => json({ ...file.listing, isActive: false }),
key_revoked: () => json({ ...file.listing, keys: file.listing.keys.map((key) => ({ ...key, status: 'revoked' })) }),
down_503: () => json({ code: 'unavailable' }, 503, { 'retry-after': '7' }),
redirect_302: () => new Response(null, { status: 302, headers: { location: 'https://elsewhere.example/' } }),
malformed: () => json({ nope: true }),
simulated: () => json({ ...file.listing, simulated: true }),
}
const answer = (vector) => {
if (vector.mode !== 'directory') return (answers[vector.registry] ?? (() => json(file.listings[vector.registry])))()
const { status, body } = file.directory.answers[vector.registry]
return json(body, status)
}
let passed = 0
const notes = []
const kinds = { accepted: 0, refused: 0, 'could not check': 0 }
for (const vector of file.cases) {
const verifyRequest = createVerifier({
...(vector.mode === 'directory' ? { directoryOrigin: file.directory.origin } : { registryOrigin: 'https://registry.invalid' }),
reserveNonce: memoryNonceStore(() => vector.now),
now: () => vector.now,
fetchImpl: async () => answer(vector),
})
const request = {
method: vector.request.method,
publicOrigin: vector.origin ?? file.origin,
target: vector.request.target ?? vector.request.url.replace(/^https:\/\/[^/]+/, ''),
headers: Object.fromEntries(vector.request.headers.map(([name, value]) => [name.toLowerCase(), value])),
rawBody: Buffer.from(vector.request.body ?? ''),
}
if (vector.repeat) await verifyRequest(request)
const result = await verifyRequest(request)
const pass = vector.expect.ok ? result.ok === true : result.code === vector.expect.code && result.judged === vector.expect.judged
if (pass) passed += 1
if (pass && !vector.expect.ok && result.reason !== vector.expect.reason) notes.push(`${vector.name}: reason ${result.reason}, the file says ${vector.expect.reason}`)
kinds[vector.expect.ok ? 'accepted' : vector.expect.judged ? 'refused' : 'could not check'] += 1
console.log(`${pass ? 'PASS' : 'FAIL'} ${vector.name}${pass ? '' : `: got ${result.code}, judged ${result.judged}`}`)
}
for (const note of notes) console.log(`NOTE ${note}`)
console.log(`${passed} of ${file.cases.length} passed: ${kinds.accepted} accepted, ${kinds.refused} refused, ${kinds['could not check']} could not check`)
process.exit(passed === file.cases.length ? 0 : 1)import json
import sys
from verify_agent import create_verifier, memory_nonce_store
with open('tap-http-request-v1.json') as handle:
file = json.load(handle)
def answer(vector):
registry = vector['registry']
def respond(doc, status=200, headers=None):
return status, headers or {}, json.dumps(doc).encode()
if vector.get('mode') == 'directory':
entry = file['directory']['answers'][registry]
return respond(entry['body'], entry['status'])
answers = {
'listed': lambda: respond(file['listing']),
'not_listed': lambda: respond({'code': 'not_found'}, 404),
'paused': lambda: respond({**file['listing'], 'isActive': False}),
'key_revoked': lambda: respond({**file['listing'], 'keys': [{**key, 'status': 'revoked'} for key in file['listing']['keys']]}),
'down_503': lambda: respond({'code': 'unavailable'}, 503, {'retry-after': '7'}),
'redirect_302': lambda: (302, {'location': 'https://elsewhere.example/'}, b''),
'malformed': lambda: respond({'nope': True}),
'simulated': lambda: respond({**file['listing'], 'simulated': True}),
}
return answers.get(registry, lambda: respond(file['listings'][registry]))()
passed = 0
notes = []
kinds = {'accepted': 0, 'refused': 0, 'could not check': 0}
for vector in file['cases']:
source = {'directory_origin': file['directory']['origin']} if vector.get('mode') == 'directory' else {'registry_origin': 'https://registry.invalid'}
verify_request = create_verifier(
**source,
reserve_nonce=memory_nonce_store(lambda: vector['now']),
now=lambda: vector['now'],
fetch=lambda url: answer(vector),
)
request = {
'method': vector['request']['method'],
'public_origin': vector.get('origin', file['origin']),
'target': vector['request'].get('target', '/' + vector['request']['url'].split('/', 3)[3]),
'headers': {name.lower(): value for name, value in vector['request']['headers']},
'raw_body': (vector['request'].get('body') or '').encode(),
}
if vector.get('repeat'):
verify_request(**request)
result = verify_request(**request)
expect = vector['expect']
ok = result['ok'] if expect['ok'] else result.get('code') == expect['code'] and result.get('judged') == expect['judged']
passed += ok
if ok and not expect['ok'] and result['reason'] != expect['reason']:
notes.append(f"{vector['name']}: reason {result['reason']}, the file says {expect['reason']}")
kinds['accepted' if expect['ok'] else 'refused' if expect['judged'] else 'could not check'] += 1
print(f"{'PASS' if ok else 'FAIL'} {vector['name']}" + ('' if ok else f": got {result.get('code')}, judged {result.get('judged')}"))
for note in notes:
print(f'NOTE {note}')
print(f"{passed} of {len(file['cases'])} passed: {kinds['accepted']} accepted, {kinds['refused']} refused, {kinds['could not check']} could not check")
sys.exit(0 if passed == len(file['cases']) else 1)Every case
- A listing pairs the victim's thumbprint keyid with the attacker's key
Result: Refused
code:
tap_key_inactivereason:
key_not_live- Authorization present, even unsigned
Result: Refused
code:
tap_malformedreason:
credential_header_present- Registry answered something unusable
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- Registry down, saying when to ask again
Result: Couldn't check
code:
tap_trust_unavailablereason:
registry_unavailable- The registry answers with a redirect
Result: Couldn't check
code:
tap_trust_unavailablereason:
registry_unavailable- Signature-Agent isn't on the allowlist
Result: Refused
code:
tap_signature_agent_not_acceptedreason:
signature_agent_not_accepted- A simulated listing, by a verifier not told to accept one
Result: Refused
code:
tap_simulated_not_acceptedreason:
simulated_listing- Dot segments after a segment that starts with a dot
Result: Refused
code:
tap_malformedreason:
request_target_invalid- Body changed and Signature-Agent off the allowlist, so the body is checked first
Result: Refused
code:
tap_signature_invalidreason:
body_digest_mismatch- The listing holds an Ed448 key, and the request is signed with it
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- A caret in the path, which newer URL parsers encode
Result: Refused
code:
tap_malformedreason:
request_target_invalid- A brace in the path, which a URL parser would encode
Result: Refused
code:
tap_malformedreason:
request_target_invalid- A target that runs on into another host, signed for that host
Result: Refused
code:
tap_malformedreason:
request_target_invalid- A target that adds a port, signed for that port
Result: Refused
code:
tap_malformedreason:
request_target_invalid- A target that turns the host into a user name, signed for the host after it
Result: Refused
code:
tap_malformedreason:
request_target_invalid- The listed key has no algorithm
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- A Signature header that is not whole base64
Result: Refused
code:
tap_malformedreason:
signature_header_format- X-Forwarded-For covered by the signature
Result: Refused
code:
tap_malformedreason:
signed_header_invalid- A covered header over 4096 characters
Result: Refused
code:
tap_malformedreason:
signed_header_invalid- The listed key's expirationDate is not a date
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- A pinned origin written with a trailing dot
Result: Refused
code:
tap_malformedreason:
origin_not_normal- A pinned origin with an underscore in the host
Result: Refused
code:
tap_malformedreason:
origin_not_normal- A method sent in lowercase, though the agent signed POST
Result: Refused
code:
tap_malformedreason:
method_not_allowed- The listed key's expirationDate is a date alone, with no time or zone
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate is a word and a number
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate is a word and a year
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate has hour 24
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate has a zone offset with 99 minutes
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate has no zone
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate has one-digit month and day
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate has a six-digit year
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate is a day that doesn't exist
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The listed key's expirationDate is in year 0000
Result: Refused
code:
tap_key_inactivereason:
key_not_live- The Visa Agent Directory answers 503
Result: Couldn't check
code:
tap_trust_unavailablereason:
registry_unavailable- Reading the Visa Agent Directory, the key's status isn't active
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- Reading the Visa Agent Directory, the key's expirationDate has passed
Result: Refused
code:
tap_key_inactivereason:
key_not_live- Reading the Visa Agent Directory, the key's expirationDate isn't RFC 3339
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- Reading the Visa Agent Directory, the answer is for another key ID
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- Reading the Visa Agent Directory, the key is neither Ed25519 nor P-256
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- Reading the Visa Agent Directory, the answer has no key
Result: Couldn't check
code:
tap_trust_invalidreason:
listing_unusable- The Visa Agent Directory holds another public key for this key ID
Result: Refused
code:
tap_signature_invalidreason:
signature_mismatch
P-256 keys in the Visa Agent Directory
Agents registered through Basis Theory may sign with P-256 (ECDSA) keys, as Basis Theory documents, and the example verifier accepts them when it reads the Visa Agent Directory. These cases aren't in the JSON file yet. The example verifier's own tests run them on every build of these docs: fixture.mjs in Node, with a P-256 key it generates, and test_server.py in Python, with a recorded signature. Verifier code prints both, with their output.