'Cannot open BPF device' error on c.open()
See original GitHub issueI’m working on an Electron App that broadcasts UDP to find specific devices connected to the network and it is throwing an error on this line:
var linkType = c.open(device, filter, bufSize, buffer);
This is the error on the console: Uncaught Error: (cannot open BPF device) /dev/bpf0: Permission denied
It works fine on my local environment, but when running the App on another Mac it’s failing as described. Do I have to grant permissions to the App in order to be able to open the Cap object ©? I’ve tried using the sudo-prompt module but it is not working.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to fix BPF device permissions on Mac OS to use tcpdump
came on this problem today. found me in group chmodbf by command line example above, but could not run tcpdump. Same error.
Read more >Error creating sniffer on OS X - permission denied
I am trying to run packetbeat on mac with packetbeat.yml configured to have mac settings and http port changes from default:
Read more >tcpdump command fails with "bpf_load: genminor failed" error
The error usually indicates tcpdump cannot find any bpf (Berkeley Packet Filter) devices to run against or mismatch of the device major ...
Read more >bpf-helpers(7) - Linux manual page - man7.org
This helper is intended to be used in combination with bpf_csum_diff(), in particular when the checksum needs to be updated after data has...
Read more >Linux Socket Filtering aka Berkeley Packet Filter (BPF)
4 manpage is very helpful in creating filters. On Linux, BPF is much simpler than on BSD. One does not have to worry...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
sudo chmod o+r /dev/bpf*
should help in reading of Berkley Packet Filter.Yes, the best solution is to start as root, start listening for packets, and then drop the privileges of the process using
process.setgid()
andprocess.setuid()
to something more appropriate, such as the current user and group (or perhaps nobody/nobody). Perform these steps before doing anything else (includingrequire()
ing other non-node core modules). This way you can ensure that nothing else in the node process (e.g. third party modules) gets superuser privileges, which is good for security.This is also a better solution than what you may find elsewhere online which may suggest to use
setcap
on the node executable which is a huge security issue because the same node executable is used to execute any and all scripts, not just the one usingcap
(andsetcap
can’t be used on a shell script or limited to a specific node script).