惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 最新话题
Help Net Security
Help Net Security
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
W
WeLiveSecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
PCI Perspectives
PCI Perspectives
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
S
SegmentFault 最新的问题
J
Java Code Geeks
P
Privacy & Cybersecurity Law Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 【当耐特】
博客园_首页
H
Hacker News: Front Page
T
Threatpost
Jina AI
Jina AI
博客园 - Franky
月光博客
月光博客
L
LINUX DO - 热门话题
The Cloudflare Blog
H
Heimdal Security Blog
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
Cloudbric
Cloudbric
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
S
Secure Thoughts
T
Tenable Blog
I
Intezer
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

Hacker News

Introducing Claude Opus 4.7 Qwen Studio The Future of Everything is Lies, I Guess: Where Do We Go From Here? GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Moving a large-scale metrics pipeline from StatsD to OpenTelemetry / Prometheus GitHub - Nightmare-Eclipse/RedSun: The Red Sun vulnerability repository GitHub - SethPyle376/hiraeth: Local AWS emulator focused on fast integration testing, with SQS support, SQLite-backed state, and a debug-friendly web UI. GitHub - macOS26/Agent: Any AI, replaces Claude Code, Cursor, OpenClaw. Over 18 LLM providers (Claude, OpenAI, Gemini, Ollama, Zai, HF, Qwen) wired into a native Mac app that writes code, builds Xcode projects, bumps versions, manages git, automates Safari, use AppleScript, JS or Accessibility, extend Agent! w/ MCP Servers, run tasks from your iPhone via Messages. YouTube now lets you turn off Shorts I Made a Terminal Pager Burgers | マクドナルド公式 Commands — HackerNews CLI documentation ChatGPT for Excel PiCore - Raspberry Pi Port of Tiny Core Linux Live Nation illegally monopolized ticketing market, jury finds Google Broke Its Promise to Me. Now ICE Has My Data. Founding Engineer at Adaptional | Y Combinator CRISPR takes important step toward silencing Down syndrome’s extra chromosome GitHub - saffron-health/libretto: The AI toolkit for building reliable browser automations US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf] Unexpected €54k billing spike in 13 hours: Firebase browser key without API restrictions used for Gemini requests Retrofitting JIT Compilers into C Interpreters IPv6 – Google The Accursèd Alphabetical Clock Cybersecurity Looks Like Proof of Work Now Fragments: April 14 Cal.com Goes Closed Source: Why AI Security Is Forcing Our Decision | Cal.com - Scheduling Software for Online Bookings Laravel raised money and now injects ads directly into your agent When moving fast, talking is the first thing to break Too much Discussion of the XOR swap trick – Heather Cafe Introduction to Spherical Harmonics for Graphics Programmers The Grand Line Building a Z-Machine in the worst possible language High-Level Rust: Getting 80% of the Benefits with 20% of the Pain GitHub - duguyue100/midnight-captain: Inspired by Midnight Commander, tailored to my taste. How to build a `git diff` driver · Jamie Tanna | Software Engineer Center for Responsible, Decentralized Intelligence at Berkeley The Local Universe’s Expansion Rate Is Clearer Than Ever, but Still Doesn’t Add Up - A new synthesis of astronomical measurements confirms a persistent mismatch that could point to physics beyond current models The air throughout our homes is infused with microplastics. But there are things you can do to breathe less of them The disturbing white paper Red Hat is trying to erase from the internet – OSnews The Future of Everything is Lies, I Guess: Annoyances ‘Abhorrent’: the inside story of the Polymarket gamblers betting millions on war Productive procrastination — Max van IJsselmuiden maps, territory and LMs 447 Terabytes per Square Centimetre at Zero Retention Energy: Non-Volatile Memory at the Atomic Scale on Fluorographane Show HN: Pardonned.com – A searchable database of US Pardons 20 Years on AWS and Never Not My Job The Seasons are Wrong Artemis II crew splashes down near San Diego after historic moon mission We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs How a dancer with ALS used brainwaves to perform live On filing the corners off my MacBooks Installing every* Firefox extension OpenClaw’s memory is unreliable, and you don’t know when it will break Steve Blank Nowhere Is Safe Chimpanzees in Uganda locked in vicious 'civil war', say researchers watgo - a WebAssembly Toolkit for Go linux/Documentation/process/coding-assistants.rst at master · torvalds/linux GitHub - callumlocke/json-formatter: Makes JSON easy to read. Founding Product Engineer at Bild AI | Y Combinator A compelling title that is cryptic enough to get you to take action on it GitHub - Keychron/Keychron-Keyboards-Hardware-Design: Industrial design files for Keychron keyboards and mice. 100+ models with CAD assets in STEP, DXF, DWG, and PDF. Source-available, with commercial use allowed for original compatible accessories within the license terms. [ANNOUNCE] WireGuardNT v0.11 and WireGuard for Windows v0.6 Released 1D-Chess Helium Is Hard to Replace Cooperative Vectors Introduction | Evolve Keeping a Postgres queue healthy — PlanetScale Our response to the Axios developer tool compromise Do Americans read print books, e-books or audiobooks more? The Zettelkasten Method in Obsidian: A Practical Setup Guide Artemis II Is Competency Porn and We Are Starving For It WeakC4 Flight Viz — Cockpit View A Mexican surveillance giant you’ve never heard of is now watching the U.S. border Surelock: Deadlock-Free Mutexes for Rust RISC-V 101 – what is it and what does it mean for Canonical? | Ubuntu The Problem That Built an Industry How Much Linear Memory Access Is Enough? | Solidean Investigating Split Locks on x86-64 Simplest hash functions Sybilproof reputation mechanisms (2005) [pdf] What is a property? How Complex is my Code? Static code analysis in Kotlin — tools overview Toffoli gates are all you need PGLite evangelism dcmake: a new CMake debugger UI Clojure on Fennel part one: Persistent Data Structures Fragments: April 2 Python Release Python install manager 26.1 The Life and Death of the Book Review - Liberties Introducing Database Traffic Control — PlanetScale Bitcoin miners are losing $19,000 on every BTC produced as difficulty drops 7.8% God sleeps in the minerals Building slogbox Apple Silicon and Virtual Machines: Beating the 2 VM Limit Who was “Not Even Wrong” first? Pokemon Evolution Vs Darwinian Evolution The APL Programming Language Source Code
Enhancing x11 Application Security with LXC · dobrowolski.dev
shirozuki · 2026-06-28 · via Hacker News

