Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ jobs:
- run: npm run lint
- run: npm run typecheck
- run: npm test
- name: Verify migrations, owner isolation and account deletion
- name: Verify migrations, owner isolation, account deletion and rate limits
run: |
npm install --prefix "$RUNNER_TEMP/buffer-pglite" --no-package-lock --no-audit --no-fund @electric-sql/[email protected]
export BUFFER_PGLITE_MODULE="$RUNNER_TEMP/buffer-pglite/node_modules/@electric-sql/pglite/dist/index.js"
node scripts/verify-alert-schema.mjs
node scripts/verify-hosted-monitoring.mjs
node scripts/verify-monitoring-scheduler.mjs
node scripts/verify-account-deletion.mjs
node scripts/verify-rate-limit.mjs
- run: npm run build

# Deterministic browser regressions block the release. External credentials
Expand Down
4 changes: 4 additions & 0 deletions docs/DATABASE-VERIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,7 @@ The initial scheduler preparation applied as `20260919183534`, but hosted postfl


The synchronous trigger migration applied as `20260919185033` (`use_synchronous_monitoring_trigger`). Hosted checks confirm http 1.6, HEAD-only helper with no net calls, non-debug logging, private-helper execution denied to anon/authenticated/service_role, and Vault reads denied to browser roles. The managed base HTTP function retains browser EXECUTE grants; those do not grant access to the private helper or its Vault credential and no persistent request queue is used. Scheduler activation/actual completed runs are recorded in the release evidence.

## Rate-limit retention and keyed hash (not yet applied)

`20261008120000_rate_limit_retention_and_keyed_hash.sql` fixes two read-only findings on the hosted limiter: `private.prune_rate_limits()` existed but nothing called it, so counters from 17 September onward were never deleted, and each counter key was the server's unkeyed SHA-256 of the client IP, which brute force reverses for IPv4. `public.consume_rate_limit` keeps its signature, result and secret, but stores HMAC-SHA-256 of the sent key under a random 32-byte key in `private.rate_limit_hash_key` (row-level security on, no grants to anon, authenticated or service_role), refuses windows longer than one minute, deletes expired counters on every check, and `buffer-prune-rate-limits` (pg_cron, every three minutes) removes idle ones, so no counter outlives the last request by more than four minutes. The migration deletes every counter stored under the old hash, records the limiter's tables for fresh projects, and leaves only anon (the server's publishable key, gated by the secret) able to execute the limiter. It can be applied before or after the app deploys. `scripts/verify-rate-limit.mjs` checks it locally against the hosted pre-migration definitions and against an empty project, applying it as a non-superuser owner as hosted Supabase does.
2 changes: 1 addition & 1 deletion docs/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Buffer runs on Node 24 with Next.js App Router. `/` is the public website, `/app
| `NEXT_PUBLIC_SUPABASE_URL` | Public | Dedicated Buffer project's API URL. |
| `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` | Public | Supabase publishable key; never a service-role or secret key. |
| `NEXT_PUBLIC_AUTH_EMAIL_READY` | Public | Set `true` only after email signup, confirmation, recovery, redirects, and password policy are verified. It is currently `false`, so public signup and recovery remain visibly unavailable. |
| `RATE_LIMIT_SECRET` | Server only | Optional secret for the protected Supabase `consume_rate_limit` RPC; absent/unreachable shared storage falls back to process limits. Never expose this value to the browser. |
| `RATE_LIMIT_SECRET` | Server only | Optional secret for the protected Supabase `consume_rate_limit` RPC; absent/unreachable shared storage falls back to process limits. It must equal `private.rate_limit_config.secret`; on a fresh project, `20261008120000_rate_limit_retention_and_keyed_hash.sql` generates that value. Never expose this value to the browser. |
| `BUFFER_TEST_AUTHORITY` | Local verification only | Optional public authority for manual checks; the application does not load it automatically. |
| `BUFFER_ALERT_STORE` | Local worker only | Optional path for the durable local SQLite worker; defaults to `.local/alerts.sqlite` and is ignored by Git. |

Expand Down
8 changes: 6 additions & 2 deletions e2e/legal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ test('the privacy policy is public, specific to Buffer and states what deletion
await expect(page).toHaveTitle('Privacy policy — Buffer');
await expect(page.getByRole('heading', { level: 1, name: 'Privacy policy' })).toBeVisible();
const main = page.getByRole('main');
await expect(main).toContainText('Last updated: 7 October 2026');
await expect(main).toContainText('Last updated: 8 October 2026');
await expect(main).toContainText('Operator Uplift');
await expect(main).toContainText('IPs are hashed for rate limiting and no address is stored.');
await expect(page.locator('#rate-limiting')).toContainText('HMAC-SHA-256 under a random key that never leaves our database');
await expect(page.locator('#rate-limiting')).toContainText('No counter is kept more than five minutes after your last request.');
await expect(page.locator('#retention')).toContainText('no later than five minutes after your last request');
await expect(main).not.toContainText('one-way SHA-256');
for (const processor of ['Vercel', 'Supabase', 'Solana RPC provider', 'Velocity', 'Pacifica', 'Drift', 'Jupiter', 'Discord']) await expect(main).toContainText(processor);
for (const record of ['Saved reports', 'Monitored wallet addresses and alert rules', 'Alert destinations', 'Alert events and delivery records']) await expect(page.locator('#delete-account')).toContainText(record);
await expect(page.locator('#delete-account')).toContainText('BUFFER_WEBHOOK_DESTINATIONS_JSON');
Expand All @@ -29,7 +33,7 @@ test('the terms carry the Solana dApp Store clause and the read-only limits', as
await expect(page).toHaveTitle('Terms of use — Buffer');
await expect(page.getByRole('heading', { level: 1, name: 'Terms of use' })).toBeVisible();
const main = page.getByRole('main');
await expect(main).toContainText('Last updated: 7 October 2026');
await expect(main).toContainText('Last updated: 8 October 2026');
await expect(main).toContainText('not trading advice');
await expect(main).toContainText('cross-margin-hold-others-v1');
await expect(main).toContainText('never asks for your seed phrase or private key');
Expand Down
12 changes: 12 additions & 0 deletions scripts/lib/pglite.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Disposable local PostgreSQL (PGlite) with pgcrypto loaded, because hosted
* Supabase installs pgcrypto in the `extensions` schema and migrations use it.
* BUFFER_PGLITE_MODULE may point at PGlite's dist/index.js, as CI does.
*/
const MODULE = process.env.BUFFER_PGLITE_MODULE || '@electric-sql/pglite';
const PGCRYPTO = MODULE.endsWith('/index.js') ? MODULE.replace(/index\.js$/, 'contrib/pgcrypto.js') : `${MODULE}/contrib/pgcrypto`;
const [{ PGlite }, { pgcrypto }] = await Promise.all([import(MODULE), import(PGCRYPTO)]);

export function createDatabase() {
return new PGlite({ extensions: { pgcrypto } });
}
6 changes: 4 additions & 2 deletions scripts/verify-account-deletion.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
*/
import { readdir, readFile } from 'node:fs/promises';
import assert from 'node:assert/strict';
const { PGlite } = await import(process.env.BUFFER_PGLITE_MODULE || '@electric-sql/pglite');
import { createDatabase } from './lib/pglite.mjs';

const DELETION_MIGRATION = '20261007120000_delete_own_account.sql';
const migrations = new URL('../supabase/migrations/', import.meta.url);
const db = new PGlite();
const db = createDatabase();
let checks = 0;
const ownerA = '00000000-0000-4000-8000-00000000000a';
const ownerB = '00000000-0000-4000-8000-00000000000b';
Expand Down Expand Up @@ -44,6 +44,8 @@ await db.exec(`
alter default privileges in schema public grant execute on functions to anon, authenticated, service_role;
alter default privileges for role buffer_migrator in schema public grant execute on functions to anon, authenticated, service_role;
create schema private;
-- Hosted Supabase installs pgcrypto here; the rate-limit migration uses it.
create schema extensions;
`);
const files = (await readdir(migrations)).filter(name => name.endsWith('.sql')).sort();
// It must run after every migration that created an owner-keyed table.
Expand Down
Loading
Loading