repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
uts-namespace.mdMarkdown96 lines4.6 KiBsource raw download

title: "UTS Namespace" section: "Linux" sectionSlug: "linux-hardening" sourcePath: "src/linux-hardening/containers-namespaces/container-security/protections/namespaces/uts-namespace.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/linux-hardening/containers-namespaces/container-security/protections/namespaces/uts-namespace.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

UTS Namespace#

Overview#

The UTS namespace isolates the hostname and NIS domain name seen by the process. At first glance this may look trivial compared with mount, PID, or user namespaces, but it is part of what makes a container appear to be its own host. Inside the namespace, the workload can see and sometimes change a hostname that is local to that namespace rather than global to the machine. [1]

On its own, this is usually not the centerpiece of a breakout story. However, once the host UTS namespace is shared, a sufficiently privileged process may influence host identity-related settings, which can matter operationally and occasionally security-wise.

Lab#

You can create a UTS namespace with:

sudo unshare --uts --fork bash
hostname
hostname lab-container
hostname

The hostname change remains local to that namespace and does not alter the host's global hostname. This is a simple but effective demonstration of the isolation property.

Runtime Usage#

Normal containers get an isolated UTS namespace. Docker and Podman can join the host UTS namespace through --uts=host, and lower-level runtimes can omit the UTS namespace from an OCI configuration to inherit the runtime namespace. Most of the time, however, private UTS isolation is simply part of the normal container setup and requires little operator attention. [2]

Security Impact#

Even though the UTS namespace is not usually the most dangerous one to share, it still contributes to the integrity of the container boundary. If the host UTS namespace is exposed and the process has the necessary privileges, it may be able to alter host hostname-related information. That may affect monitoring, logging, operational assumptions, or scripts that make trust decisions based on host identity data.

Abuse#

If the host UTS namespace is shared, the practical question is whether the process can modify host identity settings rather than just read them:

readlink /proc/self/ns/uts
hostname
cat /proc/sys/kernel/hostname

If the container also has the necessary privilege, test whether the hostname can be changed:

hostname hacked-host 2>/dev/null && echo "hostname change worked"
hostname

This is primarily an integrity and operational-impact issue rather than a full escape, but it still shows that the container can directly influence a host-global property.

Impact:

On Docker-style environments, a useful host-side detection pattern is:

docker ps -aq | xargs -r docker inspect --format '{{.Id}} UTSMode={{.HostConfig.UTSMode}}'

Containers showing UTSMode=host are sharing the host UTS namespace and should be reviewed more carefully if they also carry capabilities that let them call sethostname() or setdomainname().

Checks#

These commands are enough to see whether the workload has its own hostname view or is sharing the host UTS namespace.

readlink /proc/self/ns/uts   # UTS namespace identifier
hostname                     # Hostname as seen by the current process
cat /proc/sys/kernel/hostname   # Kernel hostname value in this namespace

What is interesting here:

In most environments, the UTS namespace is best thought of as a supporting isolation layer. It is rarely the first thing you chase in a breakout, but it is still part of the overall consistency and safety of the container view.

References#