2025-12-05

Wouldn't it be nice to add an extra layer of security to a web browser or an Electron-based IM application? After all, if a browser is compromised, the user’s entire home directory may be at risk.

Let’s mitigate this by using LXC to isolate the application from the host system.

The system used in this example is Arch Linux, but the procedure should be easily adaptable to other distributions.


Networking Capabilities

First, we need to install and preconfigure LXC. Install the following packages:

# pacman -S lxc lxcfs

Next, we need to give our LXC containers networking capabilities. To do that, edit the /etc/default/lxc file and append the following line to the bottom:

Now we can start the LXC bridge interface. Enable and start the corresponding systemd unit:

# systemctl enable lxc-net.service --now

A new interface named lxcbr0 should now be available. Verify this with:

# ip a show dev lxcbr0

Creating the Container

With the previous steps completed, we can create our first application container. Let's start by creating an initial configuration.

Navigate to /etc/lxc and create a new configuration file. Since I’m creating a web-browser container, I’ll name mine www.conf.

Open the file with your preferred editor and add the following lines:

lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 10:66:6a:xx:xx:xx
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536

The first four lines specify that the container should use the network bridge we created earlier.

Next, we define how the container’s UIDs and GIDs should be mapped to those on the host. Since our goal is maximum security, we’ll use unprivileged containers. To achieve this, we map the container’s IDs into a range of IDs that do not exist on the host. This ensures that even if a malicious process escapes the container, it will end up with no meaningful permissions on the host system.

Understanding idmap

Here’s a detailed explanation of how the idmap configuration works:

lxc.idmap = [type] [container_id] [host_id] [range]
  • [type] – Specifies which type of ID is being mapped. Options:

    • u for UID
    • g for GID
  • [container_id] – The first UID/GID inside the container to map. In our case it’s 0 (the container’s root).

  • [host_id] – The starting UID/GID on the host that container_id maps to. Here, 0 in the container maps to 100000 on the host. IDs increase sequentially:

    • container_id=1 → host_id=100001
    • container_id=1000 → host_id=101000
  • [range] – The size of the UID/GID block to map. We use 65536 to provide a full standard Linux ID range.

Example mapping table:

    | container_id       | host_id     |
    | ------------------ | ----------- |
    | 0                  | 100000      |
    | 1                  | 100001      |
    | 1000               | 101000      |
    | 65535              | 165535      |

Next, we need to tell LXC which UID/GID mappings to use in our new container. We do this by adding the following line to both /etc/subuid and /etc/subgid:

This line means that the host user root can create UID mappings in the range 100000–165535 for LXC containers. It corresponds directly to the unprivileged container configuration we created earlier.

If you want to create another container with different mappings, for example, mapping container_id=0 to host_id=200000, simply add another line to the subuid/subgid files:

root:100000:65536
root:200000:65536

Spinning up the container

Now we are finally ready to create our container using the configuration file we prepared. For this example, I’ll use the debian:trixie image as a base:

# lxc-create --config /etc/lxc/www.conf --name www -t download --- \
    -d debian -r trixie -a amd64

Verify the container is running:

# lxc-ls -f

Once the setup is complete, log into the container:

