Security + logic review of the reuse-detection path:
- DoS: cap request text at 20k chars (detection shingles the whole
string); oversized -> 413
- info leak: stop returning author payout wallet addresses in the
detect response (ReuseMatch.wallet flowed through to JSON)
- abuse: per-IP fixed-window rate limit (30/min) -> 429 + retry-after
- perf: build the comparison corpus once instead of rebuilding the
source graph (createSource hashing) on every request
- secret: never ship a hard-coded proof-signing secret — fall back to a
per-process random one in production when CITATION_PROOF_SECRET is
unset; document the var in .env.example
- guard malformed/failed detection behind 400/500
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>