diff --git a/apps/desktop/electron/connection-config.test.ts b/apps/desktop/electron/connection-config.test.ts index e5ba2812725ea..a306bec5ca1a9 100644 --- a/apps/desktop/electron/connection-config.test.ts +++ b/apps/desktop/electron/connection-config.test.ts @@ -166,6 +166,15 @@ test('normalizeSshConfig rejects unsafe remote profile mappings', () => { mode: 'ssh', host: 'box' }) + assert.deepEqual(normalizeSshConfig({ mode: 'ssh', host: 'box', remoteProfile: 'root' }), { + mode: 'ssh', + host: 'box' + }) + assert.deepEqual(normalizeSshConfig({ mode: 'ssh', host: 'box', remoteProfile: 'default' }), { + mode: 'ssh', + host: 'box', + remoteProfile: 'default' + }) }) test('normalizeSshConfig handles IPv6 and strict port bounds', () => { diff --git a/apps/desktop/electron/connection-config.ts b/apps/desktop/electron/connection-config.ts index 7cbf9c911a636..4644008d48767 100644 --- a/apps/desktop/electron/connection-config.ts +++ b/apps/desktop/electron/connection-config.ts @@ -45,6 +45,9 @@ const RT_COOKIE_VARIANTS = ['__Host-hermes_session_rt', '__Secure-hermes_session // cookies above. `privy-token` is the access token (the required signal); // variants cover the secured-prefix forms and the older `privy-session` name. const PRIVY_SESSION_COOKIE_VARIANTS = ['__Host-privy-token', '__Secure-privy-token', 'privy-token', 'privy-session'] +// Keep this aligned with hermes_cli.profiles.validate_profile_name(). `default` +// is the built-in root alias; these names cannot be created as profiles. +const RESERVED_REMOTE_PROFILES = new Set(['hermes', 'test', 'tmp', 'root', 'sudo']) function normalizeRemoteBaseUrl(rawUrl) { let value = String(rawUrl || '').trim() @@ -287,7 +290,7 @@ function normalizeSshConfig(entry) { // historical same-name behavior in the caller. const remoteProfile = String(entry.remoteProfile || '').trim() - if (/^[a-z0-9][a-z0-9_-]{0,63}$/.test(remoteProfile)) { + if (/^[a-z0-9][a-z0-9_-]{0,63}$/.test(remoteProfile) && !RESERVED_REMOTE_PROFILES.has(remoteProfile)) { out.remoteProfile = remoteProfile }