fix: permit verified local APT acquisition with native network denial checks
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Rust Discovery / RMM — Linux-Entwicklungsslice
|
||||
# Rust Discovery / RMM — Linux-MVP und Windows-Vorbereitung
|
||||
|
||||
> **Entwicklung wiederaufgenommen (2026-11-13).** Der Server zieht auf ausdrücklichen
|
||||
> Userwunsch auf einen dedizierten Internetserver um; der Entwickler-PC dient
|
||||
@@ -7,6 +7,17 @@
|
||||
> Deploymentstand: [docs/server-deployment.md](docs/server-deployment.md).
|
||||
> Die lokalen Serverbefehle und Slice-Beschreibungen unten sind historisch.
|
||||
|
||||
**Aktuell (Spezifikation 1.8):** Windows darf auf ausdrücklichen Userwunsch bereits
|
||||
parallel entwickelt werden. Windows-11-VM per abgesichertem Reverse-SSH mit
|
||||
Administratortoken erreichbar; noch kein RMM-Windows-Client installiert.
|
||||
Linux-Cloud-Agent, getrennte API/Gateway-Rollen, echte WebUI-Genehmigung und
|
||||
native Basis-/Rootdienstjobs sind nachgewiesen. APT-100-Ursache gefunden und
|
||||
Provider-/Sandboxkorrektur nativ als Readiness geprüft; Paketabnahme selbst
|
||||
bleibt offen. Aktueller Stand: [Implementierungsstand](docs/implementation-status.md),
|
||||
[Windows-Entwicklungszugang](deploy/windows/README.md).
|
||||
|
||||
## Historischer erster passiver Slice
|
||||
|
||||
**Kein fertiges MVP, keine Produktionsfreigabe.** Implementiert sind ein Rust-Workspace,
|
||||
PostgreSQL mit mandantenlokalen Transaktionen/RLS und eine passive Linux-Agentstrecke:
|
||||
Enrollment → lokaler P-256-Schlüssel → Gerätezertifikat → mTLS-WSS → Heartbeat/Basisinventar.
|
||||
|
||||
@@ -7,6 +7,7 @@ APT endpoint remains absent from the agent configuration and is stopped after
|
||||
the probe. General helper resumes with the existing binding/shared ledger.
|
||||
"""
|
||||
import base64
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@@ -42,9 +43,10 @@ def upgrade(payload):
|
||||
def ledger_guard():
|
||||
with sqlite3.connect(ledger.as_uri()+'?mode=ro',uri=True) as db:
|
||||
require(db.execute('PRAGMA integrity_check').fetchone()[0]=='ok','ledger integrity')
|
||||
require(db.execute('SELECT count(*) FROM consumed').fetchone()[0]==5 and
|
||||
actual={r[0] for r in db.execute('SELECT grant_id FROM consumed')}
|
||||
require(actual==set(payload['expected_grants']) and
|
||||
db.execute('SELECT count(*) FROM consumed WHERE result IS NULL').fetchone()[0]==0 and
|
||||
db.execute('SELECT count(*) FROM helper_sync_meta WHERE fault IS NOT NULL').fetchone()[0]==0,'five known closed root attempts required')
|
||||
db.execute('SELECT count(*) FROM helper_sync_meta WHERE fault IS NOT NULL').fetchone()[0]==0,'exact known closed root attempts required')
|
||||
ledger_guard()
|
||||
require(json.loads((state/'identity.json').read_text())['agent_id']==payload['agent_id'],'cloud identity drift')
|
||||
with sqlite3.connect((state/'journal.sqlite').as_uri()+'?mode=ro',uri=True) as db:
|
||||
@@ -85,7 +87,9 @@ def upgrade(payload):
|
||||
cmd=['/usr/bin/python3','-I',str(provider)]
|
||||
runtime=json.loads(run(cmd+['inspect-runtime']));runtime_sha=sha(json.dumps(runtime,sort_keys=True,separators=(',',':'),ensure_ascii=True).encode())
|
||||
old_config['apt_provider']['runtime_sha256']=runtime_sha
|
||||
require(old_config['apt_provider']['apt_config_sha256']==sha(run(cmd+['print-config'])),'unchanged APT config required')
|
||||
config_sha=sha(run(cmd+['print-config']))
|
||||
require(config_sha==payload['reviewed_config_sha256'],'reviewed APT config required')
|
||||
old_config['apt_provider']['apt_config_sha256']=config_sha
|
||||
create(config,json.dumps(old_config).encode())
|
||||
pin=json.loads(run([str(binary),'--inspect-apt-profile'],env=dict(os.environ,RMM_HELPER_CONFIG=str(config))))
|
||||
require(pin['identity']==old_general['identity'],'helper identity changed')
|
||||
@@ -94,7 +98,7 @@ def upgrade(payload):
|
||||
require(general==old_general,'general policy changed')
|
||||
require(all(manifest(Path(p))==v for p,v in preserved.items()) and markers[0].read_bytes()==marker and
|
||||
(ledger.stat().st_dev,ledger.stat().st_ino)==inode,'preserved identity/attempt/ledger changed')
|
||||
report.update(stage='installed_preserved',preserved_state=True,runtime_sha256=runtime_sha,apt_pin=pin,general_pin=general);save()
|
||||
report.update(stage='installed_preserved',preserved_state=True,runtime_sha256=runtime_sha,apt_config_sha256=config_sha,apt_pin=pin,general_pin=general);save()
|
||||
fcntl.flock(lockfd,fcntl.LOCK_UN);os.close(lockfd);lockfd=None
|
||||
run(['systemd-analyze','verify','/etc/systemd/system/rmm-apt-helper.service'])
|
||||
run(['systemctl','daemon-reload'])
|
||||
@@ -120,16 +124,47 @@ def upgrade(payload):
|
||||
return dict(report,backup=str(backup))
|
||||
|
||||
|
||||
def installed_metadata(payload):
|
||||
paths=('/usr/local/libexec/rmm-privileged-helper','/usr/lib/rmm-apt-transaction/apt_transaction.py',
|
||||
'/etc/systemd/system/rmm-apt-helper.service','/etc/rmm/apt-helper.json','/etc/rmm-remote/apt-helper-proof.json')
|
||||
values={name:hashlib.sha256(Path(name).read_bytes()).hexdigest() for name in paths}
|
||||
require(values[paths[0]]==payload['helper_sha256'] and values[paths[1]]==payload['provider_sha256'],'previous reviewed artifacts drifted')
|
||||
require(json.loads(Path(paths[3]).read_text())['apt_provider']['runtime_sha256']==payload['runtime_sha256'] and
|
||||
json.loads(Path(paths[4]).read_text())==payload['apt_pin'],'previous independent runtime/proof drifted')
|
||||
return dict(files=values)
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser();parser.add_argument('--local-file-fix',action='store_true');args=parser.parse_args()
|
||||
os.umask(0o077);m=cloud.contract
|
||||
require(followup.evidence('gate')['unresolved']==0,'unresolved central job')
|
||||
diagnosis=m.protected_json(followup.STATE/'diagnosis/checkpoint.json');require(diagnosis.get('verified') is True,'diagnostic evidence required')
|
||||
preflights=list(followup.STATE.glob('preflight-*.json'));require(len(preflights)==1,'one reviewed installed baseline')
|
||||
old=m.protected_json(preflights[0]);artifact=(followup.STATE/'helper-sandbox-fixed').read_bytes()
|
||||
reports=list(followup.STATE.glob('sandbox-*.json'))
|
||||
if args.local_file_fix:
|
||||
require(len(reports)==1,'exact prior successful sandbox upgrade required; never repeat migration')
|
||||
prior=m.protected_json(reports[0]);require(prior['completed'] is True,'previous migration incomplete')
|
||||
pins=m.protected_json(followup.STATE/'provider-before-local-file-fix.json')
|
||||
old=cloud.bootstrap.rpc('linux-vm.conf',installed_metadata,dict(pins,runtime_sha256=prior['runtime_sha256'],apt_pin=prior['apt_pin']))
|
||||
artifact=(followup.STATE/'helper-local-file-fixed').read_bytes()
|
||||
folders=[cloud.ROOT/'devstate/cloud-root/cases'/name for name in ('service_setup','service_start','service_stop','apt_native_install')]
|
||||
folders += [followup.STATE/name for name in ('diagnosis','diagnosis-acquisition','diagnosis-hook','diagnosis-local-hook')]
|
||||
expected=[str(uuid.UUID(m.protected_json(p/'checkpoint.json')['result']['result']['grant_id'])) for p in folders]
|
||||
require(len(set(expected))==8,'eight actual completed root attempts required')
|
||||
else:
|
||||
require(not reports,'existing sandbox upgrade retained; no implicit repeat')
|
||||
preflights=list(followup.STATE.glob('preflight-*.json'));require(len(preflights)==1,'one reviewed installed baseline')
|
||||
old=m.protected_json(preflights[0]);artifact=(followup.STATE/'helper-sandbox-fixed').read_bytes()
|
||||
folders=[cloud.ROOT/'devstate/cloud-root/cases'/name for name in ('service_setup','service_start','service_stop','apt_native_install')]+[followup.STATE/'diagnosis']
|
||||
expected=[str(uuid.UUID(m.protected_json(p/'checkpoint.json')['result']['result']['grant_id'])) for p in folders]
|
||||
code=(cloud.ROOT/'tools/apt-transaction/apt_transaction.py').read_bytes()
|
||||
import importlib.util
|
||||
import sys
|
||||
spec=importlib.util.spec_from_file_location('reviewed_apt_provider',cloud.ROOT/'tools/apt-transaction/apt_transaction.py')
|
||||
module=importlib.util.module_from_spec(spec);sys.modules[spec.name]=module;spec.loader.exec_module(module)
|
||||
payload=dict(id=str(uuid.uuid4()),agent_id=followup.identity()['agent_id'],old_files=old['files'],
|
||||
binary=base64.b64encode(artifact).decode(),helper_sha256=hashlib.sha256(artifact).hexdigest(),
|
||||
provider=base64.b64encode(code).decode(),provider_sha256=hashlib.sha256(code).hexdigest(),unit=(cloud.ROOT/'deploy/linux/rmm-apt-helper.service').read_text())
|
||||
provider=base64.b64encode(code).decode(),provider_sha256=hashlib.sha256(code).hexdigest(),unit=(cloud.ROOT/'deploy/linux/rmm-apt-helper.service').read_text(),
|
||||
expected_grants=expected,reviewed_config_sha256=hashlib.sha256(module.apt_config()).hexdigest())
|
||||
result=cloud.bootstrap.rpc('linux-vm.conf',upgrade,payload)
|
||||
m.write_private(followup.STATE/('sandbox-'+payload['id']+'.json'),result)
|
||||
print({k:result.get(k) for k in ('completed','stage','error_class','frames','preserved_state','runtime_sha256','readiness_only')})
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
# Übergabe / Entwicklungspause — 2026-11-12
|
||||
|
||||
**Aktueller Folgestand 2026-11-13:** APT-100-Ursache durch separat WebUI-genehmigte
|
||||
Cloud-Diagnosen belegt: `--no-download` lieferte im echten v3-Hook `**ERROR**`
|
||||
statt Archivpfad. Lokale Dateiacquisition korrigiert; wirkliche IPv4-/IPv6-Sperre
|
||||
zusätzlich geprüft. Neuer Provider/Helper auf Cloud-VM installiert, echter
|
||||
Readiness-Probe bestanden. Acht bekannte Rootversuche, keine offene Wirkung,
|
||||
ursprünglicher Fehlversuchsmarker/`active/` erhalten, kein Paketretry. Root-
|
||||
Diagnosepolicy geschlossen, APT-Helper gestoppt, Linux-Agent online/sync-ready.
|
||||
Paketabnahme benötigt weiterhin sichere Behandlung des gespeicherten Fehlversuchs.
|
||||
|
||||
Windows auf Userwunsch jetzt parallel erlaubt (Spezifikation 1.8). SSH-Zugang
|
||||
zur Windows-11-Pro-VM (Build 26300, x64) mit echtem Administratortoken nativ
|
||||
bestätigt. SYSTEM-Tunnel-Task/sshd Running, Windows-SSH nur Loopback; Cloud-
|
||||
Reverse-Port nicht extern erreichbar. Kein RMM-Windows-Client/Notebook-Agent.
|
||||
Bootstrap/Repair öffentlich gültiges HTTPS8443, befristet bis 2026-11-14
|
||||
12:55:31 UTC, automatisches Schließen des Downloadports vorbereitet/geprüft.
|
||||
Nach jedem Abnahmeschritt Quellen/Dokumentation nach Gitea gepusht; private
|
||||
Daten weiterhin ignoriert. Details: [implementation-status.md](implementation-status.md)
|
||||
und [Windowszugang](../deploy/windows/README.md). Die folgenden Pausentexte und
|
||||
älteren Zwischenstände sind historisch, keine aktuelle Entwicklungsstopanweisung.
|
||||
|
||||
**Historische Übergabe. Wiederaufnahme am 2026-11-13 ausdrücklich beauftragt.**
|
||||
Die lokale Servertopologie wurde inzwischen durch den dedizierten Internetserver
|
||||
ersetzt; aktueller Zustand und Zugänge: [server-deployment.md](server-deployment.md).
|
||||
|
||||
@@ -1,5 +1,58 @@
|
||||
# Tatsächlicher Implementierungsstand
|
||||
|
||||
## Providerkorrektur und erneute native Readiness bestanden — 2026-11-13
|
||||
|
||||
Korrektur in `tools/apt-transaction/apt_transaction.py`: feste lokale
|
||||
Dateiacquisition zulassen, `--no-download` entfernt. Keine globale Quelle,
|
||||
kein URLparameter, keine Abschwächung von Manifest-/Byte-/Pfad-/Hash-/Zeit-
|
||||
oder Genehmigungsgates. `**ERROR**` bleibt Veto. Statt auf ein CLI-Flag zu
|
||||
vertrauen prüfen Worker, Hook und Readonly-Probe jetzt wirklich, dass sowohl
|
||||
IPv4- als auch IPv6-Socketerzeugung vom Kernel verweigert wird. Erlaubter Socket
|
||||
oder unklarer Ressourcenfehler führt zum Veto. AF_UNIX-only/PrivateNetwork und
|
||||
private Net-/PID-/Mountnamespaces bleiben unverändert.
|
||||
|
||||
Neues Release gebaut und auf tatsächlicher Cloud-VM kontrolliert installiert:
|
||||
`python3 deploy/cloud_apt_sandbox_upgrade.py --local-file-fix`. Upgrade vergleicht
|
||||
jetzt die **exakte Menge der acht bekannten abgeschlossenen Grant-IDs**, statt
|
||||
lediglich einen Zähler zu prüfen. Alte Provider-/Helperbytes, Runtime und
|
||||
unabhängiger Pin gegen vorherige geprüfte Installation gebunden. Beide
|
||||
Agentjournale, Rootledger-Inode/Bytes vor Start, kompletter alter `active/`,
|
||||
Archive/Baselines/History und ursprünglicher Versuchsmarker erhalten.
|
||||
|
||||
Tatsächlicher neuer Readiness-Probe unter unverändertem dediziertem APT-
|
||||
Serviceprofil bestanden, einschließlich neuer IP-Denial-Prüfung und maskierter
|
||||
Cloud-Identitätspfade. Zehn stabile Starts ohne Restart; keine Pakettransaktion,
|
||||
kein neuer Acceptancebeleg. Aktuelle Messwerte:
|
||||
|
||||
- Helper `e824de1cff4a1f2a2f176fd1f5d4a48df7ac3c50ef9a10974a858e92f21e3ca6`.
|
||||
- Provider `00fef95f73edb781f0cfb92c8f4b6c3b3ef11cd4cfd063df30952507333b7059`.
|
||||
- APT-Config `1d00a6d01c4ba0ae72e5e7fb85e170f2358cccd534ef060f2e8368268dae6941`.
|
||||
- Runtime `27917dc46bb746607b1789e9cb2ba42241ab699b5569752de7d9a6ab0993c249`.
|
||||
- Stackpin `152469399b06e2e834c81c38273d7e0cfd9ac2bd5b7f8991a0774a0cf758e8b1`.
|
||||
|
||||
Abschließend Diagnosepolicy ausdrücklich geschlossen; APT-Daemon inaktiv,
|
||||
allgemeiner Helper/Linux-Agent aktiv, signierter Sync ready, Restoreblock false.
|
||||
Rootledger **8 consumed / 0 unresolved / 0 faults**, Integrität ok; Fixture
|
||||
nicht installiert. Zentrale **12/12/11**, keine ungeklärten Jobs. Windows
|
||||
sshd/Tunnel-Task tatsächlich Running, Listener ausschließlich `127.0.0.1`;
|
||||
Cloud-Reverseport extern nicht erreichbar geprüft. Geschützte Abschlussbelege:
|
||||
`devstate/cloud-apt-followup/final-*.json`, `sandbox-*.json` und
|
||||
`devstate/windows-bootstrap/windows-final-state.json`.
|
||||
|
||||
**62 Python-APT-Tests**, **8 Cloud-Guards**, **4 Download-Guards**, **28 MVP-Guards**,
|
||||
**3 Bootstrap-Guards** bestanden. Ein erster Mock-Kernel-Test modellierte die neue
|
||||
AF-Sperre noch nicht und schlug korrekt fehl; Mock um tatsächliche Socket-Denials
|
||||
ergänzt, separate Positiv-/Negativtests für beide Familien und EMFILE bestanden.
|
||||
Helper all-targets mit neu eingebettetem Provider: **25 Library / 3 Binary /
|
||||
20 Sync** bestanden; Builds ausschließlich auf Entwicklungsrechner im isolierten
|
||||
Container. Native Probe separat auf Cloud-VM, keine Vermischung der Nachweise.
|
||||
|
||||
**Weiter offen:** eigentliche Fixtureinstallation/Upgrade/EnsurePackage/
|
||||
ApplyUpdates. Create-once-Marker des alten fehlgeschlagenen Versuchs bleibt;
|
||||
kontrollierte signierte Wiederaufnahme ist Voraussetzung eines neuen festen
|
||||
WebUI-genehmigten Paketversuchs, keine Marker-/Ledger-/Identitätslöschung.
|
||||
Kein Linux-MVP-/Produktionsabschluss, kein RMM-Windows-Client behauptet.
|
||||
|
||||
## Ursache von APT Exit 100 durch echten Hookvergleich belegt — 2026-11-13
|
||||
|
||||
Zwei separat tatsächlich WebUI-genehmigte Hookdiagnosen auf der Cloud-VM:
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
# Dedizierter RMM-Server
|
||||
|
||||
Stand: 2026-11-13 · Spezifikation 1.7 · Linux-MVP weiterhin nicht abgenommen.
|
||||
Stand: 2026-11-13 · Spezifikation 1.8 · Linux-MVP weiterhin nicht abgenommen.
|
||||
|
||||
## Neuester APT-/Bootstrapstand
|
||||
|
||||
APT-Ursache und Sourcekorrektur nativ eingegrenzt/geprüft: `--no-download`
|
||||
verhinderte die lokale Archivpfadauflösung, echter Hook meldete `**ERROR**`.
|
||||
Lokale Acquisition erlaubt, echte IP-Socketsperre in Worker/Hook/Probe geprüft;
|
||||
neuer Readiness-Probe auf Cloud-VM bestanden. Rootledger acht bekannte geschlossene
|
||||
Versuche, ursprünglicher Fehlversuch/Marker erhalten; kein Paketretry/Acceptance.
|
||||
Gesamt **12 Jobs / 12 Outbox / 11 Grants**, keine ungeklärten Jobs.
|
||||
Root-Diagnosepolicy geschlossen, APT-Daemon gestoppt, Linux-Agent online/sync-ready.
|
||||
Ausführliche Befehle/Tests/Hashes: [implementation-status.md](implementation-status.md).
|
||||
|
||||
User erlaubt nun Windows parallel vor Linux-MVP-Abnahme. Eigenständiger Windows-
|
||||
Gast auf Notebook per ausgehendem SSH-Bootstrap-Reversetunnel erreichbar;
|
||||
Notebook-Host bleibt ohne Agent. Windows-SSH `127.0.0.1:22222`, Cloud-Reverseport
|
||||
`127.0.0.1:22240`, extern nicht erreichbar; eigenes forwarding-only Konto mit
|
||||
befristetem VM-generiertem Schlüssel. Windows-Adminzugang nativ bestätigt,
|
||||
noch kein RMM-Windows-Agent/Enrollment. Details: [Windowszugang](../deploy/windows/README.md).
|
||||
|
||||
Zusätzlich auf ausdrücklichen Userwunsch befristeter Public-only Bootstrap-
|
||||
Download über **8443/TLS mit öffentlicher Let's-Encrypt-Kette**. Keine Änderung
|
||||
an Projekt-TLS/mTLS auf 443, keine öffentliche Verwaltung. HTTP80 nur für ACME
|
||||
benutzt und danach wieder geschlossen. Downloadfreigabe und Firewall8443 enden
|
||||
per aktivem Ablauf-Timer am **2026-11-14 12:55:31 UTC**. Die untenstehenden
|
||||
Port-/Hash-/Zählersnapshots sind ältere Zwischenstände.
|
||||
|
||||
## Verbindlicher Auftrag
|
||||
|
||||
@@ -13,7 +38,9 @@ Cloudserver als Server, dieses Notebook ausschließlich zur Entwicklung.
|
||||
Hier keinen RMM-Client installieren, enrollen oder betreiben. Die frühere Aussage
|
||||
zum lokalen Notebook-Client ist überstimmt. Cloud-VM und später beauftragte
|
||||
weitere Agenten verwenden diesen Server direkt ausgehend. Ein
|
||||
PC→Test-VM-Reversetunnel gehört nicht mehr zum vorgesehenen Verbindungsweg.
|
||||
PC→Linux-Test-VM-Reversetunnel gehört nicht mehr zum vorgesehenen RMM-Verbindungsweg.
|
||||
Der oben genannte Windows→Cloud-Reversetunnel ist ausschließlich der neu
|
||||
beauftragte SSH-Bootstraptransport.
|
||||
|
||||
Die Maschine ist aus dem Internet erreichbar. Öffentlich nur ausdrücklich
|
||||
eingerichtete Endpunkte anbieten: Agent-TLS mit geprüfter Serverkette und nach
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import hashlib
|
||||
import errno
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
@@ -269,12 +270,34 @@ print('FILTER_LOADED')
|
||||
def test_exact_argv_config_and_fixed_hook(self):
|
||||
tx = apt.ResolvedAptTransaction.parse(transaction())
|
||||
argv = apt.apt_argv(tx)
|
||||
self.assertIn('--no-download', argv)
|
||||
self.assertNotIn('--no-download', argv) # real v3 otherwise reports **ERROR**
|
||||
self.assertIn('--no-remove', argv)
|
||||
self.assertNotIn('update', argv)
|
||||
self.assertEqual(argv[-1], tx.packages[0].archive_path)
|
||||
self.assertEqual((ROOT / 'tools/apt-transaction/hook').read_bytes(), apt.hook_script())
|
||||
self.assertIn(b'Dir::Etc::parts', apt.apt_config())
|
||||
self.assertIn(b'APT::Get::Download "true";', apt.apt_config())
|
||||
|
||||
def test_ip_socket_denials_are_required_for_both_families(self):
|
||||
with patch.object(apt.socket, 'socket', side_effect=OSError(errno.EAFNOSUPPORT, 'synthetic')) as make:
|
||||
apt.verify_no_ip_sockets()
|
||||
self.assertEqual([call.args[0] for call in make.call_args_list], [apt.socket.AF_INET, apt.socket.AF_INET6])
|
||||
|
||||
def test_permitted_ipv4_socket_closes_and_vetoes(self):
|
||||
closed=[];candidate=SimpleNamespace(close=lambda:closed.append(True))
|
||||
with patch.object(apt.socket, 'socket', return_value=candidate):
|
||||
with self.assertRaisesRegex(apt.Veto, 'SANDBOX_IP_SOCKET_ALLOWED'):apt.verify_no_ip_sockets()
|
||||
self.assertEqual(closed,[True])
|
||||
|
||||
def test_permitted_ipv6_cannot_hide_behind_denied_ipv4(self):
|
||||
closed=[];candidate=SimpleNamespace(close=lambda:closed.append(True))
|
||||
with patch.object(apt.socket, 'socket', side_effect=[OSError(errno.EPERM,'synthetic'),candidate]):
|
||||
with self.assertRaisesRegex(apt.Veto, 'SANDBOX_IP_SOCKET_ALLOWED'):apt.verify_no_ip_sockets()
|
||||
self.assertEqual(closed,[True])
|
||||
|
||||
def test_resource_exhaustion_is_not_a_network_denial_proof(self):
|
||||
with patch.object(apt.socket, 'socket', side_effect=OSError(errno.EMFILE,'synthetic')):
|
||||
with self.assertRaisesRegex(apt.Veto, 'SANDBOX_IP_SOCKET_CHECK'):apt.verify_no_ip_sockets()
|
||||
|
||||
|
||||
class FixtureTests(unittest.TestCase):
|
||||
|
||||
@@ -200,6 +200,7 @@ class NativeProbeTests(TestCase):
|
||||
patch.object(apt.os, 'readlink', return_value='host' if scenario == 'namespace' else 'child'), \
|
||||
patch.object(apt, 'invalid_control_syscall_probes', return_value=prechecks(context())['checks']['control_syscalls']), \
|
||||
patch.object(apt, 'frontend_lock_probe', return_value='native-apt-check-conflict'), \
|
||||
patch.object(apt.socket, 'socket', side_effect=OSError(apt.errno.EAFNOSUPPORT, 'mocked kernel denial')), \
|
||||
patch.object(apt.VerifiedHelperContext, 'check_deadline'):
|
||||
self.assertEqual(apt.native_prechecks(context()), prechecks(context()))
|
||||
|
||||
|
||||
@@ -265,10 +265,17 @@ Both modes run the same pipeline:
|
||||
probe. Never delete locks, kill owners or use simulation to prove locking.
|
||||
A busy foreign lock vetoes the bootstrap. Release only this process's fd.
|
||||
7. Fsync native-prechecks record, then sandbox-ready marker. Native APT uses
|
||||
exact local archives, `--no-download --no-remove --no-install-recommends` and
|
||||
exact local archives, `--no-remove --no-install-recommends` and
|
||||
constant isolated config. No global APT hooks/sources/preferences; reviewed
|
||||
dpkg global config is runtime-hash-bound in the signed action. Native foreign
|
||||
lock wait remains bounded to 10 seconds.
|
||||
**2026-11-13 native diagnosis:** `--no-download` prevented APT's local file
|
||||
acquisition and emitted `**ERROR**` instead of the absolute archive filename
|
||||
in protocol v3. The provider permits local acquisition of the presealed
|
||||
archive; the AF_UNIX-only private worker still rejects actual IPv4/IPv6
|
||||
socket creation. Both denials are now checked inside worker/hook/probe.
|
||||
A permitted IP socket or unrelated resource error vetoes; this is not a
|
||||
network-download allowance or acceptance/manifest/hash/path bypass.
|
||||
8. Mandatory v3 pre-dpkg hook repeats signed/runtime/scope/sandbox checks,
|
||||
validates the whole actual action set, actual hashes/control/payload,
|
||||
status/baseline and final deadline; O_EXCL + file/directory fsync effect-armed
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user