Commit 0db3ef0
security: fix all findings from 2026-04-10 and 2026-04-11 audit reports
## 2026-04-11 report
Fix 1 HIGH admin/server.js: add per-IP rate limiting on POST /auth/login
(5 attempts / 15 min, proxy-aware X-Forwarded-For)
Fix 2 MED relay.js: replace 3 remaining plain === ADMIN_TOKEN comparisons
with safeEqual() (/health, /metrics, /v2/reload-users)
Fix 3 MED admin/server.js: remove pgp_ enterprise path — require ADMIN_TOKEN only
Fix 4 MED relay.js /v2/dl/:token/get: defer blob deletion to res 'finish' event;
block concurrent downloads with in_progress flag;
clear flag on socket close before finish (allow retry)
Fix 5 MED relay.js verifyTotp: evaluate all windows without early return;
use timingSafeEqual; reject reused codes via _usedTotpCodes map
Fix 6 MED relay.js: replace readFileSync/writeFileSync in key create/revoke
with serialized async write queue (_writeUsersJson)
Fix 7 MED relay.js: paginate GET /v2/relays (limit/offset, max 200);
evict oldest registry entry when MAX_RELAY_REGISTRY reached
Fix 8 MED relay.js: replace appendFileSync CT log writes with async write stream;
log rotation when file exceeds CT_MAX_SIZE (default 100 MB);
flush queue on SIGTERM/SIGINT
Fix 9 LOW relay.js: replace O(n) DID registry scans with O(1) didRegistry.get()
Fix 10 LOW admin/server.js: strip internal error detail from 502 response
Fix 11 MED relay.js isSsrfSafeUrl(): restrict webhook ports to 443 (HTTPS only)
Fix 12 LOW relay.js: close active WebSocket connections on key revocation
Fix 13 LOW relay.js: validate plan string against VALID_PLANS allowlist
Fix 14 LOW relay.js base32Decode: throw on invalid Base32 char;
validate TOTP_SECRET at startup
## 2026-04-10 report
Fix A HIGH fly-relay not present in this repo — N/A
Fix B HIGH relay.js: stream-next now returns real blob hashes from per-device
delivery queue (deviceQueues) populated on /v2/inbound
Fix C HIGH relay.js: DNS rebinding check already present (pushWebhooks) — verified
Fix D MED sdk-js/index.js: detectRelay sends API key in X-Api-Key header
instead of ?k= query param; fail explicitly on no relay found
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent e32186e commit 0db3ef0
3 files changed
Lines changed: 237 additions & 58 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
| |||
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
81 | 99 | | |
82 | 100 | | |
83 | 101 | | |
84 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
85 | 106 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
90 | 110 | | |
91 | | - | |
| 111 | + | |
92 | 112 | | |
93 | 113 | | |
94 | | - | |
| 114 | + | |
95 | 115 | | |
96 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
97 | 121 | | |
98 | 122 | | |
99 | 123 | | |
| |||
0 commit comments