Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancellation blocked by signal connections #101

Open
Myshtea opened this issue Oct 2, 2024 · 0 comments
Open

Cancellation blocked by signal connections #101

Myshtea opened this issue Oct 2, 2024 · 0 comments

Comments

@Myshtea
Copy link

Myshtea commented Oct 2, 2024

Environment data

Running on an ArchLinux frida-node bindings version 16.5.2
Frida server is on a Fairphone 4 rooted with magisk version 16.5.2

Tested code

The following code is based on https://github.com/frida/frida-node/blob/main/examples/cancellation.js, with added spawn gating.

const frida = require('frida');

let device;

async function main() {
  const cancellable = new frida.Cancellable();
  setTimeout(() => {
    console.log('Cancelling');
    device.spawnAdded.disconnect((...args) => console.log("spawn", ...args));
    cancellable.cancel();
  }, 2000);

  device = await frida.getDevice('92fa9259', { timeout: 10000 }, cancellable);
  device.spawnAdded.connect((...args) => onProcessAdded("spawn", ...args));
  device.enableSpawnGating()
  console.log('[*] Device:', device);
}

async function onProcessAdded(type, spawn) {
  console.log("[*] onSpawnAdded:", spawn, " of type ", type);
  await device.resume(spawn.pid);
}
  
main()
  .catch(e => {
    console.error(e);
  });

Expected behavior

Program prints device
Program prints any spawned process
Cancellation triggers
Program stops

$ npx esrun test.js
[*] Device: Device {
  id: '92fa9259',
  name: 'FP4',
  icon: {
    format: 'rgba',
    width: 16,
    height: 16,
    image: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff 40 d2 e2 9c ff ff ff ff 30 ff ff ff 40 ff ff ff 40 ff ff ff 30 d7 e5 a8 ff ff ff ff 40 00 00 ... 974 more bytes>
  },
  type: 'usb'
}
[*] onSpawnAdded: Spawn { pid: 5049, identifier: 'com.bnyro.recorder' }  of type  spawn
[*] Resuming 5049
[*] onSpawnAdded: Spawn { pid: 5120, identifier: 'gr.nikolasspyr.integritycheck' }  of type  spawn
[*] Resuming 5120
Cancelling
$

Actual behavior

Program prints device
Program prints any spawned process
Cancellation triggers
Program continues printing spawned processes without stopping

$ npx esrun test.js
[*] Device: Device {
  id: '92fa9259',
  name: 'FP4',
  icon: {
    format: 'rgba',
    width: 16,
    height: 16,
    image: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ff ff 40 d2 e2 9c ff ff ff ff 30 ff ff ff 40 ff ff ff 40 ff ff ff 30 d7 e5 a8 ff ff ff ff 40 00 00 ... 974 more bytes>
  },
  type: 'usb'
}
[*] onSpawnAdded: Spawn { pid: 5282, identifier: 'gr.nikolasspyr.integritycheck' }  of type  spawn
[*] onSpawnAdded: Spawn { pid: 5311, identifier: 'org.fdroid.fdroid' }  of type  spawn
Cancelling
[*] onSpawnAdded: Spawn { pid: 5395, identifier: 'org.fdroid.fdroid' }  of type  spawn
...

Cancellation does work without "device.spawnAdded.connect"
Cancellation does not work even if "device.enableSpawnGating()" is not called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant