[api] audit fixes: account tests, dependencies and security hardening (#54)

* test(accounts): cover three username changes

* chore(deps): update vulnerable runtime dependencies

* fix(security): bound uploads and validate token subjects strictly

---------

Co-authored-by: Nexi (CWN) <communityshieldofficial@gmail.com>
This commit is contained in:
Nexi
2026-09-09 04:47:58 +01:00
committed by GitHub
parent 9696c56317
commit 222547ee13
38 changed files with 1161 additions and 632 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
},
"dependencies": {
"@hono/standard-validator": "0.2.2",
"hono": "4.12.27",
"hono": "4.13.5",
"http-codex": "0.6.7",
"workers-tagged-logger": "1.0.1",
"zod": "4.4.3"
+1 -1
View File
@@ -11,7 +11,7 @@
},
"dependencies": {
"@repo/domain": "workspace:*",
"hono": "4.12.27"
"hono": "4.13.5"
},
"devDependencies": {
"@cloudflare/workers-types": "4.20260630.1",
+6 -2
View File
@@ -52,8 +52,12 @@ export async function validateAndGetAccountId(
const accountId = await getAccountIdFromToken(token, secret)
if (!accountId) return null
const id = Number.parseInt(accountId, 10)
return Number.isNaN(id) ? null : id
// `parseInt("42junk", 10)` is 42, which lets a malformed subject select a real
// account. Token subjects are canonical positive base-10 account ids: reject
// partial parses, signs, decimals, leading zeroes and values outside JS's safe range.
if (!/^[1-9]\d*$/.test(accountId)) return null
const id = Number(accountId)
return Number.isSafeInteger(id) ? id : null
}
/**
+1 -1
View File
@@ -36,7 +36,7 @@
"dependencies": {
"esbuild": "0.28.1",
"slugify": "1.6.9",
"wrangler": "4.105.0",
"wrangler": "4.128.0",
"yaml": "2.9.0",
"zod": "4.4.3",
"zx": "8.8.5"