From 81a585f3a0ebfe6f4205ea07c2df552b873bdf62 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 4 Aug 2026 18:00:41 -0700 Subject: [PATCH] Validate subtype of frontier blocks. --- src/lib/account/refresh.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/account/refresh.ts b/src/lib/account/refresh.ts index b79dd45..f956dc8 100644 --- a/src/lib/account/refresh.ts +++ b/src/lib/account/refresh.ts @@ -46,6 +46,9 @@ export async function _refresh (account: Account, rpc: unknown): Promise { throw new Error('Confirmed frontier block info subtype not found') } const confirmedFrontierSubtype = resConfirmedFrontierBlockInfo.subtype + if (!['change', 'epoch', 'open', 'receive', 'send'].includes(confirmedFrontierSubtype) { + throw new RangeError('Invalid subtype for confirmed frontier block', { cause: confirmedFrontierSubtype }) + } if (!('contents' in resConfirmedFrontierBlockInfo) || resConfirmedFrontierBlockInfo.contents == null || typeof resConfirmedFrontierBlockInfo.contents !== 'object') { throw new Error('Confirmed frontier block info contents not found') } @@ -74,6 +77,9 @@ export async function _refresh (account: Account, rpc: unknown): Promise { throw new Error('Frontier block info subtype not found') } const frontierSubtype = resFrontierBlockInfo.subtype + if (!['change', 'epoch', 'open', 'receive', 'send'].includes(frontierSubtype) { + throw new RangeError('Invalid subtype for frontier block', { cause: frontierSubtype }) + } if (!('contents' in resFrontierBlockInfo) || resFrontierBlockInfo.contents == null || typeof resFrontierBlockInfo.contents !== 'object') { throw new Error('Frontier block info contents not found') } -- 2.52.0