@@ -260,10 +260,21 @@ export function isForegroundRestrictedPluginNodeCommand(command: string): boolea
260260}
261261
262262type NodeCommandPolicyNode = Pick < NodeSession , "platform" | "deviceFamily" > &
263- Partial < Pick < NodeSession , "caps" | "commands" | "connId" | "nodeId" > > & {
263+ Partial < Pick < NodeSession , "caps" | "commands" | "connId" | "nodeId" | "clientId" | "clientMode" > > & {
264264 approvedCommands ?: readonly string [ ] ;
265265 } ;
266266
267+ function isAppNode ( node ?: NodeCommandPolicyNode ) : boolean {
268+ if ( ! node ) {
269+ return false ;
270+ }
271+ return (
272+ node . clientMode === "app" ||
273+ node . clientId === "openclaw-macos" ||
274+ node . clientId === "openclaw-windows"
275+ ) ;
276+ }
277+
267278function isDesktopPlatformId ( platformId : PlatformId ) : boolean {
268279 return platformId === "macos" || platformId === "windows" || platformId === "linux" ;
269280}
@@ -337,6 +348,13 @@ function resolveNodeCommandAllowlistInternal(
337348 . map ( ( cmd ) => cmd . trim ( ) )
338349 . filter ( ( cmd ) => cmd && ! dangerousPluginCommands . has ( cmd ) ) ,
339350 ) ;
351+
352+ if ( isAppNode ( node ) ) {
353+ for ( const cmd of NODE_SYSTEM_RUN_COMMANDS ) {
354+ allow . delete ( cmd ) ;
355+ }
356+ }
357+
340358 for ( const cmd of extra ) {
341359 const trimmed = cmd . trim ( ) ;
342360 if ( trimmed ) {
@@ -363,8 +381,13 @@ export function resolveNodePairingCommandAllowlist(
363381 cfg : OpenClawConfig ,
364382 node ?: NodeCommandPolicyNode ,
365383) : Set < string > {
384+ // App nodes must never get system.run even in the pairing allowlist, because
385+ // the declared commands from this allowlist are stored in the pairing record
386+ // and later treated as approved on reconnect. Passing includeDesktopHostCommands
387+ // to resolveNodeCommandAllowlistInternal is still correct for non-app desktop
388+ // nodes that legitimately need system.run at pairing time.
366389 return resolveNodeCommandAllowlistInternal ( cfg , node , {
367- includeDesktopHostCommands : true ,
390+ includeDesktopHostCommands : ! isAppNode ( node ) ,
368391 } ) ;
369392}
370393
0 commit comments