fix(screener-api): enforce HMAC timestamp freshness on /api/data/sync - #4078
fix(screener-api): enforce HMAC timestamp freshness on /api/data/sync#4078SashaMIT wants to merge 1 commit into
Conversation
authMiddleware included X-Signature-timestamp (and nonce) in the signed message but never checked skew, so a captured blacklist create/update/delete could be replayed indefinitely. Also bind X-Signature-appid to cfg.AppID and compare digests with hmac.Equal.
|
@SashaMIT is attempting to deploy a commit to the synapsecns Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe screener authentication middleware now validates signature timestamps within a five-minute skew and compares signatures in constant time. Table-driven tests cover valid, stale, future, empty, and non-numeric timestamps. ChangesSignature authentication
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
POST /api/data/syncHMAC auth foldsX-Signature-timestampandX-Signature-nonceinto the signed message, but the server never enforced timestamp freshness (or app id binding). A captured valid request could be replayed indefinitely against blacklist create/update/delete.Change
X-Signature-timestampis outside a 5-minute skew window (or non-numeric).X-Signature-appidto match configuredAppID.hmac.Equal.Nonce uniqueness is not persisted here (would need shared storage); freshness closes indefinite replay of old captures.
Test plan
GOWORK=off go test ./screener/ -run TestSignatureTimestampFresh→ okTip:
ef5f972c4be446b74daf781b6a90b6198b7a4486Made with Cursor
Summary by CodeRabbit