Remove cap_net_bind_service from the caddy binary - #466
Open
i5okie wants to merge 1 commit into
Open
Conversation
The `+ep` file capability makes execve fail with EPERM when the capability bounding set is empty, so the image cannot start at all under `--cap-drop ALL` — as root or as any other user. Most runtimes now set net.ipv4.ip_unprivileged_port_start=0, which makes the capability redundant. Where they don't, `--cap-add NET_BIND_SERVICE` or a port above 1024 covers it. Closes caddyserver#461
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code was used for the diagnosis, testing, and this description; I have verified the change.
Removes
setcap cap_net_bind_service=+epfrom the caddy binary, as proposed in #461.The
+epfile capability does more than grant a capability — it makesexecvefail withEPERMwhen the capability bounding set is empty. So the image doesn't start at all under--cap-drop ALL, and it fails as root too. This isn't a rootless-only issue.Tested on OpenShift 4 (CRI-O), stock
restricted-v2SCC:Running
caddy:2.11.4-alpinethere:restricted-v2setsrequiredDropCapabilities: [ALL]and won't allow adding capabilities back, so there's no way to work around this downstream. Copying the binary to/tmp(which strips file caps) and running the copy starts and serves normally — which is what this change does properly.Verified against the built image:
--cap-drop ALL, root--cap-drop ALL, non-root:80, default sysctlOne breaking case, as #461 notes: running as non-root and binding below 1024 on a host where
net.ipv4.ip_unprivileged_port_startis above 0. Docker 20.10+ and containerd 2.0+ set it to 0, so most users are unaffected; anyone else can use--cap-add NET_BIND_SERVICEor listen above 1024. Root is unaffected either way.Worth flagging that last sysctl line above: CRI-O still reports 1024, so the privileged-port problem isn't universally solved by runtimes yet. Separate concern from this change though — a Caddyfile on 8080 handles it.
libcapis now unused in the alpine image and could come out too. I've left it in to keep this minimal, happy to add it if you'd prefer.This supersedes #428, which is now closed — this turned out to be the real blocker there, not the rootless packaging.
Closes #461