Skip to content

Constrain payment method and invoice recipient - #859

Merged
rzueger merged 1 commit into
developfrom
claude/flightbox-security-audit-z16av5
Aug 17, 2026
Merged

Constrain payment method and invoice recipient#859
rzueger merged 1 commit into
developfrom
claude/flightbox-security-audit-z16av5

Conversation

@rzueger

@rzueger rzueger commented Aug 17, 2026

Copy link
Copy Markdown
Member

What

Closes the two remaining server-side controls of the client-controlled-billing
finding (the fee/tax half is already server-owned):

  1. Payment method enum. RTDB rules restricted paymentMethod.method from
    "any non-empty string ≤ 50 chars" to the known set — card, checkout,
    cash, card_external, twint_external, invoice (the canonical
    PAYMENT_METHODS). Safe global tightening: the client only ever writes these.

  2. Invoice-recipient authorization. A direct database writer could set
    invoiceRecipientName to any value and bill another organization. On the
    trusted arrival write path, a declared invoice recipient is now kept only
    when the arrival author's authenticated email is listed on that recipient in
    settings/invoiceRecipients; otherwise it is cleared (and logged). This
    mirrors what fetchUserInvoiceRecipients already enforces for the UI.

Why the recipient check is server-side

settings/invoiceRecipients is an array of { name, emails }. RTDB rules
cannot iterate an array to find a matching name and check its emails, so the
authorization can't be expressed in rules. It runs on the same trusted write
path as the fee recompute, gated by the same /settings/landingFeesStrategy
switch, and only acts on method === 'invoice' records with an unauthorized
recipient (never touches legitimate invoices).

Tests

functions/fees/computeArrivalFees.spec.js — clears an unauthorized recipient,
keeps an authorized one, clears when the author has no authenticated email,
ignores non-invoice methods, no-ops when no recipient is set, and handles the
recipient list stored as an index-keyed object; plus an integration case
through the recompute trigger. Rules generation verified (method enum present,
no stray tokens). Full functions suite green (443).


Generated by Claude Code

Two remaining server-side controls for arrival billing integrity.

Rules now restrict paymentMethod.method to the known set (card,
checkout, cash, card_external, twint_external, invoice) instead of
any non-empty string.

On the trusted arrival write path, authorize the declared invoice
recipient: a recipient is only kept when the arrival author's
authenticated email is listed on it in settings/invoiceRecipients;
otherwise it is cleared. The recipient list is an array the rules
cannot search, so this is enforced server-side, gated by the same
landing-fee-strategy switch as the fee recompute.
@rzueger
rzueger merged commit b75fbf1 into develop Aug 17, 2026
2 checks passed
@rzueger
rzueger deleted the claude/flightbox-security-audit-z16av5 branch August 17, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants