Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Bound configuration imports before reading and dispatching

pulse-triage[bot]a57085af7250
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index b26fb8853c..cbbe333bb2 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -5084,6 +5084,30 @@ resolves late` in
## Current State
+### Configuration import is bounded before dispatch
+
+The existing Settings recovery import reads at most a 2 MiB selected file,
+allowing space for the export envelope and formatting. A larger file is rejected
+before `File.text()`, credential prompting or any import request. After parsing
+the supported JSON envelope, JSON string or raw CLI data, the complete serialized
+request (ciphertext, password, JSON escaping and UTF-8 bytes) must not exceed
+1 MiB, matching `configapi.handleImportConfig`'s request reader. File size alone
+cannot establish that the request fits.
+
+Local size failures remain in the active import dialog, say no import was sent,
+preserve the inputs and allow an explicit corrected submission. They neither
+reload nor claim an uncertain applied import. Requests actually dispatched retain
+the existing non-retrying, workspace-bound and uncertain-outcome behaviour. The
+file control associates visible size guidance through `aria-describedby`.
+
+`useBackupTransferFlow.test.ts` covers unread oversized files, the local file
+boundary, exact/under/over request bytes, multibyte/escaped passwords and explicit
+correction. `BackupTransferDialogs.test.tsx` checks the consuming accessible
+guidance. Desktop/narrow browser proof exercises the production transfer flow and
+recovery dialog with safe local responses; it does not establish native recovery
+or change any server limit, credential permission, archive or guest operation.
+
+
### Retained monitoring status remains reactive (11 October 2026)
The existing Machines status dot subscribes to the shared relative-time clock
diff --git a/frontend-modern/src/components/Settings/BackupTransferDialogs.tsx b/frontend-modern/src/components/Settings/BackupTransferDialogs.tsx
index c162d7c2d0..9c2e68203f 100644
--- a/frontend-modern/src/components/Settings/BackupTransferDialogs.tsx
+++ b/frontend-modern/src/components/Settings/BackupTransferDialogs.tsx
@@ -317,12 +317,17 @@ export const BackupTransferDialogs: Component<BackupTransferDialogsProps> = (pro
disabled={props.isTransferring()}
type="file"
accept=".json"
+ aria-describedby="backup-import-file-help"
onChange={(event) => {
const file = event.currentTarget.files?.[0] ?? null;
props.setImportFile(file);
}}
class={controlClass('cursor-pointer')}
/>
+ <p id="backup-import-file-help" class={`${formHelpText} mt-1`}>
+ Files up to 2 MiB are read locally. Import requests, including the password, must
+ fit the server’s 1 MiB limit.
+ </p>
</div>
<div class={formField}>
diff --git a/frontend-modern/src/components/Settings/__tests__/BackupTransferDialogs.test.tsx b/frontend-modern/src/components/Settings/__tests__/BackupTransferDialogs.test.tsx
index 3b543efbb5..bea4655fa2 100644
--- a/frontend-modern/src/components/Settings/__tests__/BackupTransferDialogs.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/BackupTransferDialogs.test.tsx
@@ -81,6 +81,9 @@ describe('BackupTransferDialogs', () => {
expect(guide).toHaveAttribute('href', '/docs/MIGRATION');
expect(guide).toHaveAttribute('target', '_blank');
expect(guide).toHaveAttribute('rel', 'noopener noreferrer');
+ expect(screen.getByLabelText('Configuration File')).toHaveAccessibleDescription(
+ 'Files up to 2 MiB are read locally. Import requests, including the password, must fit the server’s 1 MiB limit.',
+ );
});
it.each(['export', 'import'] as const)(
diff --git a/frontend-modern/src/components/Settings/__tests__/useBackupTransferFlow.test.ts b/frontend-modern/src/components/Settings/__tests__/useBackupTransferFlow.test.ts
index b9636eb94c..56bb62d8e5 100644
--- a/frontend-modern/src/components/Settings/__tests__/useBackupTransferFlow.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useBackupTransferFlow.test.ts
@@ -3,7 +3,11 @@ import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } fr
import { apiClient, clearApiToken, getApiToken, getOrgID, setOrgID } from '@/utils/apiClient';
import { notificationStore } from '@/stores/notifications';
import type { SecurityStatus } from '@/types/config';
-import { useBackupTransferFlow } from '../useBackupTransferFlow';
+import {
+ MAX_CONFIG_IMPORT_FILE_BYTES,
+ MAX_CONFIG_IMPORT_REQUEST_BYTES,
+ useBackupTransferFlow,
+} from '../useBackupTransferFlow';
vi.mock('@/stores/notifications', () => ({
notificationStore: { error: vi.fn(), success: vi.fn(), info: vi.fn() },
@@ -43,7 +47,7 @@ function setup(kind: 'export' | 'import' = 'import', tokenOnly = false) {
flow.setImportPassphrase(passphrase);
flow.setExportPassphrase(passphrase);
const read = vi.fn().mockResolvedValue('{"data":"synthetic-archive"}');
- flow.setImportFile({ text: read } as unknown as File);
+ flow.setImportFile({ size: 28, text: read } as unknown as File);
return { flow, read, dispose };
}
@@ -86,6 +90,90 @@ afterEach(() => {
});
describe('configuration transfers keep their confirmed workspace and one dispatch', () => {
+ it('rejects an oversized file before reading it or asking for a token', async () => {
+ const { flow, read } = setup('import', true);
+ flow.setImportFile({ size: MAX_CONFIG_IMPORT_FILE_BYTES + 1, text: read } as unknown as File);
+ await flow.handleImport();
+ expect(read).not.toHaveBeenCalled();
+ expect(fetchMock).not.toHaveBeenCalled();
+ expect(flow.showApiTokenModal()).toBe(false);
+ expect(flow.isTransferring()).toBe(false);
+ expect(flow.transferError()).toContain('2 MiB browser import limit. No import was sent.');
+ expect(flow.transferError()).not.toContain('may have applied');
+ expect(flow.importFile()).not.toBeNull();
+ expect(flow.importPassphrase()).toBe(passphrase);
+ expect(reloadTimers()).toHaveLength(0);
+ expect(notificationStore.success).not.toHaveBeenCalled();
+ });
+
+ it('accepts file formatting at the local read limit when the actual request fits', async () => {
+ const { flow, read } = setup();
+ const envelope = '{"data":"synthetic-archive"}';
+ read.mockResolvedValue(envelope.padEnd(MAX_CONFIG_IMPORT_FILE_BYTES));
+ flow.setImportFile({ size: MAX_CONFIG_IMPORT_FILE_BYTES, text: read } as unknown as File);
+ await flow.handleImport();
+ expect(read).toHaveBeenCalledTimes(1);
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toEqual({
+ passphrase,
+ data: 'synthetic-archive',
+ });
+ expect(flow.transferError()).toBe('');
+ });
+
+ it.each([-1, 0, 1])('checks the complete request at the byte boundary (%i)', async (delta) => {
+ const { flow, read } = setup();
+ const overhead = new Blob([JSON.stringify({ passphrase, data: '' })]).size;
+ const data = 'A'.repeat(MAX_CONFIG_IMPORT_REQUEST_BYTES - overhead + delta);
+ read.mockResolvedValue(JSON.stringify({ data }));
+ await flow.handleImport();
+ expect(read).toHaveBeenCalledTimes(1);
+ expect(fetchMock).toHaveBeenCalledTimes(delta > 0 ? 0 : 1);
+ if (delta > 0) {
+ expect(flow.transferError()).toContain('server’s 1 MiB request limit');
+ expect(flow.transferError()).toContain('No import was sent');
+ expect(flow.transferError()).not.toContain('may have applied');
+ expect(flow.showImportDialog()).toBe(true);
+ expect(reloadTimers()).toHaveLength(0);
+ expect(notificationStore.success).not.toHaveBeenCalled();
+ } else {
+ expect(new Blob([fetchMock.mock.calls[0][1].body]).size).toBe(
+ MAX_CONFIG_IMPORT_REQUEST_BYTES + delta,
+ );
+ expect(flow.transferError()).toBe('');
+ }
+ expect(flow.isTransferring()).toBe(false);
+ });
+
+ it.each(['🔒'.repeat(8), '"\\\n'.repeat(8)])(
+ 'includes UTF-8 and JSON escaping in the password budget',
+ async (password) => {
+ const { flow, read } = setup();
+ // The ASCII request would fit exactly, but this password costs more bytes.
+ const overhead = new Blob([JSON.stringify({ passphrase, data: '' })]).size;
+ const data = 'A'.repeat(MAX_CONFIG_IMPORT_REQUEST_BYTES - overhead);
+ read.mockResolvedValue(JSON.stringify({ data }));
+ flow.setImportPassphrase(password);
+ await flow.handleImport();
+ expect(fetchMock).not.toHaveBeenCalled();
+ expect(flow.transferError()).toContain('including the password. No import was sent.');
+ expect(flow.importPassphrase()).toBe(password);
+ expect(flow.isTransferring()).toBe(false);
+ },
+ );
+
+ it('allows a deliberate corrected submission after a local size rejection', async () => {
+ const { flow, read } = setup();
+ read.mockResolvedValue(JSON.stringify({ data: 'A'.repeat(MAX_CONFIG_IMPORT_REQUEST_BYTES) }));
+ await flow.handleImport();
+ expect(fetchMock).not.toHaveBeenCalled();
+ read.mockResolvedValue('{"data":"synthetic-archive"}');
+ await flow.handleImport();
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(flow.transferError()).toBe('');
+ expect(flow.showImportDialog()).toBe(false);
+ });
+
it.each(['export', 'import'] as const)(
'does not send %s after the workspace changes before confirmation',
async (kind) => {
diff --git a/frontend-modern/src/components/Settings/useBackupTransferFlow.ts b/frontend-modern/src/components/Settings/useBackupTransferFlow.ts
index 5ca53a0d03..c734f35e13 100644
--- a/frontend-modern/src/components/Settings/useBackupTransferFlow.ts
+++ b/frontend-modern/src/components/Settings/useBackupTransferFlow.ts
@@ -15,6 +15,12 @@ interface UseBackupTransferFlowParams {
const CHANGED_WORKSPACE =
'Organisation changed. Close this dialog and reopen it in the intended workspace.';
+// Allow room for the exported JSON envelope/formatting without reading an
+// unbounded local file. The wire limit matches handleImportConfig's reader;
+// include JSON escaping and UTF-8 password bytes, not just ciphertext length.
+export const MAX_CONFIG_IMPORT_FILE_BYTES = 2 * 1024 * 1024;
+export const MAX_CONFIG_IMPORT_REQUEST_BYTES = 1024 * 1024;
+
export function useBackupTransferFlow({ securityStatus }: UseBackupTransferFlowParams) {
const [exportPassphrase, setExportPassphrase] = createSignal('');
const [useCustomPassphrase, setUseCustomPassphrase] = createSignal(false);
@@ -170,6 +176,12 @@ export function useBackupTransferFlow({ securityStatus }: UseBackupTransferFlowP
fail('Please select a file to import');
return;
}
+ if (file.size > MAX_CONFIG_IMPORT_FILE_BYTES) {
+ fail(
+ 'Configuration file exceeds the 2 MiB browser import limit. No import was sent. See the migration guide for recovery options.',
+ );
+ return;
+ }
if (needsApiToken()) return;
// Freeze the confirmed target and inputs before the asynchronous file read.
@@ -200,10 +212,18 @@ export function useBackupTransferFlow({ securityStatus }: UseBackupTransferFlowP
return;
}
+ const body = JSON.stringify({ passphrase, data: encryptedData });
+ if (new Blob([body]).size > MAX_CONFIG_IMPORT_REQUEST_BYTES) {
+ fail(
+ 'Import exceeds the server’s 1 MiB request limit, including the password. No import was sent. See the migration guide for recovery options.',
+ );
+ return;
+ }
+
submitted = true;
await apiFetchJSON('/api/config/import', {
method: 'POST',
- body: JSON.stringify({ passphrase, data: encryptedData }),
+ body,
expectedOrgID: orgID,
retry: false,
signal,