flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Security] Authenticate webhook management endpoints and stop trusting client-supplied userAddress

Open blurbeast opened this issue 2 weeks ago • 3 comments

Overview & Background

All webhook management routes (createWebhook, listWebhooks, deleteWebhook, updateWebhook, regenerateSecret, listDeliveries, testWebhook) are mounted with no auth middleware. Ownership is "verified" purely from request input: the controller reads userAddress from req.body / query and the service scopes queries by it. Any unauthenticated caller can create, list, update, or delete any wallet's webhook subscriptions by quoting the victim's address, and POST /v1/webhooks/:id/secret returns a freshly generated signing secret for someone else's subscription — enabling forged, validly-signed webhook payloads to the victim's endpoint.


Technical Specification & Architecture

  1. Add requireAuth to every webhook route in backend/src/routes/v1/webhook.routes.ts:66-196 (the file currently imports no auth middleware, and backend/src/routes/v1/index.ts:19 adds no global auth).
  2. Derive ownership server-side: compare req.user.publicKey against the subscription's owner. Never accept userAddress from body/query as an authorization input (backend/src/controllers/webhook.controller.ts:15, :50; backend/src/services/webhook.service.ts:173-177).
  3. Audit regenerateWebhookSecret so the new secretKey is only returned to the authenticated owner.

Target Files

  • backend/src/routes/v1/webhook.routes.ts
  • backend/src/controllers/webhook.controller.ts
  • backend/src/services/webhook.service.ts

Acceptance Criteria

  • [ ] Every webhook route requires authentication.
  • [ ] Operations are scoped to req.user.publicKey; supplying another address has no effect.
  • [ ] Unauthenticated tests for all seven endpoints return 401.
  • [ ] Cross-tenant access tests (acting on another user's subscription) return 403/404.

blurbeast avatar Nov 18 '26 19:11 blurbeast

@OlamideAdesina has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

Hi maintainer, I can get this issue fixed quickly. Please assign it to me

ℹ️ Repo Maintainers: To accept this application, review their application or assign @OlamideAdesina to this issue.

OlamideAdesina avatar Nov 21 '26 12:11 OlamideAdesina

Congratulations, @OlamideAdesina! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

🧑‍💻 @OlamideAdesina: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Nov 21 '26 12:11 drips-wave[bot]

This issue has been completed by @OlamideAdesina as part of the Stellar Wave Program's 11th Wave 🥳

😎 @OlamideAdesina: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Nov 22 '26 09:11 drips-wave[bot]