mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 15:11:29 -07:00
[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:
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user