AccessoryAccess for a Developer ID virtualization app: can it replace a root daemon for USB storage devices?

I build AVM, the Accessible Virtual Machine, a free, open source Mac app that runs Windows 11 for ARM in QEMU. It's built for blind people who use VoiceOver on the Mac and a screen reader in Windows. It's on GitHub at https://github.com/allisonfm85/accessible-virtual-machine. AVM ships with Developer ID, it's notarized, and it isn't sandboxed. QEMU runs as a child process, signed by the same team, and does the USB work itself through usbredir and libusb.

I asked DTS about this (case 23107052), and Quinn pointed me to thread 851767.

Today AVM captures USB devices from a root daemon registered with SMAppService. That works for braille displays and microphones. It fails for USB flash drives. Opening interface 0 returns 0xe00002c9. I measured why with a small IOUSBHost tool:

  • Run with sudo from a terminal that has Removable Volumes: works.
  • Same command with Removable Volumes turned off: fails with 0xe00002c9.
  • Run as a launchd daemon in the system domain: fails. Full Disk Access makes no difference.

So the block is the Removable Volumes permission, and a daemon has no responsible app to carry it. Granting it to AVM doesn't help the daemon.

Thread 851767 shows a flash drive working through AccessoryAccess and IOUSBHostDevice, with interfaces opened through IOUSBLib. That looks like the path I should be on. My questions:

  1. Is the Claim USB Accessory capability (com.apple.developer.accessory-access.usb) available to Developer ID apps outside the Mac App Store? Does it require the App Sandbox?

  2. Does the user's AccessoryAccess consent cover a USB storage device's interfaces? In other words, would it get past the Removable Volumes check that stops my daemon?

  3. Can AVM pass createXPCRepresentation to QEMU, a non-sandboxed child process from the same team, and have QEMU open the accessory there?

  4. libusb opens interfaces through IOUSBLib. Given FB25324561, is it reasonable to ship on that path for now?

If AccessoryAccess isn't available to Developer ID apps, I'd still welcome guidance on a supported way, such as com.apple.vm.device-access. I'm happy to share my sample project or logs.

Thank you,
Allison Meloy

Answered by DTS Engineer in 916778022
Written by allisonfm85 in 857720021

1- Is the Claim USB Accessory capability (com.apple.developer.accessory-access.usb) available to Developer ID apps outside the Mac App Store?

Yes.

But you don’t have to take my word for it (-: See Finding a Capability’s Distribution Restrictions.

Written by allisonfm85 in 857720021

Does it require the App Sandbox?

No. It works for both sandboxed and non-sandboxed apps.

Written by allisonfm85 in 857720021

2- Does the user's AccessoryAccess consent cover a USB storage device's interfaces?

It’s intended to work with all USB accessories [1].

However, see below.

Written by allisonfm85 in 857720021

3- Can AVM pass createXPCRepresentation to QEMU, a non-sandboxed child process from the same team, and have QEMU open the accessory there?

Yes. The XPC representation is actually an XPC data object, and it’s sufficient to transport just the bytes of that data object. That came as as surprise to me, so I actually confirmed it as part of this thread.

Written by allisonfm85 in 857720021

4- libusb opens interfaces through IOUSBLib. Given FB25324561, is it reasonable to ship on that path for now?

Yes.

Obviously the world would be a better place if you could move off deprecated APIs, but sometimes needs must.

I do recommend that you file a bug asking it to be dup’d to FB25324561. That way you’ll be notified if and when we fix that issue, and you can then adjust your plans accordingly.

Finally, a general warning. Accessory Access is brand new and we’re all still coming up to speed on it. Clearly it’s not perfect, and thus it’s not inconceivable that you might bump into some other limitation. I hope that’s not the case, but if you’d asked me about the IOUSBHost / IOUSBLib difference I few months back I would’ve confidently predicted that they’d work the same. So, my advice:

  • Prototype before committing to this approach.
  • Share your experiences here, both good and bad.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Hmmmm, that’s not quite true. Last I checked it won’t let you permanently steal HID pointing devices, because that’s something that could bork the user’s system.

Written by allisonfm85 in 857720021

1- Is the Claim USB Accessory capability (com.apple.developer.accessory-access.usb) available to Developer ID apps outside the Mac App Store?

Yes.

But you don’t have to take my word for it (-: See Finding a Capability’s Distribution Restrictions.

Written by allisonfm85 in 857720021

Does it require the App Sandbox?

No. It works for both sandboxed and non-sandboxed apps.

Written by allisonfm85 in 857720021

2- Does the user's AccessoryAccess consent cover a USB storage device's interfaces?

It’s intended to work with all USB accessories [1].

However, see below.

Written by allisonfm85 in 857720021

3- Can AVM pass createXPCRepresentation to QEMU, a non-sandboxed child process from the same team, and have QEMU open the accessory there?

Yes. The XPC representation is actually an XPC data object, and it’s sufficient to transport just the bytes of that data object. That came as as surprise to me, so I actually confirmed it as part of this thread.

Written by allisonfm85 in 857720021

4- libusb opens interfaces through IOUSBLib. Given FB25324561, is it reasonable to ship on that path for now?

Yes.

Obviously the world would be a better place if you could move off deprecated APIs, but sometimes needs must.

I do recommend that you file a bug asking it to be dup’d to FB25324561. That way you’ll be notified if and when we fix that issue, and you can then adjust your plans accordingly.

Finally, a general warning. Accessory Access is brand new and we’re all still coming up to speed on it. Clearly it’s not perfect, and thus it’s not inconceivable that you might bump into some other limitation. I hope that’s not the case, but if you’d asked me about the IOUSBHost / IOUSBLib difference I few months back I would’ve confidently predicted that they’d work the same. So, my advice:

  • Prototype before committing to this approach.
  • Share your experiences here, both good and bad.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Hmmmm, that’s not quite true. Last I checked it won’t let you permanently steal HID pointing devices, because that’s something that could bork the user’s system.