fix: permit verified local APT acquisition with native network denial checks
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 14:59:23 +01:00
parent e18fae0e8a
commit a5c2dce4fb
9 changed files with 210 additions and 13 deletions
+21 -1
View File
@@ -14,6 +14,7 @@ import os
from pathlib import Path
import re
import selectors
import socket
import stat
import subprocess
import sys
@@ -824,6 +825,7 @@ APT::Install-Suggests "false";
APT::Get::AutomaticRemove "false";
APT::Get::Fix-Broken "false";
APT::Get::Fix-Missing "false";
APT::Get::Download "true";
APT::Get::allow-Downgrades "false";
APT::Get::allow-Remove-Essential "false";
DPkg::Lock::Timeout "10";
@@ -838,8 +840,12 @@ DPkg::Tools::Options::/usr/lib/rmm-apt-transaction/hook::InfoFD "0";
def apt_argv(transaction):
# APT's --no-download also prevents the local file method from resolving
# its Install filename (v3 emits **ERROR**). Permit local acquisition of
# the already sealed/hash-checked archive. Empty sources, fixed paths and
# the verified AF_UNIX-only private worker still forbid network retrieval.
return ['/usr/bin/apt-get', '--yes', '--no-remove', '--no-install-recommends',
'--no-download', 'install', '--'] + [p.archive_path for p in transaction.packages]
'install', '--'] + [p.archive_path for p in transaction.packages]
def check_hook_config(config):
@@ -985,6 +991,7 @@ def inspect_sandbox(workspace=None):
require(caps == sum(1 << n for n in (0, 1, 3, 4, 6, 7, 8, 31)), 'SANDBOX_CAPS')
require(int(status['CapInh'].strip(), 16) == 0 and int(status['CapAmb'].strip(), 16) == 0,
'SANDBOX_INHERITED_CAPS')
verify_no_ip_sockets()
# Host PID1 must not be visible. Namespace PID1 is this trusted Python worker.
require(Path('/proc/1/cmdline').read_bytes().startswith(b'/usr/bin/python3\x00-I\x00'),
'SANDBOX_PID1')
@@ -1003,6 +1010,19 @@ def inspect_sandbox(workspace=None):
require(os.readlink('/proc/self/ns/' + name) != ids[name], 'SANDBOX_NAMESPACE')
def verify_no_ip_sockets():
"""Kernel enforcement, not a no-download flag or a network configuration claim."""
for family in (socket.AF_INET, socket.AF_INET6):
try:
candidate = socket.socket(family, socket.SOCK_STREAM)
except OSError as error:
require(error.errno in (errno.EAFNOSUPPORT, errno.EPERM, errno.EACCES),
'SANDBOX_IP_SOCKET_CHECK')
else:
candidate.close()
raise Veto('SANDBOX_IP_SOCKET_ALLOWED')
def inspect_private_control_paths():
# Validate directory contents rather than guessing future key filenames.
# Both historical and current cloud identity/config layouts must be hidden.