containers / containers/bubblewrap

Can't listen on privileged ports with `--dev /dev`

Open
#516 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
8.7k
Forks
386
Avg merge
3d 17h
Merged PRs (30d)
11

Description

When I run bwrap with `--dev /dev`, I can't listen on a privileged port like 80. Here's an example, with an strace to show that the `bind` system call is failing:

```
$ strace -f -e bind bwrap --dev /dev --ro-bind / / --unshare-net --cap-add cap_net_bind_service nc -l -p 80
[pid 378942] bind(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EACCES (Permission denied)
Error: Couldn't setup listening socket (err=-3)
```

Without `--dev /dev`, it works fine:

```
$ strace -f -e bind bwrap --ro-bind / / --unshare-net --cap-add cap_net_bind_service nc -l -p 80
[pid 378903] bind(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
```

In both cases the capabilities seem to be set up correctly, so I'm very puzzled as to how `--dev /dev` could possibly affect this.

This is with bubblewrap 0.6.1 and I'm running Linux 5.15.28. I also reproduced this issue on a machine running Linux 5.12.2.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.