|
| 1 | +# Security Audit — Trustline Manager (issue #598) |
| 2 | + |
| 3 | +## Scope & method |
| 4 | + |
| 5 | +Static review of the entire `backend/` tree for any trustline-management surface: |
| 6 | +`changeTrust` / `change_trust` / `allowTrust` operations, `Asset` trustline |
| 7 | +handling, and any module named "Trustline Manager". |
| 8 | + |
| 9 | +## Finding: no Trustline Manager module exists |
| 10 | + |
| 11 | +There is **no trustline-management code in the repository**: |
| 12 | + |
| 13 | +- `grep -rniE "changeTrust|change_trust|allowTrust|trustline"` over `backend/src` |
| 14 | + returns **zero** matches. |
| 15 | +- The only Stellar asset/operation surface is in `src/lib/stellar.js`: |
| 16 | + - `StellarSdk.Asset.native()` (native XLM only) — `stellar.js:237` |
| 17 | + - `StellarSdk.Operation.payment(...)` — `stellar.js:638` |
| 18 | + - `findStrictReceivePaths(...)` (strict-receive path **quoting**, read-only) — `stellar.js:418` |
| 19 | + - `verifyTransactionSignature(...)` (signature verification) — `stellar.js:731` |
| 20 | + |
| 21 | +The platform settles payments against assets the receiving account already |
| 22 | +trusts; it never builds, submits, or manages `changeTrust` operations on behalf |
| 23 | +of users. So there is no Trustline Manager to audit. |
| 24 | + |
| 25 | +## Security implication of the current design |
| 26 | + |
| 27 | +Because the backend never issues `changeTrust`, the trustline attack surface |
| 28 | +(unbounded trust limits, trusting an attacker-controlled issuer, trustline |
| 29 | +removal griefing) **does not exist server-side** — trust decisions remain with |
| 30 | +the end user's wallet. This is the safer default. |
| 31 | + |
| 32 | +## Recommendations (for if/when a Trustline Manager is introduced) |
| 33 | + |
| 34 | +If trustline management is added later, the audit checklist should be: |
| 35 | + |
| 36 | +1. **Issuer allow-listing** — never `changeTrust` to an arbitrary |
| 37 | + caller-supplied issuer; validate against a vetted asset registry. |
| 38 | +2. **Explicit trust limits** — set a bounded `limit` rather than the max default. |
| 39 | +3. **Authorization** — gate any trustline mutation behind `requireApiKeyAuth` |
| 40 | + and merchant scoping (the pattern already used for `/api/payments*` in |
| 41 | + `src/app.js:282`). |
| 42 | +4. **Signature verification** — reuse `verifyTransactionSignature` |
| 43 | + (`src/lib/stellar.js:731`) before submitting any user-authorized changeTrust. |
| 44 | +5. **Idempotency** — route mutations through `idempotencyMiddleware`. |
| 45 | + |
| 46 | +## Conclusion |
| 47 | + |
| 48 | +No action possible against a non-existent module; documented the absence, the |
| 49 | +(safe) reason for it, and the audit criteria for a future implementation. This |
| 50 | +issue should be re-scoped to "build a Trustline Manager" before code work is |
| 51 | +meaningful. |
0 commit comments