Skip to content

feat(sandbox): Landlock TCP port restriction for mandatory proxy enforcement#13

Closed
Ladas wants to merge 1 commit into
feat/platform-mode-v2from
feat/landlock-tcp-port
Closed

feat(sandbox): Landlock TCP port restriction for mandatory proxy enforcement#13
Ladas wants to merge 1 commit into
feat/platform-mode-v2from
feat/landlock-tcp-port

Conversation

@Ladas

@Ladas Ladas commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Add Landlock ABI v4 TCP port restriction to Platform mode. When active,
the kernel restricts connect() to only the proxy port (default 3128).
Any connect() to another port returns EACCES at the kernel level.

This closes the cooperative proxy gap: without this, a process ignoring
HTTP_PROXY can connect directly (caught only by K8s NetworkPolicy at
the CNI level). With this, enforcement is at the kernel LSM layer -- no
userspace bypass possible.

Depends on: #12 (Platform mode base)

What changes

  • Import AccessNet, NetPort from the landlock crate (already v0.4, supports network rules)
  • In prepare(): handle AccessNet::ConnectTcp and add NetPort rule for the proxy port when Platform mode
  • Graceful degradation: if kernel ABI < v4, network rules silently skipped (cooperative proxy + NetworkPolicy fallback)

How it works

Agent → connect(evil.com:443) → Landlock EACCES (port 443 not in allowlist)
Agent → connect(127.0.0.1:3128) → Landlock allows → proxy → OPA domain check
Property Value
Capabilities required None
restricted-v2 compatible Yes
Enforcement level Tier 1 (kernel LSM hook)
Performance overhead Negligible (in-kernel, no context switch)
RHEL 9.6 support Yes (ABI v4 backported)
Graceful degradation Yes (skips on ABI < v4)

Related

Assisted-By: Claude Code

When Platform mode is active, apply Landlock ABI v4 network rules to
restrict TCP connect to only the proxy port (default 3128). This makes
the loopback CONNECT proxy mandatory at the kernel level -- a process
calling connect() to any other port gets EACCES.

This closes the cooperative proxy gap identified in the enforcement
analysis: without this, processes ignoring HTTP_PROXY could bypass the
proxy and connect directly (caught only by Tier 3 NetworkPolicy). With
this, enforcement is at Tier 1 (kernel LSM).

Graceful degradation: if the kernel does not support Landlock ABI v4
(e.g. RHEL 9.5 or earlier), the network rules are silently skipped
and enforcement falls back to the cooperative proxy + NetworkPolicy
(same as Issue NVIDIA#899 base behavior).

Ref: NVIDIA#899
@Ladas Ladas closed this Jun 12, 2026
@Ladas Ladas deleted the feat/landlock-tcp-port branch June 12, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant