mscdex / cap

A cross-platform binding for performing packet capturing with node.js
MIT License
360 stars 46 forks source link

`Cap.deviceList()` Permissions error #107

Closed mattfysh closed 2 years ago

mattfysh commented 2 years ago

Hello - I am trying to run this in a Lambda Container Image (followed the instructions here: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-from-base)

When I run locally, there are no issues. However upon pushing to Lambda and calling deviceList() I get the following error:

Can't open raw Bluetooth socket: Operation not permitted

And I also get a similar message when attempting to call open()

I know this is not caused by your library, just wondering if you had any ideas of how I can debug this? e.g can I put libpcap in verbose mode to see which exact operation it is trying to run? thanks!

mscdex commented 2 years ago

The libpcap APIs used in cap require CAP_NET_ADMIN and similar OS capabilities, which I doubt Amazon gives to Lambda users.

If you're able to find examples of libpcap working on Lambda, I would be interested in seeing how those are accomplished. But until then, you're probably out of luck.

mattfysh commented 2 years ago

Thanks @mscdex I'll keep digging. I've just discovered Lambda uses Firecracker microVMs so I'll play around with that locally to reproduce & hopefully fix the issue. Will let you know if I find anything

The other option for me is to capture packets on a NAT instance, but I've no clue how to correlate packets with their originating Lambda invocation / request ID. If you have any thoughts on this also would appreciate it, thanks again :)