Repository navigation
Description
Affected layers
- Frontend (
src/): affected. Four reads insrc/hooks/usePoolData.tsrequest one page and treat it as the whole population:fetchAllSv2Clientsfor/clients(Load every SV2 client page before computing dashboard state #341) and for each client's/clients/{id}/channels(dashboard: every page of a paginated monitoring endpoint is read #330), the pool and translator/server/channelsqueries (Paginate server-channel responses used by monitoring modes #338), anduseSv1ClientsData, whichUnifiedDashboardcalls withlimit=1000for/sv1/clientsalthough the API caps a page at 100 (Paginate SV1 workers before dashboard aggregation #336). None of them reads thetotal,total_extendedortotal_standardfields the responses carry. - Backend (
server/): not affected. The monitoring proxies forward the query string unchanged, and the backend reads no monitoring endpoint itself. shared/: not affected.shared/openapi.jsonis the contract these reads ignore: each of these endpoints is paginated with a default page of 25 and a maximum of 100, and the generated types already expose the totals.
Problem
With more than 100 downstream SV2 clients, more than 100 channels under one client, more than 100 upstream server channels or more than 100 SV1 workers, the dashboard never requests the later pages. Those clients, channels and workers are missing from the worker tables, the counts, the hashrate sums, the best-difficulty and block entries, and from the metrics the dashboard persists.
Impact
A downstream peer that opens enough connections or channels can place its own beyond the first page and mine unseen by the operator. The same blind spot appears without an attacker on any deployment that crosses 100 of anything. The aggregate endpoints may show a different total, but they do not restore the missing identities.
Expected outcome
- Every dashboard value computed from a paginated monitoring endpoint covers every item the endpoint reports, for any population size, on both the JDC and the translator APIs.
- When a later page cannot be loaded, the dashboard does not present the first page as complete.
- Tests built from representative upstream payloads, as
docs/monitoring-api-compatibility.mdasks, cover a two-page response for each of the four endpoints.
Possible approach (non-binding)
One helper that follows offset until the loaded count reaches the reported total, with a ceiling on pages to bound the work, used by the fou
9798
r reads; useSv1ClientsData would then stop taking a page size from its caller. Once the first page reports the total, the remaining pages of one poll can load in parallel.
Loupe findings
- project-loupe/audit-sv2-ui#69: per-client channel pages (reported as dashboard: every page of a paginated monitoring endpoint is read #330)
- project-loupe/audit-sv2-ui#49: SV2 client pages (reported as Load every SV2 client page before computing dashboard state #341)
- project-loupe/audit-sv2-ui#52: server channel pages in both monitoring modes (reported as Paginate server-channel responses used by monitoring modes #338)
- project-loupe/audit-sv2-ui#55: SV1 worker pages (reported as Paginate SV1 workers before dashboard aggregation #336)
Related issues and PRs
- Paginate SV1 workers before dashboard aggregation #336, Paginate server-channel responses used by monitoring modes #338 and Load every SV2 client page before computing dashboard state #341 reported the same omission at the other three call sites and were closed as duplicates of this issue; their Loupe exports are kept below.
- dashboard: merging an over-cap channel snapshot costs linear work per poll #340 bounds the eviction cost in the persisted metrics; loading every page raises the number of entries that reach it.
- Tracker: [Tracker] Dashboard metrics #373.
Loupe export for #330 (finding #69)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
1451e3b6e9364b5eb043b479fe5dabed74f1739c - title: Load every per-client SV2 channel page
- severity:
low - location:
src/hooks/usePoolData.ts:122-128 - scanner:
llm-code-review - fingerprint:
e2e9697f00881aa245ed1d168d56b1297973a52cf2be5add50dce11817ad61d8
Description
For each SV2 client, fetchAllSv2Clients requests only /channels?offset=0&limit=100 and returns those arrays as the client's complete channel set. The checked-in OpenAPI contract caps this endpoint at 100 items and supplies total_extended and total_standard, but neither total is consulted. A downstream SV2 peer that can open 101 or more channels under one connection can therefore place live channels beyond the first page. Those channels disappear from sv2Clients and the aggregate clientChannels; the dashboard consequently omits their identities, hashrate, shares, best-difficulty, and block telemetry. This is a low-severity monitoring-evasion/integrity issue: it does not grant code execution or disclose data, but it can conceal miner activity from an operator. The regression test serves a compliant two-page response with 101 extended channels and proves HEAD returns only the first 100. A fix should follow pagination until both advertised totals are represented, with sensible overall and concurrency bounds. Prior finding #13075 was reviewed and covers pagination of the top-level client list only; #13079 covers /server/channels, and dismissed #894 covers client_id path encoding, so none duplicate this per-client channel omission.
Proof of Concept
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -109,7 +109,7 @@ function aggregateSv2ClientChannels(clients: Sv2ClientWithChannels[]): Aggregate
/**
* Fetch all Sv2 clients plus their channels.
*/
-async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels[]> {
+export async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels[]> {
const clientsResponse = await fetchWithTimeout<Sv2ClientsResponse>(`${baseUrl}/clients?offset=0&limit=100`);
if (clientsResponse.items.length === 0) {
diff --git a/src/hooks/usePoolData.test.ts b/src/hooks/usePoolData.test.ts
new file mode 100644
--- /dev/null
+++ b/src/hooks/usePoolData.test.ts
@@ -0,0 +1,70 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+
+import { fetchAllSv2Clients } from './usePoolData.js';
+
+test('fetchAllSv2Clients loads every page of channels for each client', async () => {
+ const originalFetch = globalThis.fetch;
+ const firstPage = Array.from({ length: 100 }, (_, channel_id) => ({ channel_id }));
+
+ globalThis.fetch = (async (input: RequestInfo | URL) => {
+ const url = String(input);
+ let body: unknown;
+
+ if (url === '/jdc-api/v1/clients?offset=0&limit=100') {
+ body = {
+ offset: 0,
+ limit: 100,
+ total: 1,
+ items: [{
+ client_id: 7,
+ client_kind: 'miner',
+ extended_channels_count: 101,
+ standard_channels_count: 0,
+ total_hashrate: 0,
+ }],
+ };
+ } else if (url === '/jdc-api/v1/clients/7/channels?offset=0&limit=100') {
+ body = {
+ client_id: 7,
+ offset: 0,
+ limit: 100,
+ total_extended: 101,
+ total_standard: 0,
+ extended_channels: firstPage,
+ standard_channels: [],
+ };
+ } else if (url === '/jdc-api/v1/clients/7/channels?offset=100&limit=100') {
+ body = {
+ client_id: 7,
+ offset: 100,
+ limit: 100,
+ total_extended: 101,
+ total_standard: 0,
+ extended_channels: [{ channel_id: 100 }],
+ standard_channels: [],
+ };
+ } else {
+ throw new Error('unexpected request: ' + url);
+ }
+
+ return new Response(JSON.stringify(body), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ });
+ }) as typeof globalThis.fetch;
+
+ try {
+ const clients = await fetchAllSv2Clients('/jdc-api/v1');
+ assert.equal(clients.length, 1);
+ assert.equal(
+ clients[0].extended_channels.length,
+ 101,
+ 'the channel advertised on the second page must not disappear from monitoring',
+ );
+ assert.equal(clients[0].extended_channels.at(-1)?.channel_id, 100);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+
Suggested Fix
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -117,13 +117,33 @@ async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels
const clientsWithChannels = await Promise.all(clientsResponse.items.map(async (client) => {
try {
- const channels = await fetchWithTimeout<Sv2ClientChannelsResponse>(
- `${baseUrl}/clients/${client.client_id}/channels?offset=0&limit=100`
- );
+ const extendedChannels: ExtendedChannelInfo[] = [];
+ const standardChannels: StandardChannelInfo[] = [];
+ let offset = 0;
+ let totalExtended = 0;
+ let totalStandard = 0;
+
+ do {
+ const channels = await fetchWithTimeout<Sv2ClientChannelsResponse>(
+ `${baseUrl}/clients/${client.client_id}/channels?offset=${offset}&limit=100`
+ );
+
+ extendedChannels.push(...channels.extended_channels);
+ standardChannels.push(...channels.standard_channels);
+
+ if (offset === 0) {
+ totalExtended = channels.total_extended;
+ totalStandard = channels.total_standard;
+ }
+ offset += 100;
+ } while (
+ (extendedChannels.length < totalExtended || standardChannels.length < totalStandard)
+ && offset < totalExtended + totalStandard
+ );
return {
...client,
- extended_channels: channels.extended_channels,
- standard_channels: channels.standard_channels,
+ extended_channels: extendedChannels,
+ standard_channels: standardChannels,
};
} catch {
return {
This finding was discovered by Project Loupe.
Loupe export for #341 (finding #49)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
b610455ac2d1e017c1df5db8787c0b2e505eabdc - title: Load every SV2 client page before computing dashboard state
- severity:
low - location:
src/hooks/usePoolData.ts:113 - scanner:
llm-code-review - fingerprint:
d29b09fc7b803839f2e734df366d6830d9d9282be8c7c802a4959b0562ae43ff
Description
fetchAllSv2Clients promises to load all SV2 clients, but it requests only offset=0&limit=100 and ignores Sv2ClientsResponse.total. The API model is explicitly paginated, so a deployment with 101 or more downstream connections necessarily has later pages that this hook never requests. An adversarial downstream peer able to establish many ordinary SV2 connections can therefore push connections beyond the first page. Those connections receive no per-client channel request and disappear from the detailed dataset. UnifiedDashboard derives its worker table, direct-worker count, hashrate, best-difficulty entries, and block entries from this truncated array; the aggregate /global response may expose that totals differ, but it does not restore the omitted identities or details. This creates a low-severity monitoring-evasion and telemetry-integrity issue rather than code execution or data exposure. The PoC returns a compliant 101-client result over two pages and proves HEAD returns only 100; a fix should iterate pages using the advertised total while retaining explicit resource/concurrency bounds. Prior-finding searches for fetchAllSv2Clients pagination, usePoolData limit 100, and client offset/omission terms returned no match. Finding #894 was reviewed and is unrelated: it concerns encoding client_id in a path, not pagination.
Proof of Concept
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -109,7 +109,7 @@ function aggregateSv2ClientChannels(clients: Sv2ClientWithChannels[]): Aggregate
/**
* Fetch all Sv2 clients plus their channels.
*/
-async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels[]> {
+export async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels[]> {
const clientsResponse = await fetchWithTimeout<Sv2ClientsResponse>(`${baseUrl}/clients?offset=0&limit=100`);
if (clientsResponse.items.length === 0) {
diff --git a/src/hooks/usePoolData.test.ts b/src/hooks/usePoolData.test.ts
new file mode 100644
--- /dev/null
+++ b/src/hooks/usePoolData.test.ts
@@ -0,0 +1,70 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+
+import { fetchAllSv2Clients } from './usePoolData.js';
+
+test('fetchAllSv2Clients follows client-list pagination until every client is loaded', async () => {
+ const originalFetch = globalThis.fetch;
+ const firstPage = Array.from({ length: 100 }, (_, client_id) => ({
+ client_id,
+ client_kind: 'miner',
+ extended_channels_count: 0,
+ standard_channels_count: 0,
+ total_hashrate: 0,
+ }));
+ const emptyChannels = (client_id: number) => ({
+ client_id,
+ offset: 0,
+ limit: 100,
+ total_extended: 0,
+ total_standard: 0,
+ extended_channels: [],
+ standard_channels: [],
+ });
+
+ globalThis.fetch = (async (input: RequestInfo | URL) => {
+ const url = String(input);
+ let body: unknown;
+
+ if (url === '/jdc-api/v1/clients?offset=0&limit=100') {
+ body = {
+ offset: 0,
+ limit: 100,
+ total: 101,
+ items: firstPage,
+ };
+ } else if (url === '/jdc-api/v1/clients?offset=100&limit=100') {
+ body = {
+ offset: 100,<
7438
/span>
+ limit: 100,
+ total: 101,
+ items: [{
+ client_id: 100,
+ client_kind: 'miner',
+ extended_channels_count: 0,
+ standard_channels_count: 0,
+ total_hashrate: 0,
+ }],
+ };
+ } else {
+ const match = url.match(/\/clients\/(\d+)\/channels\?offset=0&limit=100$/);
+ if (!match) throw new Error(`unexpected request: ${url}`);
+ body = emptyChannels(Number(match[1]));
+ }
+
+ return new Response(JSON.stringify(body), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ });
+ }) as typeof globalThis.fetch;
+
+ try {
+ const clients = await fetchAllSv2Clients('/jdc-api/v1');
+ assert.equal(
+ clients.length,
+ 101,
+ 'the client advertised by total on the second page must be represented',
+ );
+ assert.equal(clients.at(-1)?.client_id, 100);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+Suggested Fix
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -110,31 +110,43 @@ function aggregateSv2ClientChannels(clients: Sv2ClientWithChannels[]): Aggregate
* Fetch all Sv2 clients plus their channels.
*/
async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels[]> {
- const clientsResponse = await fetchWithTimeout<Sv2ClientsResponse>(`${baseUrl}/clients?offset=0&limit=100`);
-
- if (clientsResponse.items.length === 0) {
- return [];
- }
-
- const clientsWithChannels = await Promise.all(clientsResponse.items.map(async (client) => {
- try {
- const channels = await fetchWithTimeout<Sv2ClientChannelsResponse>(
- `${baseUrl}/clients/${client.client_id}/channels?offset=0&limit=100`
- );
-
- return {
- ...client,
- extended_channels: channels.extended_channels,
- standard_channels: channels.standard_channels,
- };
- } catch {
- return {
- ...client,
- extended_channels: [],
- standard_channels: [],
+ const clientsWithChannels: Sv2ClientWithChannels[] = [];
+ let offset = 0;
+ let total = 0;
+
+ do {
+ const clientsResponse = await fetchWithTimeout<Sv2ClientsResponse>(
+ `${baseUrl}/clients?offset=${offset}&limit=100`
+ );
+
+ if (clientsResponse.items.length === 0) {
+ break;
+ }
+
+ const pageWithChannels = await Promise.all(clientsResponse.items.map(async (client) => {
+ try {
+ const channels = await fetchWithTimeout<Sv2ClientChannelsResponse>(
+ `${baseUrl}/clients/${client.client_id}/channels?offset=0&limit=100`
+ );
+
+ return {
+ ...client,
+ extended_channels: channels.extended_channels,
+ standard_channels: channels.standard_channels,
+ };
+ } catch {
+ return {
+ ...client,
+ extended_channels: [],
+ standard_channels: [],
+ };
- };
- }
- }));
+ }
+ }));
+
+ clientsWithChannels.push(...pageWithChannels);
+ offset += clientsResponse.items.length;
+ total = clientsResponse.total;
+ } while (offset < total);
return clientsWithChannels;
}
This finding was discovered by Project Loupe.
Loupe export for #338 (finding #52)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
b610455ac2d1e017c1df5db8787c0b2e505eabdc - title: Paginate server-channel responses used by monitoring modes
- severity:
low - location:
src/hooks/usePoolData.ts:167-170 - scanner:
llm-code-review - fingerprint:
15de83e348a60403a439eaf4972795351bf3afda43b9b1f44246090088055f67
Description
Both primary pool-channel loading (serverChannelsQuery) and the translator-specific helper issue exactly one /server/channels?offset=0&limit=100 request and treat its arrays as complete. The checked-in OpenAPI contract marks this endpoint paginated with a maximum page size of 100, while ServerChannelsResponse provides total_extended and total_standard; neither total is consulted. In a supported non-aggregated configuration, a large downstream worker population can produce more than 100 upstream channels. An adversarial miner able to create enough worker/channel connections can therefore move records to later pages that are never displayed. UnifiedDashboard computes share acknowledgements/rejections, best difficulty, block entries, and channel identities from these truncated arrays, producing a monitoring blind spot and incorrect persistent telemetry. The same omission exists in useTranslatorServerChannels at line 239, so JD mode's translator view is also affected; these are two mode-specific uses of the same server-channel endpoint and should share one paginating loader. The PoC performs that behavior-preserving extraction and proves a 101-channel response still returns only 100 on HEAD. Searches for serverChannelsQuery pagination total_extended, useTranslatorServerChannels limit 100, and ServerChannelsResponse pagination usePoolData found no prior report. Finding #894 is unrelated path encoding.
Proof of Concept
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -138,6 +138,12 @@ async function fetchAllSv2Clients(baseUrl: string): Promise<Sv2ClientWithChannels
return clientsWithChannels;
}
+
+export function fetchAllServerChannels(baseUrl: string): Promise<ServerChannelsResponse> {
+ return fetchWithTimeout<ServerChannelsResponse>(
+ `${baseUrl}/server/channels?offset=0&limit=100`
+ );
+}
/**
* Hook to fetch Pool connection data.
@@ -166,7 +173,7 @@ export function usePoolData(templateMode: TemplateMode = null) {
// Fetch upstream server channels (Pool connection: shares, best diff)
const serverChannelsQuery = useQuery({
queryKey: ['server-channels', mode],
- queryFn: () => fetchWithTimeout<ServerChannelsResponse>(`${baseUrl}/server/channels?offset=0&limit=100`),
+ queryFn: () => fetchAllServerChannels(baseUrl),
refetchInterval: 3000,
});
@@ -236,7 +243,7 @@ export function useTranslatorServerChannels(enabled = true) {
return useQuery({
queryKey: ['translator-server-channels'],
- queryFn: () => fetchWithTimeout<ServerChannelsResponse>(`${endpoints.translator.base}/server/channels?offset=0&limit=100`),
+ queryFn: () => fetchAllServerChannels(endpoints.translator.base),
refetchInterval: enabled ? 3000 : false,
enabled,
});
diff --git a/src/hooks/usePoolData.test.ts b/src/hooks/usePoolData.test.ts
new file mode 100644
--- /dev/null
+++ b/src/hooks/usePoolData.test.ts
@@ -0,0 +1,53 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+
+import { fetchAllServerChannels } from './usePoolData.js';
+
+test('server-channel loading follows pagination until every channel is represented', async () => {
+ const originalFetch = globalThis.fetch;
+ const firstPage = Array.from({ length: 100 }, (_, channel_id) => ({ channel_id }));
+
+ globalThis.fetch = (async (input: RequestInfo | URL) => {
+ const url = String(input);
+ let body: unknown;
+
+ if (url === '/jdc-api/v1/server/channels?offset=0&limit=100') {
+ body = {
+ offset: 0,
+ limit: 100,
+ total_extended: 101,
+ total_standard: 0,
+ extended_channels: firstPage,
+ standard_channels: [],
+ };
+ } else if (url === '/jdc-api/v1/server/channels?offset=100&limit=100') {
+ body = {
+ offset: 100,
+ limit: 100,
+ total_extended: 101,
+ total_standard: 0,
+ extended_channels: [{ channel_id: 100 }],
+ standard_channels: [],
+ };
+ } else {
+ throw new Error(`unexpected request: ${url}`);
+ }
+
+ return new Response(JSON.stringify(body), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ });
+ }) as typeof globalThis.fetch;
+
+ try {
+ const channels = await fetchAllServerChannels('/jdc-api/v1');
+ assert.equal(
+ channels.extended_channels.length,
+ 101,
+ 'the channel advertised by total_extended on the second page must be represented',
+ );
+ assert.equal(channels.extended_channels.at(-1)?.channel_id, 100);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+Suggested Fix
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -80,3 +80,36 @@ async function fetchWithTimeout<T>(url: string, timeoutMs = 5000): Promise<T> {
}
+/**
+ * Fetch all upstream server channels.
+ */
+async function fetchAllServerChannels(baseUrl: string): Promise<ServerChannelsResponse> {
+ const pageLimit = 100;
+ const firstPage = await fetchWithTimeout<ServerChannelsResponse>(
+ `${baseUrl}/server/channels?offset=0&limit=${pageLimit}`
+ );
+ const allChannels = {
+ ...firstPage,
+ extended_channels: [...firstPage.extended_channels],
+ standard_channels: [...firstPage.standard_channels],
+ };
+ const totalChannels = firstPage.total_extended + firstPage.total_standard;
+
+ for (
+ let offset = pageLimit;
+ offset <
10BC8
totalChannels && (
+ allChannels.extended_channels.length < firstPage.total_extended ||
+ allChannels.standard_channels.length < firstPage.total_standard
+ );
+ offset += pageLimit
+ ) {
+ const page = await fetchWithTimeout<ServerChannelsResponse>(
+ `${baseUrl}/server/channels?offset=${offset}&limit=${pageLimit}`
+ );
+ allChannels.extended_channels.push(...page.extended_channels);
+ allChannels.standard_channels.push(...page.standard_channels);
+ }
+
+ return allChannels;
+}
+
/**
@@ -167,5 +200,5 @@ export function usePoolData(templateMode: TemplateMode = null) {
const serverChannelsQuery = useQuery({
queryKey: ['server-channels', mode],
- queryFn: () => fetchWithTimeout<ServerChannelsResponse>(`${baseUrl}/server/channels?offset=0&limit=100`),
+ queryFn: () => fetchAllServerChannels(baseUrl),
refetchInterval: 3000,
});
@@ -236,7 +269,7 @@ export function useTranslatorServerChannels(enabled = true) {
return useQuery({
queryKey: ['translator-server-channels'],
- queryFn: () => fetchWithTimeout<ServerChannelsResponse>(`${endpoints.translator.base}/server/channels?offset=0&limit=100`),
+ queryFn: () => fetchAllServerChannels(endpoints.translator.base),
refetchInterval: enabled ? 3000 : false,
enabled,
});
This finding was discovered by Project Loupe.
Loupe export for #336 (finding #55)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
b610455ac2d1e017c1df5db8787c0b2e505eabdc - title: Paginate SV1 workers before dashboard aggregation
- severity:
low - location:
src/pages/UnifiedDashboard.tsx:121 - scanner:
llm-code-review - fingerprint:
b0ec24b7c590e0bf00edf2003d3007076f20aee7e26ea713b0abf01023c51190
Description
UnifiedDashboard calls useSv1ClientsData(0, 1000) and treats the returned items array as the complete SV1 population for active-worker counts, total hashrate, search, and the worker table. The checked-in shared/openapi.json contract states that /api/v1/sv1/clients is paginated with a maximum page size of 100, and useSv1ClientsData performs only one request and never follows the response's total. Requesting 1,000 therefore does not make the snapshot complete: with 101 connected SV1 clients, only the first 100 are represented. A downstream peer able to establish many normal SV1 connections can place a connection beyond the first page, creating a monitoring blind spot and excluding its identity, telemetry, activity state, and hashrate from dashboard-derived values. The response's aggregate total can expose a count discrepancy in some modes, so this is conservatively low severity rather than a full stealth or authorization bypass. The fix should fetch successive bounded pages until items.length reaches total, with an explicit safety cap. Prior findings #13075 and #13079 were reviewed: they cover SV2-client and server-channel pagination respectively, not this SV1 endpoint. #13074 concerns negative telemetry and is also distinct. The PoC preserves the current one-request behavior behind a testable helper, then simulates the API's 100-record cap; it fails because the 101st client is never requested.
Proof of Concept
diff --git a/src/pages/UnifiedDashboard.tsx b/src/pages/UnifiedDashboard.tsx
--- a/src/pages/UnifiedDashboard.tsx
+++ b/src/pages/UnifiedDashboard.tsx
@@ -18,6 +18,6 @@
import {
usePoolData,
- useSv1ClientsData,
+ useAllSv1ClientsData,
useTranslatorServerChannels,
useTranslatorHealth,
useJdcHealth,
@@ -118,7 +118,7 @@
const {
data: sv1Data,
isLoading: sv1Loading,
- } = useSv1ClientsData(0, 1000);
+ } = useAllSv1ClientsData();
// Health checks for the error banner (React Query deduplicates the API calls)
const { data: translatorOk, isLoading: translatorHealthLoading, isError: translatorHealthError } = useTranslatorHealth();
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -223,8 +223,36 @@
},
refetchInterval: 3000,
enabled,
});
}
+
+/**
+ * Fetch the complete SV1 client snapshot used by the dashboard.
+ *
+ * This extraction intentionally preserves the dashboard's current single
+ * oversized request so the regression test below exercises HEAD behavior.
+ */
+export async function fetchAllSv1Clients(baseUrl: string): Promise<Sv1ClientsResponse> {
+ const response = await fetch(
+ baseUrl + '/sv1/clients?offset=0&limit=1000',
+ { signal: AbortSignal.timeout(5000) },
+ );
+ if (!response.ok) {
+ throw new Error('HTTP ' + response.status);
+ }
+ return response.json() as Promise<Sv1ClientsResponse>;
+}
+
+export function useAllSv1ClientsData(enabled = true) {
+ const endpoints = getEndpointsCached();
+
+ return useQuery({
+ queryKey: ['sv1-clients', 'all'],
+ queryFn: () => fetchAllSv1Clients(endpoints.translator.base),
+ refetchInterval: 3000,
+ enabled,
+ });
+}
/**
* Hook to fetch Translator upstream channels.
diff --git a/src/hooks/usePoolData.sv1-pagination.test.ts b/src/hooks/usePoolData.sv1-pagination.test.ts
new file mode 100644
--- /dev/null
+++ b/src/hooks/usePoolData.sv1-pagination.test.ts
@@ -0,0 +1,56 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+
+import { fetchAllSv1Clients } from './usePoolData.js';
+
+test('dashboard SV1 snapshot follows pagination through the advertised total', async () => {
+ const originalFetch = globalThis.fetch;
+ const requestedOffsets: number[] = [];
+ const firstPage = Array.from({ length: 100 }, (_, client_id) => ({ client_id }));
+
+ globalThis.fetch = (async (input: RequestInfo | URL) => {
+ const url = new URL(String(input), 'http://dashboard.test');
+ const offset = Number(url.searchParams.get('offset'));
+ requestedOffsets.push(offset);
+
+ let body: unknown;
+ if (offset === 0) {
+ // The monitoring contract caps every page at 100 even if the caller
+ // asks for 1000. A total of 101 therefore requires a second request.
+ body = {
+ offset: 0,
+ limit: 100,
+ total: 101,
+ items: firstPage,
+ };
+ } else if (offset === 100) {
+ body = {
+ offset: 100,
+ limit: 100,
+ total: 101,
+ items: [{ client_id: 100 }],
+ };
+ } else {
+ throw new Error('unexpected offset: ' + offset);
+ }
+
+ return new Response(JSON.stringify(body), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ });
+ }) as typeof globalThis.fetch;
+
+ try {
+ const snapshot = await fetchAllSv1Clients('/translator-api/v1');
+
+ assert.equal(snapshot.total, 101);
+ assert.equal(
+ snapshot.items.length,
+ snapshot.total,
+ 'all clients advertised by total must be represented in the dashboard snapshot',
+ );
+ assert.deepEqual(requestedOffsets, [0, 100]);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
Suggested Fix
diff --git a/src/pages/UnifiedDashboard.tsx b/src/pages/UnifiedDashboard.tsx
--- a/src/pages/UnifiedDashboard.tsx
+++ b/src/pages/UnifiedDashboard.tsx
@@ -18,7 +18,7 @@
import {
usePoolData,
- useSv1ClientsData,
+ useAllSv1ClientsData,
useTranslatorServerChannels,
useTranslatorHealth,
useJdcHealth,
} from '@/hooks/usePoolData';
@@ -118,7 +118,7 @@ export function UnifiedDashboard() {
const {
data: sv1Data,
isLoading: sv1Loading,
- } = useSv1ClientsData(0, 1000);
+ } = useAllSv1ClientsData();
// Health checks for the error banner (React Query deduplicates the API calls)
const { data: translatorOk, isLoading: translatorHealthLoading, isError: translatorHealthError } = useTranslatorHealth();
diff --git a/src/hooks/usePoolData.ts b/src/hooks/usePoolData.ts
--- a/src/hooks/usePoolData.ts
+++ b/src/hooks/usePoolData.ts
@@ -225,6 +225,49 @@ export function useSv1ClientsData(offset = 0, limit = 25, enabled = true) {
enabled,
});
}
+
+const SV1_CLIENTS_PAGE_LIMIT = 100;
+const SV1_CLIENTS_MAX_ITEMS = 1000;
+
+/**
+ * Fetch the bounded SV1 client snapshot used by the dashboard.
+ */
+export async function fetchAllSv1Clients(baseUrl: string): Promise<Sv1ClientsResponse> {
+ const firstPage = await fetchWithTimeout<Sv1ClientsResponse>(
+ `${baseUrl}/sv1/clients?offset=0&limit=${SV1_CLIENTS_PAGE_LIMIT}`
+ );
+ const cappedTotal = Math.min(firstPage.total, SV1_CLIENTS_MAX_ITEMS);
+ const items = firstPage.items.slice(0, cappedTotal);
+ let page = firstPage;
+ let offset = firstPage.offset + firstPage.items.length;
+
+ while (items.length < cappedTotal && page.items.length > 0) {
+ page = await fetchWithTimeout<Sv1ClientsResponse>(
+ `${baseUrl}/sv1/clients?offset=${offset}&limit=${SV1_CLIENTS_PAGE_LIMIT}`
+ );
+ items.push(...page.items.slice(0, cappedTotal - items.length));
+ offset = page.offset + page.items.length;
+ }
+
+ return {
+ ...firstPage,
+ items,
+ };
+}
+
+/**
+ * Hook to fetch the bounded SV1 client snapshot used by the dashboard.
+ */
+export function useAllSv1ClientsData(enabled = true) {
+ const endpoints = getEndpointsCached();
+
+ return useQuery({
+ queryKey: ['sv1-clients', 'all'],
+ queryFn: () => fetchAllSv1Clients(endpoints.translator.base),
+ refetchInterval: 3000,
+ enabled,
+ });
+}
/**
* Hook to fetch Translator upstream channels.
This finding was discovered by Project Loupe.
Activity
[-]Load every per-client SV2 channel page[/-][+]dashboard: every page of a paginated monitoring endpoint is read[/+]