# lxc-attach www /bin/bash

Inside the container, you can install the software you need just like on a regular Linux system. For example, to run Firefox:

# apt update
# apt-get -y install firefox-esr

Many x11 applications do not run well as root, so it’s best to create a dedicated user to run the application inside the container:

# /sbin/useradd -m -s /bin/bash www

Setting up x11

Basic container configuration is complete, so let's jump right into configuring it to host x11 apps. First, we have to map the x11 socket. If you're currently running an X server, you'll find it under /tmp/.X11-unix.

We also need to give the container an .Xauthority so it can authorize against the X server. Simply mounting the host's file won't work: each cookie entry is keyed by hostname, and the client only uses the entry whose hostname matches the machine it runs on — which, inside the container, it won't. The fix is to replace the entry's family field with the FamilyWild wildcard (ffff) so it matches any host, then merge it into a fresh .Xauthority for the container:

: > /tmp/lxc.Xauthority && xauth nlist :0 | \
    sed 's/^..../ffff/' | xauth -f /tmp/lxc.Xauthority nmerge -
# Replace :0 with your $DISPLAY value

Lastly, we have to make sure we've set the following environment variables:

  • DISPLAY - set this to the host's DISPLAY value

  • XAUTHORITY - set this to the path where the lxc.Xauthority file will be mounted inside the container

To implement these steps, let's edit the container's configuration file and add the following lines. Note that this is the per-container config that lxc-create generated under /var/lib/lxc/www/config, which is distinct from the /etc/lxc/www.conf template we passed at creation time:

lxc.environment = XAUTHORITY=/tmp/lxc.Xauthority
lxc.environment = DISPLAY=:0

lxc.mount.entry = /tmp/.X11-unix tmp/.X11-unix none bind,optional,create=dir,ro
lxc.mount.entry = /tmp/lxc.Xauthority tmp/lxc.Xauthority none bind,optional,create=file,ro

One last detail: since we built an unprivileged container, its IDs are shifted by our idmap (container UID 0 maps to host UID 100000). The .Xauthority file, however, was created by xauth with mode 0600 and is owned by your host user, whose UID falls outside that mapped range. Inside the container the file therefore shows up as owned by nobody, and our container user can't read it - so X would still reject the connection with Authorization required.

The simplest fix is to make the cookie file world-readable on the host:

chmod 644 /tmp/lxc.Xauthority

If you'd rather keep it at 0600, chown it to the mapped host UID of the container user instead (for the www user at container UID 1000, that's host UID 101000).

If everything went smoothly, you should now be able to run the browser we installed earlier and see its window on your host's desktop:

# lxc-start www
# lxc-attach www -- su www -c firefox

Optionally, if you want hardware-accelerated rendering and video decoding inside the container, you can pass through the GPU by mounting /dev/dri:

lxc.mount.entry = /dev/dri dev/dri none bind,optional,create=dir

Setting up sound

Audio follows the same pattern as the display. PipeWire ships a PulseAudio-compatible server, so we can expose a PulseAudio socket on the host and bind-mount it into the container, just as we did with the x11 socket.

First, install the audio packages inside the container so the application can use the socket:

# apt-get -y install pulseaudio pipewire-pulse

Next, tell PipeWire to open a dedicated PulseAudio socket by adding it to server.address in ~/.config/pipewire/pipewire-pulse.conf:

pulse.properties = {
    # ... keep the existing defaults ...
    server.address = [
        "unix:native"
        "unix:/tmp/pulse-socket-0"
    ]
}

Reload the PulseAudio server so the socket appears:

systemctl --user restart pipewire-pulse

/tmp/pulse-socket-0 should now exist. Next, mount it into the container and point PULSE_SERVER at it. Add the following to the container config:

lxc.environment = PULSE_SERVER=unix:/tmp/pulse-socket-0

lxc.mount.entry = /tmp/pulse-socket-0 tmp/pulse-socket-0 none bind,optional,create=file,ro

Unlike the cookie file, the socket is world-accessible, so the unprivileged-container ownership issue from before doesn't apply here — there's nothing to chmod. Restart the container and it should have working audio.


Conclusion

We now have a GUI application running inside an unprivileged LXC container, with its display and sound forwarded from the host. If the browser is compromised, the blast radius is a container whose UIDs map to an unused range on the host — your home directory and the rest of the system stay out of reach.

The isolation isn't free, though, and it isn't absolute. Every channel we opened — the X socket, the PulseAudio socket, optionally the GPU — is a hole through the wall, and each one widens what a compromised process can touch. The audio socket, for instance, grants capture as well as playback. Forward what the application actually needs and leave the rest out; that trade-off is the whole exercise.

The same setup works for any untrusted GUI application, not just a browser. You can tighten it further with seccomp or AppArmor profiles, but even as it stands, a compromised app is now boxed in rather than sitting on top of your home directory.