@@ -519,6 +519,34 @@ function observeProcesses(processes: ProcessFixture[]) {
519519 ) ;
520520}
521521
522+ test ( 'a managed binary symlink cannot confer ownership on an executable outside its install' , async ( ) => {
523+ const stateDir = mkdtempForTestSync ( 'agent-device-web-install-boundary-' ) ;
524+ try {
525+ installFakeManagedAgentBrowser ( stateDir ) ;
526+ const status = getManagedAgentBrowserStatus ( {
527+ stateDir,
528+ host : { env : process . env , cwd : process . cwd ( ) } ,
529+ } ) ;
530+ const binary = nativeBinary ( status . installDir ) ;
531+ const linkedBinary = nativeBinary ( managedInstallPaths ( stateDir , '0.27.1' ) . installDir ) ;
532+ const linkedBin = path . dirname ( linkedBinary ) ;
533+ const outsideBin = path . join ( stateDir , 'unrelated-bin' ) ;
534+ fs . renameSync ( linkedBin , outsideBin ) ;
535+ fs . symlinkSync ( outsideBin , linkedBin , process . platform === 'win32' ? 'junction' : 'dir' ) ;
536+ const unrelated = fs . realpathSync . native ( path . join ( outsideBin , path . basename ( linkedBinary ) ) ) ;
537+ observeProcesses ( [
538+ { pid : 101 , command : `${ binary } daemon` , executable : binary } ,
539+ { pid : 102 , command : unrelated , executable : unrelated } ,
540+ ] ) ;
541+ const store = { replace : vi . fn ( ) , clear : vi . fn ( ) , read : vi . fn ( ( ) => [ ] ) } ;
542+
543+ expect ( ( await recordManagedAgentBrowserProcesses ( status , store ) ) . pids ) . toEqual ( [ 101 ] ) ;
544+ expect ( store . replace . mock . calls [ 0 ] ?. [ 1 ] . map ( ( { pid } : { pid : number } ) => pid ) ) . toEqual ( [ 101 ] ) ;
545+ } finally {
546+ fs . rmSync ( stateDir , { recursive : true , force : true } ) ;
547+ }
548+ } ) ;
549+
522550test ( 'records verified current and retained native roots and stable descendants' , async ( ) => {
523551 const stateDir = mkdtempForTestSync ( 'agent-device web life-' ) ;
524552 try {
0 commit comments