--- issue: "004" title: "fetch-tx, auto-fetch-missing, and debug payment endpoints have no authentication" severity: critical domain: payment labels: [security, backend, bug] status: open created: 2026-05-29 source: Doc vs Code Audit 2026-05-29 --- # 🔴 fetch-tx, auto-fetch-missing, and debug payment endpoints have no authentication **Severity:** critical **Domain:** payment **Labels:** security, backend, bug ## Description Three backend payment endpoints are mounted with **no `authenticateToken` middleware**, despite being documented as admin-only: 1. `POST /api/payment/payments/:id/fetch-tx` — triggers on-chain transaction fetch for a payment 2. `POST /api/payment/payments/auto-fetch-missing` — triggers bulk on-chain fetch for all pending payments 3. `GET /api/payment/payments/:id/debug` — returns full payment document including blockchain metadata and wallet monitor state Any unauthenticated caller (no Authorization header needed) can call all three endpoints. ## Current Behavior ```bash curl -X POST https://api.example.com/api/payment/payments/anyId/fetch-tx # Returns 200 and triggers on-chain state write ``` ## Expected Behavior All three endpoints should require `authenticateToken` + `authorizeRoles('admin')` and return `401` without credentials. ## Affected Files - `backend/src/routes/paymentRoutes.js` — route definitions for `fetch-tx`, `auto-fetch-missing`, `debug` ## References - [Doc vs Code Audit Report](../09%20-%20Audits/Doc%20vs%20Code%20Audit%20Report%20-%202026-05-29.md) — Findings C28, M40 - Related: [[ISSUE-005-scanner-status-no-auth]]