Installing WiringPi from the official Raspbian repositories (on Stretch or later, I believe) will create an executable file at /usr/bin/gpio
.
- By default, the owner of the file is root, i.e.
0
, and the group is root, i.e.0
. - By default, the permissions on the file is 4755. The interesting part of this is the
4
, which is the setuid bit. It enables executables to be run with the same privileges as the file's owner, in this case0
, or root.
I fixed the problem simply by removing the setuid bit with chmod 0755 $(which gpio)
. GPIO can now only be controlled by the root user, even if a user is a member of the gpio
group. Considering that there are other groups like i2c
and spi
, I'm not sure if this completely mitigates security problems.
I wish the gpio
group could enable/disable GPIO control for users.