fix: egress filtering when running as non-root user#118
Open
sao90 wants to merge 1 commit intoopen-webui:mainfrom
Open
fix: egress filtering when running as non-root user#118sao90 wants to merge 1 commit intoopen-webui:mainfrom
sao90 wants to merge 1 commit intoopen-webui:mainfrom
Conversation
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.
Summary
Egress filtering (
OPEN_TERMINAL_ALLOWED_DOMAINS) is broken in the current default image. Two bugs exist:userAddressing issue: #119
Bug 1 — Container crash on capability drop
When egress filtering is enabled, the entrypoint configures iptables rules and then attempts to permanently drop
CAP_NET_ADMINusingcapsh. However,capshis executed as the unprivilegeduser, which lacks theCAP_SETPCAPpermission required to modify the bounding set. Combined withset -e, this crashes the container immediately:Fix: Execute
capshviasudo(which theuseraccount has passwordless access to), and use--user=userto securely drop back to the unprivileged user before starting the application.Bug 2 — dnsmasq blocked from reaching upstream DNS
The iptables rules block ALL outbound port 53 traffic. This includes dnsmasq's own queries to the upstream DNS server, which it needs to resolve whitelisted domains. As a result, the
allowedipset is never populated, and all outbound connections fail — even to whitelisted domains.Fix: Explicitly allow dnsmasq to reach the captured upstream DNS server before applying the blanket port 53 block.
Test Results
Configuration:
--cap-add NET_ADMIN,OPEN_TERMINAL_ALLOWED_DOMAINS=pypi.orgv0.11.34(default, asuser)v0.11.34(forced to run asroot*)user(UID 1000)cap_net_adminpermanently droppedpypi.orgresolves via dnsmasqgoogle.comblockedpypi.orgaccessible (200)google.comblocked--user 0:0to bypass Bug 1. This is not a viable workaround because it means the AI sandbox process runs with full root privileges, defeating the container's security model.Notes
entrypoint.shis modified.