<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wg-wrap.git/internal/namespace/launcher_src/launcher.c, branch main</title>
<subtitle>wg-wrap runs commands in network namespaces configured with userspace wireguard tunnels.
</subtitle>
<id>https://git.theodohertyfamily.com/wg-wrap.git/atom?h=main</id>
<link rel='self' href='https://git.theodohertyfamily.com/wg-wrap.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/'/>
<updated>2026-05-30T01:07:46Z</updated>
<entry>
<title>feat: harden bootstrap and optimize network data path</title>
<updated>2026-05-30T01:07:46Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-30T01:07:46Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=d2173cdbc03884ecd9534e9369f8ebe1634f7e9c'/>
<id>urn:sha1:d2173cdbc03884ecd9534e9369f8ebe1634f7e9c</id>
<content type='text'>
- Security: Eliminate namespace escape risk by removing `HostBind` and enforcing `FDBind` using pre-opened host socket FDs.
- Security: Replace unsafe `atoi` with `strtol` and strict validation in the C launcher to prevent malformed PID joins.
- Stability: Fix PID wraparound by storing session timestamps in PID files to detect recycled PIDs.
- Stability: Resolve DNS mount leaks by implementing proper unmounting of `/etc/resolv.conf` during tunnel shutdown.
- Performance: Optimize `FDBind` throughput by implementing batch packet processing in the receive loop.
- Deployment: Implement `memfd_create` for the C launcher to support `noexec` temporary directories and reduce disk I/O.
- Maintenance: Replace external `ip` CLI dependency with native `netlink` library for robust network configuration.
- Quality: Fix all `golangci-lint` errors and replace remaining panics with explicit error handling.
</content>
</entry>
<entry>
<title>Refactor rootless namespace joining to use C launcher</title>
<updated>2026-05-30T00:11:07Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-30T00:11:07Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=4ddd0d2ffc7073f2d55ffb6777e3a168af0051f0'/>
<id>urn:sha1:4ddd0d2ffc7073f2d55ffb6777e3a168af0051f0</id>
<content type='text'>
Fix an architectural shortfall where concurrent sessions failed to share
the target network and mount namespaces. Because the Go runtime is
multi-threaded, calling unix.Setns with CLONE_NEWNS from Go always returned
EINVAL, silently forcing concurrent runs to fall back to bootstrapping separate
isolated namespaces and separate WireGuard connections.

This commit resolves the issue by extending the embedded single-threaded C
launcher to handle namespace joining, and introducing a host-to-isolated path
propagation pattern:

1. Launcher setns Support: The C launcher now checks for WG_WRAP_JOIN_PID in
   the environment. If present, it joins the User, Mount, and Network
   namespaces of the active PID in single-threaded mode before executing the Go
   binary.
2. BootstrapJoin Integration: Implemented namespace.BootstrapJoin to
   transition joining sessions via the launcher.
3. Path Preservation: Export WG_WRAP_HOST_RUNTIME_BASE_DIR from the host to ensure
   the isolated instance maps the profile and PID directories to the exact
   same location.
4. Redundant Tunnel Bypass: Detect joined sessions via WG_WRAP_JOINED=1 in the CLI
   and bypass starting a duplicate WireGuard tunnel on the occupied tun0.
5. Testing: Added tests/e2e/sharing_test.go to assert namespace ID equality,
   which now passes successfully.
6. Git Tracking: Fixed .gitignore overmatch to stop ignoring cmd/wg-wrap/.
</content>
</entry>
<entry>
<title>security, refactor: resolve critical namespace escapes, path traversal, concurrency races, and resource leaks</title>
<updated>2026-05-29T23:41:28Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-29T23:41:28Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=c6a1240e469ff8170cf31b39a01c1cb08fdb86f4'/>
<id>urn:sha1:c6a1240e469ff8170cf31b39a01c1cb08fdb86f4</id>
<content type='text'>
This commit addresses several security vulnerabilities, undefined behaviors, race conditions, and resource leaks across the application:

1. Path Traversal &amp; Arbitrary File/Directory Actions:
   - Implemented `IsValidProfileName` in `internal/cli/cli.go` to restrict profile names to alphanumeric characters, dashes, and underscores.
   - Applied validation to all CLI paths (`--profile`, `import`, `configure`, `delete`, `stop`) to prevent directory traversal and unauthorized directory or file creations/deletions.
   - Added `TestIsValidProfileName` in `internal/cli/cli_test.go`.

