bwrap: Failed RTM_NEWADDR: Operation not permitted
Resolved 💬 43 comments Opened Mar 17, 2026 by udayshnk Closed Mar 27, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
Description
After updating Codex CLI to 0.115.0, the Linux bubblewrap sandbox fails with:
bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted
This worked fine before the update. Subagents cannot execute any commands in sandbox mode.
Environment
- OS: Ubuntu 24.04.4 LTS (Noble Numbat)
- Kernel: 6.17.0-19-generic
- Codex version: 0.115.0
- bwrap version: 0.9.0
- bwrap binary:
/usr/bin/bwrap(not setuid)
Thread
Uploaded thread: 019cfb76-f176-71d2-b80e-b03ab6bc6a38
43 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
After reviewing the flagged duplicates, this is not a duplicate:
writable_rootsand detached child process regressions on WSLThis issue is specifically about
bwrap: loopback: Failed RTM_NEWADDR: Operation not permittedon bare Ubuntu 24.04 (no Docker, no WSL, no devcontainer) due to AppArmor restricting unprivileged user namespaces (kernel.apparmor_restrict_unprivileged_userns=1), which is enabled by default on Ubuntu 24.04. The regression started with the 0.115.0 update.same problem on Ubuntu 24.04.3, codex-cli 0.115.0
worked just fine before update
+1
rollback to 0.114.0 can temporarily fix it
can you try setting
Ubuntu 24+ ships with a restrictive AppArmor policy that restricts bubblewrap from working correctly.
Exact same error here, downgrading to
0.114.0solves the problem@viyatb-oai Yes, that fixes it on Ubuntu 25.10. The second line alone (
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0) is enough.Removing a system wide mitigation against kernel privilege escalation exploits does not sound like a fix to me...
Possibly better approach is to create an AppArmor profile to allow
usernsfor codex, though how was it working before?+1. It's related to #13996
Workaround (to still use old sandbox):
Some details:
Started to happen after upgrading to
codex-cli 0.115.0.Exceptions like
bwrap: setting up uid map: Permission deniedand similar.Environment:
25.046.14.0-37-genericuidmapinstalledkernel.unprivileged_userns_clone = 1kernel.apparmor_restrict_unprivileged_userns = 1kernel.apparmor_restrict_unprivileged_unconfined = 1Observed behavior:
0.115.0, normal sandboxed Codex commands fail on this hostbwrap: loopback: Failed RTM_NEWADDR: Operation not permittedcodex --enable use_legacy_landlock sandbox linux /bin/trueworksbwrapworks:/usr/bin/bwrap --ro-bind / / --dev-bind /dev /dev --proc /proc --unshare-user --uid 0 --gid 0 truebwrapbinary fails with the same kind of permission errorThis looks like an Ubuntu AppArmor interaction with the
0.115.0switch to vendored/defaultbubblewrap.Ubuntu ships
/etc/apparmor.d/bwrap-userns-restrict, which grantsusernsaccess specifically to/usr/bin/bwrap. Since Codex now uses a vendored/internalbwrappath, that path is not covered by the Ubuntu AppArmor exception, so the sandbox cannot complete namespace setup on this host.So this seems to be:
uidmapbwrappath on AppArmor-restricted Ubuntu systemsA good fix would be one of:
/usr/bin/bwrapon Linux/AppArmor systemsbwrappathI have an additional data point that seems to narrow the root cause further.
I reproduced the same failure class in an Incus-based jail setup, but the important part is that this does not appear to be Incus-specific. The common factor is whether the actual unprivileged user that Codex runs as is allowed to create the namespaces bubblewrap needs.
What I observed:
rootinside the container can create a user namespaceagentuser cannotagentMinimal probes that separated the issue for me:
In my case these fail for the unprivileged user while the equivalent test as root succeeds.
I also confirmed that the effective blocker was AppArmor’s restriction on unprivileged user namespaces. In the jail setup, setting:
on the host made the agent-level bwrap test succeed again.
Requests / possible improvements:
I encounter the same issue on my Ubuntu24.04. Works totally fine before that
I'm also experiencing this, I'm currently downgrading to 0.114 as a workaround.
Codex 0.116.0 seems to fix this, provided that you
apt-get install bubblewrap.Without
bubblewrapinstalled, it prints the following warning message when starting, and sandbox commands fail:After installing it with
apt-get install bubblewrap, Codex seems to pick up the system Bubblewrap, and the sandbox works again.Using Ubuntu 24 with codex-cli 0.116.
I'm getting this:
I have bubblewrap installed.
Is there any update on this? I still have this issue.
the use_legacy_landlock workaround mentioned above seems to work, but yeah this should probably be addressed somehow
I'm updating the official Codex documentation soon, but you'll need to install Bubblewrap for eg.
apt-get install bubblewrapwhich installs the correct AppArmor policy for Codex to work or have unprivileged user namespaces enabled viasudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0.This should be fixed in 0.117.0.
@etraut-openai
you mean regardless of this (from @viyatb-oai in the msg above)
?
asking because I work on several remote machines I don't have admin privileges for, so it would spare a lot of pain if that were the case. So for example on one machine I have bwrap v0.9.0, on another v0.6.1, and so on.
For anyone still hitting this on Ubuntu 24.04 with Codex 0.117.0 even though
bubblewrapis already installed:I was still getting sandbox failures, and the decisive check was that the actual unprivileged user could not create the required user namespace:
Inside Codex,
/usr/bin/bwrapwas already being used:and the relevant sysctls were:
Also, a direct Bubblewrap test still failed:
What fixed it for me was installing Ubuntu’s separate AppArmor profile package and enabling the
bwrap-userns-restrictprofile:After that, the direct
bwraptest succeeded and Codex started working.How to verify on your machine as the unprivileged user running codex:
Background:
bwrap-userns-restrictis not part of the baseapparmorpackage on current Ubuntu packaging. Ubuntu ships it in the separateapparmor-profilespackage, and thebwrapprofile is not enabled by default. So havingbubblewrapinstalled and having/usr/bin/bwrappresent is still not sufficient if AppArmor is denying unprivileged user namespaces forbwrap.One extra detail: after enabling the
bwrapprofile,unshare -Ur truemay still fail, because that profile applies tobwrap, not to theunsharebinary in general. For Codex, the important check is the direct/usr/bin/bwrap ...test above.Follow-up data point from my Ubuntu 24.04 setup: the
bwrap-userns-restrictsolution fixed Codex for me, but it also broke some Flatpak apps.After enabling the
bwrapAppArmor profile, Codex 0.117.0 started working, but some Flatpak apps started failing on startup or during file updates. The kernel log showed AppArmor denials like these:I was seeing
apparmor="DENIED"withoperation="link"under bothprofile="bwrap"andprofile="unpriv_bwrap"for paths inside Flatpak app data directories.Have a look at:
apparmor="DENIED"So in my case there is a real conflict:
bwrap-userns-restrictfixes CodexWhat finally worked for me as a combined setup was:
bwrapAppArmor profile again so Flatpak apps work:bwrapAppArmor profile:So my conclusion is: on Ubuntu 24.04,
bwrap-userns-restrictcan solve the Codex issue, but it can also conflict with Flatpak apps. The workaround that solved both for me was to disable thebwrapAppArmor profile and setkernel.apparmor_restrict_unprivileged_userns=0persistently.0.118.0 still get error
So is codex effectively unsupported on Ubuntu 24.04 and later based distributions now?
This worked for me on Ubuntu 24.04LTS
Can you elaborate on which AppAmor policy that is and where it should come from, to help me find it? Because on 24.04 i see no traces of this being the case.
Looking for apparmor profile
I've also did
apt-get install --reinstall bubblewrap.I see no related apparmor profiles:
% rg 'bubblewrap|bwrap|codex' /etc/apparmor*But I also do not see any evidence that apparmor profiles are supposed to be installed with bubblewrap. There are no dependencies for it:
I did
apt source bubblewrapto download source, but cannot find the word 'apparmor' anywhere in files or file names:Extra data
I'm running this on a regular laptop, not in a container or VM.
@geomander : have a look at my post a bit ealier in the thread: apt install apparmor-profiles
But also have a look at the other issues you might run into with for example flatpak if you happen to use that.
@cs224 Yes, I did read it all, but I use Flatpak and containers extensively, and
apparmor_restrict_unprivileged_usernsis a security feature that adds protection in both of those contexts. So globally disabling it does not seem like the right solution to me.--enable use_legacy_landlock, however, does work as a workaround.But this issue is marked as closed, and the two dev comments:
...apt-get install bubblewrap, which installs the correct AppArmor policy for Codex to work...and
This should be fixed in 0.117.0.make it sound like the issue is considered fixed. I cannot confirm that on my end, so either I am missing something, or maybe the issue was considered resolved prematurely.
Reading state information... Done
bubblewrap is already the newest version (0.9.0-1ubuntu0.1).
0 upgraded, 0 newly installed, 0 to remove and 19 not upgraded.
root@nyx:/home/john/wardline#
Newest bubblewrap doesn't fix it.
codex-cli 0.118.0
Ok, I did some research and testing. I believe there are 2 solutions that align with the official way Ubuntu does these things in 24.04, neither of which requires globally disabling
apparmor_restrict_unprivileged_userns. It should be noted thatapparmor_restrict_unprivileged_usernsis an Ubuntu-specific thing that denies apps run as regular users from creating namespaces (the thing that makes containers and bwrap-sandoxing work), unless they specifically have been allowed to.Solution 1: Allow bwrap to create namespaces
Ubuntu 24 already uses this method in over 90 other AppArmor profiles. So we just create what is basically a copy of one of these existing profiles, e.g.
/etc/apparmor.d/flatpak, and replace the names inside withbwrap.Save it as
/etc/apparmor.d/bwrap-usernsand load it withsudo apparmor_parser /etc/apparmor.d/bwrap-userns.This allows
bwrapto create namespaces at will. This should "just work(tm)", but the drawback is that this also allows any program inside the sandbox to create namespaces, which is less strict than it could be. And so Ubuntu attempted to implement a stricter version, which is Solution 2 below.Rolling back
If you want to roll back this change later, do
sudo apparmor_parser -R /etc/apparmor.d/bwrap-usernsand thensudo rm /etc/apparmor.d/bwrap-userns(in that order).Solution 2: bwrap-userns-restrict
In Ubuntu 24.04.02 they added the
bwrap-userns-restrictAppArmor profile, which allowsbwrapto create a namespace, but children ofbwrapwill _not_ be allowed to do so. Unfortunately, the update broke a lot of Flatpaks and they had to roll the change back.I still mention it here, because it seems like the slightly better solution if it works. And in fact _none of my Flatpaks exhibit any problems_. If it breaks for you, you can just roll back this solution and use solution 1.
Then load the profile with
sudo apparmor_parser /etc/apparmor.d/bwrap-userns-restrictand test.Rolling back
If you want to roll back this change later, do
in that order.
---
@cs224 you mentioned that some of your Flatpaks broke. Could you name some examples? I'd love to test here. Ubuntu only made minor changes to the
bwrap-userns-restrictprofile in 25.04, so it would be interesting to see if those minor changes would fix the issues you saw, under 24.04.I hit this issue on Ubuntu 24.04 with codex 0.120.0. What worked for me was running
codex features enable use_legacy_landlockas suggested here by filimonov.Before, I tried some of the fixes suggested by others. They didn't fix the issue, and surprisingly the agent still could edit files by running commands even if
bwrapwas failing. See the output fromcodex exec --jsonhere - one tool call fails, another succeeds.It's worrying that only some of the tools are sandboxed via bwrap. It's also worrying that gpt-5.2 itself says that Ubuntu intentionally doesn't ship with
bwrap-userns-restrictsince it circumvents system security restrictions.No. The _opposite_ is true.
bwrap-userns-restrictenforces security restrictions that would otherwise be bypassed by running anunconfinedprofile. It was disabled in 24.04.3 because these added restrictions were breaking certain Flatpaks. It was reintroduced in 25.04 (see release notes https://documentation.ubuntu.com/release-notes/25.04/) and is now part of the default install.I think either gpt-5.2 is gaslighting you or maybe you misunderstood the reply it gave you. :)
https://github.com/openai/codex/issues/18800
this workaround is being removed soon!
codex --enable use_legacy_landlockhttps://github.com/openai/codex/issues/14919#issuecomment-4076504751
This works with latest codex after 5.5 update
This is still broken as of build 124, ubuntu 24.04 LTS
I've been running FIO benchmarks using Codex, but they are failing due to permission issues. Could you provide an option to temporarily disable the sandbox when requested by the user?
• I’m retrying the doc updates now.
• I tried, but the same shell-layer failure is still blocking any file write through command execution:
bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted
This is on version 0.124.0
As far as I can tell this issue was closed prematurely, as the problem still persists on Ubuntu 24.04 with
bubblewrapinstalled on latestcodex(0.128.0as of this writing). Basic sandbox edit operations fail, which significantly impedes normal work. Only theuse_legacy_landlocksetting reliably fixes it for me.Please don't remove
use_legacy_landlockuntil there is actually a fix or workaround for LTS users that doesn't involve disabling AppArmor security features.@eloquence did you try an AppArmor profile for
bwrap? I mentioned it earlier, but it may have been buried.I've put together a guide to fixing this so we have something to link to: https://github.com/dfaerch/bubblewrap-on-ubuntu
Thanks @dfaerch - I've not tried this yet, but if this is going to be the final word from OpenAI on this issue, that does seem like the way to go.
However, IMO at a minimum Codex itself should attempt to _detect_ the sandbox issue and offer a path to resolution, before considering this issue resolved. That resolution path, as your approach suggests, should indeed be minimally invasive as fixing the behavior of one application should not require weakening a system-wide security setting that exists for good reasons.
@dfaerch @eloquence does the instructions for Ubuntu 24.04 not work for you? https://developers.openai.com/codex/concepts/sandboxing#prerequisites (if you scroll past a bit)
Following those do make codex work, but breaks other things using bwrap (ie flatpak), which is why the bwrap-userns-restrict was rolled back and not installed by default in 24.04.
There are more details on this in my repo readme, including how to fix it.
@viyatb-oai I can confirm that the instructions do work. I don't use Flatpak, so I can't speak to the breakage that @dfaerch mentions, but that seems important to at least acknowledge in the docs to avoid users breaking something else by attempting to get Codex to work.
In general, FWIW, this messing around with AppArmor settings feels very brittle and it might be advisable to support a first class fallback option until system configuration changes are no longer necessary on any mainline LTS release. Users could still be given a warning that they are running on a lower security sandbox, and instructions to resolve.
I should also note that contrary to what the docs say, I did _not_ get a startup warning prior to running these instructions. Here's a direct copy/paste of my session.
As you can see there is no warning message about the sandbox initialization, nor any pointer to a workaround.