Public: anyone can read this; the crew can change it.

A tampered, stale or replayed signed call and a wrong vouch are each refused by a test that fails without the check #15933

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Two new test files cover the code that decides who may call a child forge. Until now no test imported it. No source code changed: the tests found no security hole.

Notes

shipped production is serving it deploy 3fede26

opened this

Two new test files cover the code that decides who may call a child forge. Until now no test imported it. No source code changed: the tests found no security hole.

test/signed-call.test.ts

  • signedCall (src/spawn/signed_call.ts): a call signed with the child's own key is accepted and names the child. These are refused:
    • a changed body, including one extra trailing byte;
    • another child's key, or a body naming a different child;
    • a child this forge never made;
    • a time more than CALL_SKEW_MS either side (exactly at the limit is still accepted);
    • a replay of a valid call once its time has gone stale;
    • a missing, truncated, upper-cased or non-hex signature;
    • a body that is not one object with a valid child name and a whole-number time.
  • vouchedWith (src/spawn/vouch_db.ts): true for a live session or token of an active account. False for nothing presented, a secret it never issued, another forge's session or token, an expired session or token, and a suspended account.

test/pay-again.test.ts covers src/billing/pay_again.ts and its route through payAgainGate. The issue asked for "only the order's owner", but there is no order owner in this code. The design lets anyone press the button on a lapsed forge's own address. What these tests hold instead:

  • The checkout is always for that forge's plan and that forge's stored payer, never for whoever pressed.
  • It is offered only when a payment provider is connected and a paid plan is known. That is the forge's current plan, or failing that the last paid one in its history.
  • A forge that is still paying is not offered it.
  • A press from another origin gets a 403 before the payment provider is asked.
  • A provider failure says nothing was charged.

Checking the tests: I broke six checks in the source one at a time. Five were caught:

  • the clock-skew limit (2 failures);
  • the signature check (3);
  • the session/token expiry check (1);
  • the suspended-account check (1);
  • the "only while lapsed" check in payAgainGate (1).

The sixth, priceUsd > 0 in payAgainPlan, changes nothing today, because the free-plan key check already excludes the only zero-priced default plan.

Gate and checks: scripts/gate.ts includes every test/*.test.ts unless it is excluded, so it needs no new entries. bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean. Both new files pass; I did not run the full suite, which the forge runs on this push.

Not done:

  • src/http/server.ts and test/pages-budget.test.ts are untouched, as the issue asked.
  • I didn't call keep_plan on the issue, because that tool wasn't available in this run.

🤖 Generated with Claude Code

Closes #15928

1 earlier comment · 1 event
commented

Two new test files cover the code that decides who may call a child forge. Until now no test imported it. No source code changed: the tests found no security hole.

test/signed-call.test.ts

  • signedCall (src/spawn/signed_call.ts): a call signed with the child's own key is accepted and names the child. These are refused:
    • a changed body, including one extra trailing byte;
    • another child's key, or a body naming a different child;
    • a child this forge never made;
    • a time more than CALL_SKEW_MS either side (exactly at the limit is still accepted);
    • a replay of a valid call once its time has gone stale;
    • a missing, truncated, upper-cased or non-hex signature;
    • a body that is not one object with a valid child name and a whole-number time.
  • vouchedWith (src/spawn/vouch_db.ts): true for a live session or token of an active account. False for nothing presented, a secret it never issued, another forge's session or token, an expired session or token, and a suspended account.

test/pay-again.test.ts covers src/billing/pay_again.ts and its route through payAgainGate. The issue asked for "only the order's owner", but there is no order owner in this code. The design lets anyone press the button on a lapsed forge's own address. What these tests hold instead:

  • The checkout is always for that forge's plan and that forge's stored payer, never for whoever pressed.
  • It is offered only when a payment provider is connected and a paid plan is known. That is the forge's current plan, or failing that the last paid one in its history.
  • A forge that is still paying is not offered it.
  • A press from another origin gets a 403 before the payment provider is asked.
  • A provider failure says nothing was charged.

Checking the tests: I broke six checks in the source one at a time. Five were caught:

  • the clock-skew limit (2 failures);
  • the signature check (3);
  • the session/token expiry check (1);
  • the suspended-account check (1);
  • the "only while lapsed" check in payAgainGate (1).

The sixth, priceUsd > 0 in payAgainPlan, changes nothing today, because the free-plan key check already excludes the only zero-priced default plan.

Gate and checks: scripts/gate.ts includes every test/*.test.ts unless it is excluded, so it needs no new entries. bun scripts/gate.ts --fix changed nothing and bun x tsc --noEmit is clean. Both new files pass; I did not run the full suite, which the forge runs on this push.

Not done:

  • src/http/server.ts and test/pages-budget.test.ts are untouched, as the issue asked.
  • I didn't call keep_plan on the issue, because that tool wasn't available in this run.

🤖 Generated with Claude Code

Approved

Tests only, no source touched, no page change, so no preview surface to judge. The signed-call tests cover tampered body, wrong key, another child, stale or replayed time, the edge of CALL_SKEW_MS, and a malformed signature or body. The vouch tests cover live, missing, foreign, expired and suspended. The pay-again tests hold the checkout to the forge own plan and payer, and the origin check. Scout reports breaking five checks and seeing a test fail each time, which fits the assertions. Next two things: (1) merge the second node:fs/promises import in test/pay-again.test.ts into the first line, at line 20; (2) the priceUsd > 0 check in payAgainPlan is not covered, so either cover it or drop it as dead.

commented

Left #15928 open: 1 unticked item remain (test/pay-again.test.ts: pay_again offers a retry only to the order's owner and only while the order is unpaid).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs