Problem
All four real-time indexer POST endpoints have no authentication:
/api/index/trade
/api/index/storyline
/api/index/plot
/api/index/donation
Anyone can spam these with arbitrary txHash values, causing excessive RPC calls (getReceiptWithRetry + getBlock + readContract per call). The cron routes correctly verify CRON_SECRET, but the real-time routes do not.
No data integrity risk (events are verified on-chain), but this is a DoS vector via RPC cost amplification.
Fix
Add CRON_SECRET or a separate INDEX_SECRET header check to all four real-time indexer routes. The frontend calls these after successful transactions, so the secret can be passed from the client (or use a lightweight API key).
Alternative: rate-limit by IP or require a valid recent tx hash (check tx exists and is < 5 min old before processing).
Files to modify
src/app/api/index/trade/route.ts
src/app/api/index/storyline/route.ts
src/app/api/index/plot/route.ts
src/app/api/index/donation/route.ts
Branch
task/636-indexer-auth
Acceptance criteria
Self-Verification (T3)
Problem
All four real-time indexer POST endpoints have no authentication:
/api/index/trade/api/index/storyline/api/index/plot/api/index/donationAnyone can spam these with arbitrary
txHashvalues, causing excessive RPC calls (getReceiptWithRetry+getBlock+readContractper call). The cron routes correctly verifyCRON_SECRET, but the real-time routes do not.No data integrity risk (events are verified on-chain), but this is a DoS vector via RPC cost amplification.
Fix
Add
CRON_SECRETor a separateINDEX_SECRETheader check to all four real-time indexer routes. The frontend calls these after successful transactions, so the secret can be passed from the client (or use a lightweight API key).Alternative: rate-limit by IP or require a valid recent tx hash (check tx exists and is < 5 min old before processing).
Files to modify
src/app/api/index/trade/route.tssrc/app/api/index/storyline/route.tssrc/app/api/index/plot/route.tssrc/app/api/index/donation/route.tsBranch
task/636-indexer-authAcceptance criteria
Self-Verification (T3)
npm run dev, callPOST /api/index/tradewithout auth header — verify 401 responsePOST /api/index/storylinewithout auth — verify 401POST /api/index/plotwithout auth — verify 401POST /api/index/donationwithout auth — verify 401npm run build— no errors