2. Network Namespace Escape via Compromised Thread recycling:
   - Fixed `HostBind.Open` in `internal/wireguard/wireguard.go` to panic immediately instead of returning an error if restoring the isolated namespace fails. This prevents Go from returning the compromised thread (still in host namespace) to the runtime pool.

3. Concurrency Race Conditions &amp; Thread Migration:
   - Added `runtime.LockOSThread()` in `JoinExistingNamespace` (`internal/namespace/pinning.go`) to ensure the goroutine stays on the modified namespace thread before executing the command.
   - Implemented profile locking using advisory file locks (`unix.Flock`) on a `.lock` file in the user's runtime directory (with platform stubs in `internal/namespace/lock_linux.go` and `internal/namespace/lock_stub.go`).
   - Integrated locking during `App.Run` and `App.ExecuteCommand`, releasing the lock right before spawning the wrapped process.

4. File Descriptor Leaks on Bootstrap Failures:
   - Refactored `Bootstrap()` in `internal/namespace/namespace.go` to use named return values and a deferred cleanup loop that closes `execFd`, `hostNetFd`, and the duplicated `hostSocketFd` if `syscall.Exec` fails.
   - Added an explicit `conn.Close()` on the original socket connection after duplication.

5. Glibc Undefined Behavior / Crash on argc == 0:
   - Corrected `internal/namespace/launcher_src/launcher.c` to not reference `argv[0]` when `argc &lt; 1`. Recompiled `internal/namespace/launcher.bin`.

6. DNS Fallback Usability &amp; Import Safety:
   - Added validation in `ExecuteCommand` to issue a warning when falling back to `1.1.1.1` if the configuration does not route all traffic (`0.0.0.0/0` or `::/0`).
   - Prevented silent overwrites in `handleProfileImport` if the destination profile already exists, and added a corresponding unit test verifying failure.
</content>
</entry>
<entry>
<title>feat: implement userspace wireguard data-path and unprivileged host fd-passing</title>
<updated>2026-05-29T22:29:12Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-29T22:29:12Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=ee2f5d545825752af63da36e2b9ec7a92985a875'/>
<id>urn:sha1:ee2f5d545825752af63da36e2b9ec7a92985a875</id>
<content type='text'>
- Implement complete rootless network namespace bootstrap via C launcher using unshare(CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWNET).
- Resolve unprivileged network isolation blackhole via host-socket preservation (FD passing): open client UDP sockets on the host pre-isolation, clear O_CLOEXEC, and ingest them via custom `FDBind` inside the sandbox.
- Implement isolated routing table automation over `tun0` (addresses, MTU, default routes).
- Implement persistent, multi-process namespace sharing and joining using reference-counted PID files and the setns system call.
- Write robust, self-contained E2E data plane test suites in `tests/e2e/e2e_test.go` using a mock UDP listener.
- Update project documentation (`README.md` and `AGENTS.md`) to reflect completed milestones.
- Ensure 100% test passing rate and zero lint/staticcheck warnings.
</content>
</entry>
<entry>
<title>Fix PID lifecycle race and improve CLI routing for diagnostic commands</title>
<updated>2026-05-22T15:37:57Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-22T15:37:57Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=e5bbb969a15c569cf7d37634234a71783f628390'/>
<id>urn:sha1:e5bbb969a15c569cf7d37634234a71783f628390</id>
<content type='text'>
</content>
</entry>
<entry>
<title>docs: update README and AGENTS.md to reflect embedded launcher architecture</title>
<updated>2026-05-22T14:14:03Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-22T14:14:03Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=5dbc46f3c1c75bf922bcc1c3df342323c23c04ce'/>
<id>urn:sha1:5dbc46f3c1c75bf922bcc1c3df342323c23c04ce</id>
<content type='text'>
</content>
</entry>
<entry>
<title>feat: implement rootless network isolation bootstrap and C launcher</title>
<updated>2026-05-22T14:05:38Z</updated>
<author>
<name>James O'Doherty</name>
<email>james@theodohertyfamily.com</email>
</author>
<published>2026-05-22T14:05:38Z</published>
<link rel='alternate' type='text/html' href='https://git.theodohertyfamily.com/wg-wrap.git/commit/?id=764d3e67fc783c487f42d398d1b85a5a1f0d8ef0'/>
<id>urn:sha1:764d3e67fc783c487f42d398d1b85a5a1f0d8ef0</id>
<content type='text'>
</content>
</entry>
</feed>
