aboutsummaryrefslogtreecommitdiffstats
path: root/routes/payments.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-12-04 17:24:25 -0700
committerAdam Soltys <[email protected]>2026-12-04 17:24:25 -0700
commitd1db874a6e3c3c488331f3117f41b48480354f4e (patch)
tree18d38dae915ac4efcefe2ac336223689ec1933c2 /routes/payments.ts
parentdfe22eee4e698731c3e31420250bb158f2d4b2d5 (diff)
downloadcoinos-server-d1db874a6e3c3c488331f3117f41b48480354f4e.tar.gz
coinos-server-d1db874a6e3c3c488331f3117f41b48480354f4e.zip
Admin only from Adam's addresses: the admin account's sessions and the admin password are refused from anywhere else.HEADmasterHEAD
After the 2026-12-04 desk breach the JWT secret was kept, so a copied or forged admin session must be useless off Adam's networks. config.adminIps lists exact addresses and IPv4 ranges; a request is judged by its Cloudflare client address (the app is only reachable through the tunnel and Caddy), and Tor pages never qualify. A global preHandler (after each route's auth) answers 403 to an admin session from elsewhere; the master-password login and freeze only accept adminpass from an allowed address. Unset or empty adminIps keeps the old behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar
Diffstat (limited to 'routes/payments.ts')
-rw-r--r--routes/payments.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/routes/payments.ts b/routes/payments.ts
index ca68bcdf..69eb992e 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -35,6 +35,7 @@ import rpc from "@coinos/rpc";
import got from "got";
import { safeGot } from "$lib/safe-fetch";
import { v4 } from "uuid";
+import { adminIpAllowed } from "$lib/adminip";
// Funds are closed. The mechanism let a caller pull unbacked balance out of a
// fund (the /take drain, 2026-08-25) and its deposit path never had a
@@ -791,7 +792,7 @@ export default {
body: { secret },
} = req;
try {
- if (!config.adminpass || secret !== config.adminpass) fail("unauthorized");
+ if (!config.adminpass || secret !== config.adminpass || !adminIpAllowed(req)) fail("unauthorized");
await s("freeze", true);
res.send("ok");
} catch (e) {