Repository navigation
Security/billframe reliability hardening - #1
Conversation
…, webhooks, and PIN security - Credential Security: Revoke and eliminate hardcoded Groq key; enforce strict client BYOK and offline heuristic execution; add automated secret scanner regression guard - CI Portability: Eliminate machine-specific artifact paths; add portable PDF binaries in tests/fixtures/pdf/; run Jest in-band to eliminate worker IPC BigInt serialization crashes - Cloud Synchronization: Disallow anonymous token bearer authentication and mock user fallbacks; enforce JWT session verification; add strict SQL column allowlists and safe timestamp-based LWW upsert; add cloud sync tables with RLS in cloud/schema.sql - Payment Webhooks: Add atomic stored procedure process_payment_webhook with ON CONFLICT deduplication; verify HMAC-SHA256 signatures with constant-time equality and database error bubbling - PIN & Local Data Security: Replace Math.random with cryptographically secure PRNG salt generation (32 bytes / 64 hex chars); implement constant-time comparison and 30-second brute-force lockout after 5 consecutive failures - Documentation: Update README.md and SECURITY.md with security trust boundaries and BYOK instructions
…ping, and lockout feedback
… and resolve canonical tab paths
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5823e0f6b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| RETURN jsonb_build_object('success', TRUE, 'status', 'processed', 'event_id', p_event_id); | ||
| END; | ||
| $$ LANGUAGE plpgsql SECURITY DEFINER; |
There was a problem hiding this comment.
Restrict webhook RPC execution to the service role
On a standard Supabase deployment, PostgreSQL grants new functions EXECUTE privileges to PUBLIC by default. This SECURITY DEFINER function has no caller authorization or signature validation, and repository-wide inspection found no corresponding privilege revocation. A client can therefore call /rest/v1/rpc/process_payment_webhook directly with an arbitrary signature and payment-link ID, insert an event marked verified, and mark another tenant's payment request paid while bypassing RLS and the edge function's HMAC check. Revoke execution from PUBLIC and client roles and grant it only to the service role used by the webhook.
Useful? React with 👍 / 👎.
| documents: new Set([ | ||
| 'id', 'business_id', 'customer_id', 'doc_type', 'document_number', 'issue_date', | ||
| 'due_date', 'status', 'currency', 'subtotal_minor', 'tax_total_minor', | ||
| 'discount_total_minor', 'grand_total_minor', 'balance_due_minor', 'notes', | ||
| 'terms', 'payment_details', 'created_at', 'updated_at' |
There was a problem hiding this comment.
Match synchronization allowlists to the actual SQLite schema
When pulling records produced by another Billframe device, these allowlists strip real persisted columns instead of just unknown fields. For example, documents requires business_profile_id, but this list permits business_id instead, so inserting a new remote document fails with NOT NULL constraint failed: documents.business_profile_id (reproduced against src/data/database/schema.ts). The payments list likewise drops required invoice_id, while profile, customer, and catalog lists silently discard addresses, banking details, tax rates, and other real fields. Align all allowlists with the local schema so authenticated synchronization can restore complete records.
Useful? React with 👍 / 👎.
| if (!config.authToken || !config.userId) { | ||
| return { |
There was a problem hiding this comment.
Provide an authentication flow before requiring a session token
For users configuring cloud sync through the app, this guard now rejects every synchronization attempt: src/app/settings/cloud-sync.tsx only saves the project URL, anon key, and optional user ID, never authToken. Repository-wide searches for token writes and authentication handlers found no production sign-in flow or other caller that populates the newly introduced token key. Keep the authenticated-session requirement, but wire up a way to obtain and persist that session; otherwise the error asks users to log in through a flow that does not exist.
Useful? React with 👍 / 👎.
| const existingRow: any = await db.getFirstAsync( | ||
| `SELECT ${mapping.pk}, updated_at FROM ${mapping.local} WHERE ${mapping.pk} = ?;`, | ||
| [pkVal] | ||
| ); |
There was a problem hiding this comment.
Handle document items without an updated_at column
Whenever the pull contains a document item, this unconditional lookup fails before either insertion or update because document_items has no updated_at column in the SQLite schema or migrations. Executing the query against the repository schema produces no such column: updated_at. The surrounding table-level catch then abandons the remaining item rows, so line items cannot be downloaded even after the allowlists are corrected. Use a table-specific conflict strategy or add and populate the timestamp through a migration.
Useful? React with 👍 / 👎.
| } else { | ||
| await this.recordFailedAttempt(); | ||
| return false; |
There was a problem hiding this comment.
Count complete PIN submissions rather than partial prefixes
For a six-digit PIN, LockChallengeScreen.handleKeyPress calls verification after digits four, five, and six, so this new counter records three failures for one incorrect entry. After one wrong six-digit entry, typing the correct PIN reaches the five-failure lockout at its fifth digit and clears the input before the sixth digit can be entered. Since expiration does not reset the failure counter, subsequent attempts lock out again at the fourth digit, preventing the owner from unlocking even with the correct PIN. Count only completed submissions, or make automatic verification aware of the configured PIN length.
Useful? React with 👍 / 👎.
…qualizer, and monochrome action bottom sheet
…and fix streaming scroll jitter
Description
Briefly describe the purpose of this PR and what problem it solves.
Type of Change
Checklist
npm run typecheckpasses).BigIntminor units without floating-point math.npm testpasses).