Separate SYSTEM policy and verify thirteen policy guards on cloud Linux
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Rust RMM: Architektur und Implementierungsspezifikation
|
# Rust RMM: Architektur und Implementierungsspezifikation
|
||||||
|
|
||||||
Version 1.15 · 2026-11-13 · Sprache: Deutsch
|
Version 1.16 · 2026-11-14 · Sprache: Deutsch
|
||||||
|
|
||||||
**Zweck:** Vollständige, eigenständig nutzbare Grundlage für die Implementierung einer mandantenfähigen Plattform zur Inventarisierung, Überwachung und Fernadministration von Kundengeräten durch eine Coding-KI und ein Entwicklungsteam.
|
**Zweck:** Vollständige, eigenständig nutzbare Grundlage für die Implementierung einer mandantenfähigen Plattform zur Inventarisierung, Überwachung und Fernadministration von Kundengeräten durch eine Coding-KI und ein Entwicklungsteam.
|
||||||
|
|
||||||
@@ -10,6 +10,11 @@ Version 1.15 · 2026-11-13 · Sprache: Deutsch
|
|||||||
|
|
||||||
1.4 → 1.5 (2026-11-12): ausdrücklicher Useroverride „rustdesk musst du nicht machen ... das lasse aus“; RustDesk ist keine Pflicht dieser Umsetzung und keine MVP-Abnahme. Ausschließlich browsergesteuerte dev/test-Bedienung darf mit sichtbar simuliertem Testprincipal menschliche UI-Aktionen nachstellen; keine API-/DB-Freigabeabkürzung. Lokale Serverneustarts ausdrücklich erlaubt, keine impliziten VM-Reboots/Updates/destruktiven Zieltests.
|
1.4 → 1.5 (2026-11-12): ausdrücklicher Useroverride „rustdesk musst du nicht machen ... das lasse aus“; RustDesk ist keine Pflicht dieser Umsetzung und keine MVP-Abnahme. Ausschließlich browsergesteuerte dev/test-Bedienung darf mit sichtbar simuliertem Testprincipal menschliche UI-Aktionen nachstellen; keine API-/DB-Freigabeabkürzung. Lokale Serverneustarts ausdrücklich erlaubt, keine impliziten VM-Reboots/Updates/destruktiven Zieltests.
|
||||||
|
|
||||||
|
1.15 → 1.16 (2026-11-14): Windows-SYSTEM als eigene explizite Identität und
|
||||||
|
`system:execute` mit unabhängiger, standardmäßig verweigernder zentraler und
|
||||||
|
lokaler Helperpolicy präzisiert. Keine Vererbung von Linux-Rootrechten, keine
|
||||||
|
Windowsfähigkeit aus einer bloßen Quellen-/Build-/Linux-Unitqualifikation.
|
||||||
|
|
||||||
## Inhaltsverzeichnis
|
## Inhaltsverzeichnis
|
||||||
|
|
||||||
- [0 Auftrag und verbindliche Produktanforderungen](#0-auftrag-und-verbindliche-produktanforderungen)
|
- [0 Auftrag und verbindliche Produktanforderungen](#0-auftrag-und-verbindliche-produktanforderungen)
|
||||||
@@ -99,6 +104,24 @@ Deploymentdaten, offene Konfiguration und reale Nachweise:
|
|||||||
|
|
||||||
### 0.1 Auftrag an die implementierende KI
|
### 0.1 Auftrag an die implementierende KI
|
||||||
|
|
||||||
|
**Technische Präzisierung Version 1.16 — getrennte Windows-SYSTEM-Grenze:**
|
||||||
|
`execution_identity=system` und `system:execute` sind von Linux-`root` und
|
||||||
|
`root:execute` unabhängig. Planung, Submit, interaktive WebUI-Genehmigung,
|
||||||
|
Revalidation, Zustellung und Start prüfen die jeweilige konkrete Identität und
|
||||||
|
aktuelle Rechte-/Policybindung. Die erste enge SYSTEM-Strecke darf ausschließlich
|
||||||
|
fest benannte eigene Fixturedienste auf `running` oder `stopped` setzen; keine
|
||||||
|
freie SYSTEM-Shell oder implizite Paket-/Log-/Rebootfreigabe. Zentrale Policy
|
||||||
|
bindet Kunde/Gerät/Generationen, Principals, exakte Helperbinary-/Policyhashes
|
||||||
|
und Grenzen. Die lokale SYSTEM-Helperpolicy prüft den vollständigen signierten
|
||||||
|
Originalauftrag unabhängig. Beide verweigern ohne erfolgreiche Qualifikation,
|
||||||
|
TrustedClock und bestätigten signierten Agent-/Helpersync. Ein Startgrant
|
||||||
|
benötigt einen tatsächlich vorhandenen unabhängigen Helperjournalbezug, kein
|
||||||
|
Legacy-Readyflag. Source- oder Unitnachweise eröffnen keine Fähigkeit oder
|
||||||
|
Genehmigung. Standard bleibt deaktiviert; eigene Windows-VM-/WebUI-Abnahmen
|
||||||
|
sind erforderlich. Bestehende Linux-Job-/Grantbytes und die allgemeine
|
||||||
|
`pending_approval`-/WebUI-Grenze bleiben unverändert. Implementierungsstände
|
||||||
|
werden in `docs/windows-system-policy.md` getrennt von diesem Vertrag berichtet.
|
||||||
|
|
||||||
**Technische Präzisierung Version 1.15 — endliche Journalbudgets:**
|
**Technische Präzisierung Version 1.15 — endliche Journalbudgets:**
|
||||||
Agentjournal sowie Agent-/Helper-Verbrauchsledger erhalten pro SQLite-Datei
|
Agentjournal sowie Agent-/Helper-Verbrauchsledger erhalten pro SQLite-Datei
|
||||||
maximal1GiB bei geprüften4096-Byte-Seiten (262144Seiten). Die früheren festen
|
maximal1GiB bei geprüften4096-Byte-Seiten (262144Seiten). Die früheren festen
|
||||||
|
|||||||
@@ -317,9 +317,9 @@ pub async fn permit(
|
|||||||
if !payload.action.validate() {
|
if !payload.action.validate() {
|
||||||
return Ok(denied("APT_MANIFEST_REQUIRED"));
|
return Ok(denied("APT_MANIFEST_REQUIRED"));
|
||||||
}
|
}
|
||||||
if payload.execution_identity == "root" {
|
if crate::root_policy::needs_helper(&payload.execution_identity) {
|
||||||
let helper_ready: bool = sqlx::query_scalar(
|
let helper_ready: bool = sqlx::query_scalar(
|
||||||
"SELECT helper_sync_ready FROM agent_installations WHERE agent_id=$1",
|
"SELECT i.helper_sync_ready AND EXISTS(SELECT 1 FROM agent_sync_state s WHERE s.tenant_id=i.tenant_id AND s.agent_id=i.agent_id AND s.helper_journal_id IS NOT NULL) FROM agent_installations i WHERE i.agent_id=$1",
|
||||||
)
|
)
|
||||||
.bind(agent)
|
.bind(agent)
|
||||||
.fetch_one(&mut *tx)
|
.fetch_one(&mut *tx)
|
||||||
@@ -332,7 +332,11 @@ pub async fn permit(
|
|||||||
.await
|
.await
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
return Ok(denied("ROOT_SCOPE_OR_HELPER_SYNC_REQUIRED"));
|
return Ok(denied(if payload.execution_identity == "system" {
|
||||||
|
"SYSTEM_SCOPE_OR_HELPER_SYNC_REQUIRED"
|
||||||
|
} else {
|
||||||
|
"ROOT_SCOPE_OR_HELPER_SYNC_REQUIRED"
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let sync: (bool, bool) = sqlx::query_as(
|
let sync: (bool, bool) = sqlx::query_as(
|
||||||
@@ -497,7 +501,7 @@ pub async fn next(
|
|||||||
if let Some(r)=sqlx::query("SELECT job_id,attempt_id FROM jobs WHERE agent_id=$1 AND cancel_requested AND state IN ('accepted','running','verifying','awaiting_reboot') ORDER BY job_id LIMIT 1").bind(agent).fetch_optional(&mut *tx).await?{
|
if let Some(r)=sqlx::query("SELECT job_id,attempt_id FROM jobs WHERE agent_id=$1 AND cancel_requested AND state IN ('accepted','running','verifying','awaiting_reboot') ORDER BY job_id LIMIT 1").bind(agent).fetch_optional(&mut *tx).await?{
|
||||||
tx.commit().await?;return Ok(Some(Payload::CancelRequest(CancelRequest{job_id:r.get::<Uuid,_>("job_id").to_string(),attempt_id:r.get::<Uuid,_>("attempt_id").to_string(),reason:"operator_cancel_requested".into()})))
|
tx.commit().await?;return Ok(Some(Payload::CancelRequest(CancelRequest{job_id:r.get::<Uuid,_>("job_id").to_string(),attempt_id:r.get::<Uuid,_>("attempt_id").to_string(),reason:"operator_cancel_requested".into()})))
|
||||||
}
|
}
|
||||||
let row=sqlx::query("SELECT j.job_id,j.attempt_id,j.payload,j.payload_hash,a.authorization_id,p.plan_hash,i.capabilities FROM outbox b JOIN jobs j USING(tenant_id,job_id,attempt_id) JOIN operations o ON o.tenant_id=j.tenant_id AND o.operation_id=j.operation_id JOIN authorizations a ON a.tenant_id=o.tenant_id AND a.authorization_id=o.authorization_id JOIN approval_requests r ON r.tenant_id=j.tenant_id AND r.operation_id=j.operation_id JOIN operation_plans p ON p.tenant_id=j.tenant_id AND p.plan_id=r.plan_id JOIN tenants t ON t.tenant_id=j.tenant_id JOIN agent_installations i ON i.tenant_id=j.tenant_id AND i.agent_id=j.agent_id WHERE j.agent_id=$1 AND j.state='queued' AND NOT j.cancel_requested AND NOT t.changes_stopped AND a.revoked_at IS NULL AND r.approval_state='approved' AND p.expires_at>now() AND b.acknowledged_at IS NULL AND (b.lease_until IS NULL OR b.lease_until<now()) ORDER BY j.job_id FOR UPDATE OF b SKIP LOCKED LIMIT 1").bind(agent).fetch_optional(&mut *tx).await?;
|
let row=sqlx::query("SELECT j.job_id,j.attempt_id,j.payload,j.payload_hash,a.authorization_id,a.principal AS approver,p.plan_hash,p.payload AS plan_payload,i.capabilities FROM outbox b JOIN jobs j USING(tenant_id,job_id,attempt_id) JOIN operations o ON o.tenant_id=j.tenant_id AND o.operation_id=j.operation_id JOIN authorizations a ON a.tenant_id=o.tenant_id AND a.authorization_id=o.authorization_id JOIN approval_requests r ON r.tenant_id=j.tenant_id AND r.operation_id=j.operation_id JOIN operation_plans p ON p.tenant_id=j.tenant_id AND p.plan_id=r.plan_id JOIN tenants t ON t.tenant_id=j.tenant_id JOIN agent_installations i ON i.tenant_id=j.tenant_id AND i.agent_id=j.agent_id WHERE j.agent_id=$1 AND j.state='queued' AND NOT j.cancel_requested AND NOT t.changes_stopped AND a.revoked_at IS NULL AND r.approval_state='approved' AND p.expires_at>now() AND b.acknowledged_at IS NULL AND (b.lease_until IS NULL OR b.lease_until<now()) ORDER BY j.job_id FOR UPDATE OF b SKIP LOCKED LIMIT 1").bind(agent).fetch_optional(&mut *tx).await?;
|
||||||
let Some(row) = row else {
|
let Some(row) = row else {
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
@@ -511,6 +515,19 @@ pub async fn next(
|
|||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
if crate::root_policy::needs_helper(&payload.execution_identity) {
|
||||||
|
let plan: PlanPayload = serde_json::from_slice(&row.get::<Vec<u8>, _>("plan_payload"))?;
|
||||||
|
if crate::root_policy::authorize(&mut tx, &plan.principal, &payload)
|
||||||
|
.await
|
||||||
|
.is_err()
|
||||||
|
|| crate::root_policy::authorize(&mut tx, &row.get::<String, _>("approver"), &payload)
|
||||||
|
.await
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
tx.commit().await?;
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
}
|
||||||
sqlx::query("UPDATE outbox SET lease_until=now()+interval '30 seconds' WHERE job_id=$1")
|
sqlx::query("UPDATE outbox SET lease_until=now()+interval '30 seconds' WHERE job_id=$1")
|
||||||
.bind(row.get::<Uuid, _>("job_id"))
|
.bind(row.get::<Uuid, _>("job_id"))
|
||||||
.execute(&mut *tx)
|
.execute(&mut *tx)
|
||||||
|
|||||||
@@ -384,7 +384,10 @@ pub async fn plan(
|
|||||||
if input.targets.asset_ids.is_empty()
|
if input.targets.asset_ids.is_empty()
|
||||||
|| input.targets.asset_ids.len() > 100
|
|| input.targets.asset_ids.len() > 100
|
||||||
|| !input.action.validate_plan_shape()
|
|| !input.action.validate_plan_shape()
|
||||||
|| !matches!(input.execution_identity.as_str(), "agent_service" | "root")
|
|| !matches!(
|
||||||
|
input.execution_identity.as_str(),
|
||||||
|
"agent_service" | "root" | "system"
|
||||||
|
)
|
||||||
|| !(1..=3600).contains(&input.max_runtime_seconds)
|
|| !(1..=3600).contains(&input.max_runtime_seconds)
|
||||||
|| input.max_output_bytes == 0
|
|| input.max_output_bytes == 0
|
||||||
|| input.max_output_bytes > 262144
|
|| input.max_output_bytes > 262144
|
||||||
@@ -423,8 +426,8 @@ pub async fn plan(
|
|||||||
let mut tx = rmm_persistence::tenant_tx(&state.pool, tenant).await?;
|
let mut tx = rmm_persistence::tenant_tx(&state.pool, tenant).await?;
|
||||||
policy(&mut tx).await?;
|
policy(&mut tx).await?;
|
||||||
crate::permissions::require_principal(&mut tx, p, "operations:plan").await?;
|
crate::permissions::require_principal(&mut tx, p, "operations:plan").await?;
|
||||||
if input.execution_identity == "root" && !p.permits_scope("root:execute") {
|
if let Some(permission) = crate::root_policy::execution_permission(&input.execution_identity) {
|
||||||
return Err(Error(StatusCode::FORBIDDEN, "FORBIDDEN"));
|
crate::permissions::require_principal(&mut tx, p, permission).await?;
|
||||||
}
|
}
|
||||||
if matches!(input.action, Action::AptNativeAcceptance { .. }) {
|
if matches!(input.action, Action::AptNativeAcceptance { .. }) {
|
||||||
crate::permissions::require_principal(&mut tx, p, "apt:native_acceptance").await?;
|
crate::permissions::require_principal(&mut tx, p, "apt:native_acceptance").await?;
|
||||||
@@ -661,8 +664,11 @@ pub async fn submit(
|
|||||||
if matches!(job.payload.action, Action::QueryLogs { .. }) {
|
if matches!(job.payload.action, Action::QueryLogs { .. }) {
|
||||||
crate::permissions::require_principal(&mut tx, p, "logs:read").await?;
|
crate::permissions::require_principal(&mut tx, p, "logs:read").await?;
|
||||||
}
|
}
|
||||||
if job.payload.execution_identity == "root" {
|
if let Some(permission) =
|
||||||
crate::permissions::require_principal(&mut tx, p, "root:execute").await?;
|
crate::root_policy::execution_permission(&job.payload.execution_identity)
|
||||||
|
{
|
||||||
|
crate::permissions::require_principal(&mut tx, p, permission).await?;
|
||||||
|
crate::root_policy::authorize(&mut tx, &p.name, &job.payload).await?;
|
||||||
}
|
}
|
||||||
if matches!(job.payload.action, Action::AptNativeAcceptance { .. }) {
|
if matches!(job.payload.action, Action::AptNativeAcceptance { .. }) {
|
||||||
crate::permissions::require_principal(&mut tx, p, "apt:native_acceptance").await?;
|
crate::permissions::require_principal(&mut tx, p, "apt:native_acceptance").await?;
|
||||||
@@ -763,6 +769,11 @@ async fn authorize_http(
|
|||||||
return Err(fail("AUTHORIZATION_REVOKED"));
|
return Err(fail("AUTHORIZATION_REVOKED"));
|
||||||
}
|
}
|
||||||
for job in &plan.jobs {
|
for job in &plan.jobs {
|
||||||
|
if let Some(permission) =
|
||||||
|
crate::root_policy::execution_permission(&job.payload.execution_identity)
|
||||||
|
{
|
||||||
|
crate::permissions::require_principal(&mut tx, &p, permission).await?;
|
||||||
|
}
|
||||||
crate::root_policy::authorize(&mut tx, &p.name, &job.payload).await?;
|
crate::root_policy::authorize(&mut tx, &p.name, &job.payload).await?;
|
||||||
}
|
}
|
||||||
let authorization = Uuid::new_v4();
|
let authorization = Uuid::new_v4();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ mod root_policy;
|
|||||||
mod scheduler;
|
mod scheduler;
|
||||||
mod synchronization;
|
mod synchronization;
|
||||||
mod tls;
|
mod tls;
|
||||||
|
mod windows_policy;
|
||||||
|
|
||||||
use anyhow::{Context, Result, ensure};
|
use anyhow::{Context, Result, ensure};
|
||||||
use axum::{
|
use axum::{
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ impl RootScope {
|
|||||||
capabilities: &[String],
|
capabilities: &[String],
|
||||||
global_log_units: Option<&[String]>,
|
global_log_units: Option<&[String]>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if job.execution_identity != "root" {
|
if job.execution_identity != "root" || capabilities.iter().any(|c| c == "windows.base/1") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if !self.matches_target(job)
|
if !self.matches_target(job)
|
||||||
@@ -279,13 +279,26 @@ fn load() -> Result<RootPolicy, Error> {
|
|||||||
}
|
}
|
||||||
Ok(policy)
|
Ok(policy)
|
||||||
}
|
}
|
||||||
|
pub fn execution_permission(identity: &str) -> Option<&'static str> {
|
||||||
|
match identity {
|
||||||
|
"root" => Some("root:execute"),
|
||||||
|
"system" => Some("system:execute"),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn needs_helper(identity: &str) -> bool {
|
||||||
|
execution_permission(identity).is_some()
|
||||||
|
}
|
||||||
pub async fn authorize(
|
pub async fn authorize(
|
||||||
tx: &mut Transaction<'_, Postgres>,
|
tx: &mut Transaction<'_, Postgres>,
|
||||||
principal: &str,
|
principal: &str,
|
||||||
job: &JobPayload,
|
job: &JobPayload,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if job.execution_identity != "root" {
|
match job.execution_identity.as_str() {
|
||||||
return Ok(());
|
"system" => return crate::windows_policy::authorize(tx, principal, job).await,
|
||||||
|
"agent_service" => return Ok(()),
|
||||||
|
"root" => {}
|
||||||
|
_ => return Err(Error(StatusCode::FORBIDDEN, "EXECUTION_IDENTITY_DENIED")),
|
||||||
}
|
}
|
||||||
for permission in required_permissions(job, false) {
|
for permission in required_permissions(job, false) {
|
||||||
crate::permissions::require(tx, principal, permission).await?;
|
crate::permissions::require(tx, principal, permission).await?;
|
||||||
@@ -375,6 +388,9 @@ mod tests {
|
|||||||
assert!(scope.permits("selected", &job, &caps, None));
|
assert!(scope.permits("selected", &job, &caps, None));
|
||||||
assert!(!scope.permits("automation", &job, &caps, None));
|
assert!(!scope.permits("automation", &job, &caps, None));
|
||||||
assert!(!scope.permits("selected", &job, &caps[..4], None));
|
assert!(!scope.permits("selected", &job, &caps[..4], None));
|
||||||
|
let mut windows = caps;
|
||||||
|
windows.push("windows.base/1".into());
|
||||||
|
assert!(!scope.permits("selected", &job, &windows, None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -504,6 +504,11 @@ pub async fn reconcile(
|
|||||||
decisions.push(decision);
|
decisions.push(decision);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let missing_helper =
|
||||||
|
crate::root_policy::needs_helper(&payload.execution_identity) && !helper_ready;
|
||||||
|
if missing_helper {
|
||||||
|
ready = false;
|
||||||
|
}
|
||||||
let grant = sqlx::query(
|
let grant = sqlx::query(
|
||||||
"SELECT grant_id,payload,created_at FROM execution_permits WHERE job_id=$1 AND attempt_id=$2",
|
"SELECT grant_id,payload,created_at FROM execution_permits WHERE job_id=$1 AND attempt_id=$2",
|
||||||
)
|
)
|
||||||
@@ -720,8 +725,7 @@ pub async fn reconcile(
|
|||||||
}
|
}
|
||||||
.into();
|
.into();
|
||||||
}
|
}
|
||||||
if payload.execution_identity == "root" && !helper_ready {
|
if missing_helper {
|
||||||
ready = false;
|
|
||||||
decision.unlock = false;
|
decision.unlock = false;
|
||||||
decision.reason = "HELPER_JOURNAL_REQUIRED".into();
|
decision.reason = "HELPER_JOURNAL_REQUIRED".into();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,453 @@
|
|||||||
|
//! Independent development-only Windows SYSTEM ceiling. Policy never approves a
|
||||||
|
//! plan, publishes a capability, provisions a helper or substitutes for Sync.
|
||||||
|
use crate::jobs::Error;
|
||||||
|
use axum::http::StatusCode;
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
use rmm_domain::jobs::{Action, JobPayload};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use sqlx::{Postgres, Transaction};
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
io::Read,
|
||||||
|
os::unix::fs::{MetadataExt, PermissionsExt},
|
||||||
|
path::Path,
|
||||||
|
};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
const POLICY_LIMIT: u64 = 65536;
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
struct SystemPolicy {
|
||||||
|
schema_version: u32,
|
||||||
|
profile: String,
|
||||||
|
expires_at: DateTime<Utc>,
|
||||||
|
scopes: Vec<SystemScope>,
|
||||||
|
}
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
struct SystemScope {
|
||||||
|
tenant_id: Uuid,
|
||||||
|
asset_id: Uuid,
|
||||||
|
agent_id: Uuid,
|
||||||
|
enrollment_generation: u64,
|
||||||
|
assignment_version: u64,
|
||||||
|
principals: Vec<String>,
|
||||||
|
helper_policy_sha256: String,
|
||||||
|
helper_binary_sha256: String,
|
||||||
|
// Administrative evidence pin, never an approval or authorization ID.
|
||||||
|
acceptance_evidence_id: Uuid,
|
||||||
|
allowed_services: Vec<String>,
|
||||||
|
max_runtime_seconds: u32,
|
||||||
|
}
|
||||||
|
fn digest(value: &str) -> bool {
|
||||||
|
value.len() == 64
|
||||||
|
&& value
|
||||||
|
.bytes()
|
||||||
|
.all(|c| c.is_ascii_digit() || b"abcdef".contains(&c))
|
||||||
|
}
|
||||||
|
fn fixture_service(name: &str) -> bool {
|
||||||
|
name.starts_with("RmmDiscoveryFixture")
|
||||||
|
&& name.len() > "RmmDiscoveryFixture".len()
|
||||||
|
&& name.len() <= 80
|
||||||
|
&& name
|
||||||
|
.bytes()
|
||||||
|
.all(|c| c.is_ascii_alphanumeric() || b"_-".contains(&c))
|
||||||
|
}
|
||||||
|
impl SystemScope {
|
||||||
|
fn valid(&self) -> bool {
|
||||||
|
!self.tenant_id.is_nil()
|
||||||
|
&& !self.asset_id.is_nil()
|
||||||
|
&& !self.agent_id.is_nil()
|
||||||
|
&& self.enrollment_generation > 0
|
||||||
|
&& self.assignment_version > 0
|
||||||
|
&& !self.acceptance_evidence_id.is_nil()
|
||||||
|
&& digest(&self.helper_policy_sha256)
|
||||||
|
&& digest(&self.helper_binary_sha256)
|
||||||
|
&& !self.principals.is_empty()
|
||||||
|
&& self.principals.len() <= 64
|
||||||
|
&& self
|
||||||
|
.principals
|
||||||
|
.iter()
|
||||||
|
.all(|p| !p.trim().is_empty() && p.len() <= 256)
|
||||||
|
&& self
|
||||||
|
.principals
|
||||||
|
.iter()
|
||||||
|
.collect::<std::collections::BTreeSet<_>>()
|
||||||
|
.len()
|
||||||
|
== self.principals.len()
|
||||||
|
&& self.allowed_services.len() <= 16
|
||||||
|
&& self
|
||||||
|
.allowed_services
|
||||||
|
.iter()
|
||||||
|
.all(|name| fixture_service(name))
|
||||||
|
&& self
|
||||||
|
.allowed_services
|
||||||
|
.iter()
|
||||||
|
.collect::<std::collections::BTreeSet<_>>()
|
||||||
|
.len()
|
||||||
|
== self.allowed_services.len()
|
||||||
|
&& (1..=120).contains(&self.max_runtime_seconds)
|
||||||
|
}
|
||||||
|
fn permits(&self, principal: &str, job: &JobPayload, capabilities: &[String]) -> bool {
|
||||||
|
let has = |cap: &str| capabilities.iter().any(|c| c == cap);
|
||||||
|
self.valid()
|
||||||
|
&& job.execution_identity == "system"
|
||||||
|
&& self.tenant_id == job.tenant_id
|
||||||
|
&& self.asset_id == job.asset_id
|
||||||
|
&& self.agent_id == job.agent_id
|
||||||
|
&& self.enrollment_generation == job.enrollment_generation
|
||||||
|
&& self.assignment_version == job.assignment_version
|
||||||
|
&& self.principals.iter().any(|p| p == principal)
|
||||||
|
&& has("windows.base/1")
|
||||||
|
&& !has("linux.base/1")
|
||||||
|
&& has("rmm.sync.v1")
|
||||||
|
&& has("helper.system.v1")
|
||||||
|
&& has(&format!(
|
||||||
|
"helper.policy.sha256:{}",
|
||||||
|
self.helper_policy_sha256
|
||||||
|
))
|
||||||
|
&& has(&format!(
|
||||||
|
"helper.binary.sha256:{}",
|
||||||
|
self.helper_binary_sha256
|
||||||
|
))
|
||||||
|
&& has("system:set_service_state")
|
||||||
|
&& has("set_service_state")
|
||||||
|
&& (1..=self.max_runtime_seconds).contains(&job.max_runtime_seconds)
|
||||||
|
&& (1..=65536).contains(&job.max_output_bytes)
|
||||||
|
&& matches!(&job.action,Action::SetServiceState{unit,state}
|
||||||
|
if self.allowed_services.contains(unit) && matches!(state.as_str(),"running"|"stopped"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl SystemPolicy {
|
||||||
|
fn valid(&self, now: DateTime<Utc>) -> bool {
|
||||||
|
self.schema_version == 1
|
||||||
|
&& self.profile == "development"
|
||||||
|
&& self.expires_at > now
|
||||||
|
&& !self.scopes.is_empty()
|
||||||
|
&& self.scopes.len() <= 64
|
||||||
|
&& self.scopes.iter().all(SystemScope::valid)
|
||||||
|
}
|
||||||
|
fn permits(
|
||||||
|
&self,
|
||||||
|
principal: &str,
|
||||||
|
job: &JobPayload,
|
||||||
|
capabilities: &[String],
|
||||||
|
now: DateTime<Utc>,
|
||||||
|
) -> bool {
|
||||||
|
self.valid(now)
|
||||||
|
&& self
|
||||||
|
.scopes
|
||||||
|
.iter()
|
||||||
|
.any(|scope| scope.permits(principal, job, capabilities))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn disabled() -> Error {
|
||||||
|
Error(StatusCode::CONFLICT, "UNSUPPORTED_CAPABILITY")
|
||||||
|
}
|
||||||
|
fn no_symlink_components(path: &Path) -> Result<(), Error> {
|
||||||
|
let absolute = if path.is_absolute() {
|
||||||
|
path.to_path_buf()
|
||||||
|
} else {
|
||||||
|
std::env::current_dir().map_err(|_| disabled())?.join(path)
|
||||||
|
};
|
||||||
|
for component in absolute.ancestors() {
|
||||||
|
if fs::symlink_metadata(component)
|
||||||
|
.map_err(|_| disabled())?
|
||||||
|
.file_type()
|
||||||
|
.is_symlink()
|
||||||
|
{
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn protected_parent_chain(path: &Path, owner: u32) -> Result<(), Error> {
|
||||||
|
// A private immediate parent can itself be renamed through an unsafe
|
||||||
|
// ancestor. Trust every directory owner, and reject writable ancestors
|
||||||
|
// unless their sticky bit protects the trusted-owned next component.
|
||||||
|
// This deliberately preserves /tmp's root-owned sticky-directory contract.
|
||||||
|
let absolute = if path.is_absolute() {
|
||||||
|
path.to_path_buf()
|
||||||
|
} else {
|
||||||
|
std::env::current_dir().map_err(|_| disabled())?.join(path)
|
||||||
|
};
|
||||||
|
for ancestor in absolute.ancestors().skip(1) {
|
||||||
|
let directory = fs::symlink_metadata(ancestor).map_err(|_| disabled())?;
|
||||||
|
let mode = directory.permissions().mode();
|
||||||
|
if !directory.is_dir()
|
||||||
|
|| ![0, owner].contains(&directory.uid())
|
||||||
|
|| (mode & 0o022 != 0 && mode & 0o1000 == 0)
|
||||||
|
{
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn protected_bytes(path: &Path, owner: u32) -> Result<Vec<u8>, Error> {
|
||||||
|
no_symlink_components(path)?;
|
||||||
|
protected_parent_chain(path, owner)?;
|
||||||
|
let before = fs::symlink_metadata(path).map_err(|_| disabled())?;
|
||||||
|
let parent = path.parent().ok_or_else(disabled)?;
|
||||||
|
let directory = fs::symlink_metadata(parent).map_err(|_| disabled())?;
|
||||||
|
if !before.is_file()
|
||||||
|
|| before.uid() != owner
|
||||||
|
|| before.permissions().mode() & 0o777 != 0o600
|
||||||
|
|| before.len() > POLICY_LIMIT
|
||||||
|
|| !directory.is_dir()
|
||||||
|
|| ![0, owner].contains(&directory.uid())
|
||||||
|
|| directory.permissions().mode() & 0o022 != 0
|
||||||
|
{
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
// The protected immediate parent excludes unprivileged swaps. Additionally
|
||||||
|
// bind the opened descriptor to the lstat identity and bound the actual read.
|
||||||
|
let mut file = File::open(path).map_err(|_| disabled())?;
|
||||||
|
let opened = file.metadata().map_err(|_| disabled())?;
|
||||||
|
if opened.dev() != before.dev() || opened.ino() != before.ino() {
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
let mut bytes = Vec::new();
|
||||||
|
file.by_ref()
|
||||||
|
.take(POLICY_LIMIT + 1)
|
||||||
|
.read_to_end(&mut bytes)
|
||||||
|
.map_err(|_| disabled())?;
|
||||||
|
no_symlink_components(path)?;
|
||||||
|
protected_parent_chain(path, owner)?;
|
||||||
|
let after = fs::symlink_metadata(path).map_err(|_| disabled())?;
|
||||||
|
if bytes.len() as u64 > POLICY_LIMIT
|
||||||
|
|| !after.is_file()
|
||||||
|
|| after.dev() != before.dev()
|
||||||
|
|| after.ino() != before.ino()
|
||||||
|
|| after.uid() != owner
|
||||||
|
|| after.permissions().mode() & 0o777 != 0o600
|
||||||
|
|| after.len() != before.len()
|
||||||
|
|| after.mtime() != before.mtime()
|
||||||
|
|| after.mtime_nsec() != before.mtime_nsec()
|
||||||
|
{
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
Ok(bytes)
|
||||||
|
}
|
||||||
|
fn load() -> Result<SystemPolicy, Error> {
|
||||||
|
if std::env::var("RMM_PROFILE").as_deref() != Ok("development")
|
||||||
|
|| std::env::var("RMM_DEV_SYSTEM_ENABLED").as_deref() != Ok("true")
|
||||||
|
{
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
let path = std::env::var("RMM_DEV_SYSTEM_POLICY_FILE").map_err(|_| disabled())?;
|
||||||
|
let key =
|
||||||
|
std::env::var("RMM_JOB_KEY_FILE").unwrap_or_else(|_| "devstate/jobs/ed25519.pem".into());
|
||||||
|
// Inspect only signing-key metadata, never read/log/export the private key.
|
||||||
|
no_symlink_components(Path::new(&key))?;
|
||||||
|
let key = fs::symlink_metadata(key).map_err(|_| disabled())?;
|
||||||
|
if !key.is_file() {
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
let policy: SystemPolicy =
|
||||||
|
serde_json::from_slice(&protected_bytes(Path::new(&path), key.uid())?)
|
||||||
|
.map_err(|_| disabled())?;
|
||||||
|
if !policy.valid(Utc::now()) {
|
||||||
|
return Err(disabled());
|
||||||
|
}
|
||||||
|
Ok(policy)
|
||||||
|
}
|
||||||
|
pub async fn authorize(
|
||||||
|
tx: &mut Transaction<'_, Postgres>,
|
||||||
|
principal: &str,
|
||||||
|
job: &JobPayload,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
if job.execution_identity != "system" {
|
||||||
|
return Err(Error(StatusCode::FORBIDDEN, "SYSTEM_IDENTITY_REQUIRED"));
|
||||||
|
}
|
||||||
|
// Independent DB permission; root:execute never implies this scope.
|
||||||
|
crate::permissions::require(tx, principal, "system:execute").await?;
|
||||||
|
let policy = load()?;
|
||||||
|
let caps:serde_json::Value=sqlx::query_scalar("SELECT capabilities FROM agent_installations WHERE tenant_id=$1 AND agent_id=$2 AND asset_id=$3 AND revoked_at IS NULL AND enrollment_generation=$4 AND assignment_version=$5").bind(job.tenant_id).bind(job.agent_id).bind(job.asset_id).bind(i64::try_from(job.enrollment_generation).map_err(|_|Error(StatusCode::CONFLICT,"BINDING_MISMATCH"))?).bind(i64::try_from(job.assignment_version).map_err(|_|Error(StatusCode::CONFLICT,"BINDING_MISMATCH"))?).fetch_optional(&mut **tx).await?.ok_or(Error(StatusCode::CONFLICT,"AUTHORIZATION_REVOKED"))?;
|
||||||
|
let capabilities: Vec<String> = serde_json::from_value(caps)?;
|
||||||
|
if !policy.permits(principal, job, &capabilities, Utc::now()) {
|
||||||
|
return Err(Error(
|
||||||
|
StatusCode::FORBIDDEN,
|
||||||
|
"SYSTEM_SCOPE_OR_HELPER_POLICY_DENIED",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use serde_json::json;
|
||||||
|
fn fixture() -> (SystemPolicy, JobPayload, Vec<String>) {
|
||||||
|
let id = Uuid::new_v4();
|
||||||
|
let now = Utc::now();
|
||||||
|
let policy:SystemPolicy=serde_json::from_value(json!({"schema_version":1,"profile":"development","expires_at":now+chrono::Duration::minutes(10),"scopes":[{"tenant_id":id,"asset_id":id,"agent_id":id,"enrollment_generation":1,"assignment_version":1,"principals":["selected"],"helper_policy_sha256":"ab".repeat(32),"helper_binary_sha256":"cd".repeat(32),"acceptance_evidence_id":Uuid::new_v4(),"allowed_services":["RmmDiscoveryFixtureService"],"max_runtime_seconds":30}]})).unwrap();
|
||||||
|
let job = JobPayload {
|
||||||
|
schema_version: 1,
|
||||||
|
tenant_id: id,
|
||||||
|
asset_id: id,
|
||||||
|
agent_id: id,
|
||||||
|
enrollment_generation: 1,
|
||||||
|
assignment_version: 1,
|
||||||
|
job_id: Uuid::new_v4(),
|
||||||
|
attempt_id: Uuid::new_v4(),
|
||||||
|
action: Action::SetServiceState {
|
||||||
|
unit: "RmmDiscoveryFixtureService".into(),
|
||||||
|
state: "running".into(),
|
||||||
|
},
|
||||||
|
execution_identity: "system".into(),
|
||||||
|
not_before: now,
|
||||||
|
start_before: now + chrono::Duration::minutes(5),
|
||||||
|
max_runtime_seconds: 30,
|
||||||
|
max_output_bytes: 4096,
|
||||||
|
};
|
||||||
|
let caps = vec![
|
||||||
|
"windows.base/1".into(),
|
||||||
|
"rmm.sync.v1".into(),
|
||||||
|
"helper.system.v1".into(),
|
||||||
|
format!("helper.policy.sha256:{}", "ab".repeat(32)),
|
||||||
|
format!("helper.binary.sha256:{}", "cd".repeat(32)),
|
||||||
|
"system:set_service_state".into(),
|
||||||
|
"set_service_state".into(),
|
||||||
|
];
|
||||||
|
(policy, job, caps)
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn system_permission_and_helper_requirement_are_distinct_from_root() {
|
||||||
|
let id = Uuid::new_v4();
|
||||||
|
let principal = crate::auth::Principal {
|
||||||
|
tenant: id,
|
||||||
|
name: "root-only".into(),
|
||||||
|
operator: true,
|
||||||
|
session_hash: None,
|
||||||
|
csrf: None,
|
||||||
|
scopes: Some(std::collections::BTreeSet::from(["root:execute".into()])),
|
||||||
|
testsimulation: false,
|
||||||
|
identity: None,
|
||||||
|
tenants: vec![id],
|
||||||
|
};
|
||||||
|
assert!(principal.permits_scope(crate::root_policy::execution_permission("root").unwrap()));
|
||||||
|
assert!(
|
||||||
|
!principal.permits_scope(crate::root_policy::execution_permission("system").unwrap())
|
||||||
|
);
|
||||||
|
assert!(crate::root_policy::needs_helper("system"));
|
||||||
|
assert!(crate::root_policy::needs_helper("root"));
|
||||||
|
assert!(!crate::root_policy::needs_helper("agent_service"));
|
||||||
|
let (policy, job, caps) = fixture();
|
||||||
|
let mut empty = policy;
|
||||||
|
empty.scopes.clear();
|
||||||
|
assert!(!empty.permits("selected", &job, &caps, Utc::now()));
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn exact_system_scope_never_inherits_root_or_other_device_authority() {
|
||||||
|
let (policy, job, caps) = fixture();
|
||||||
|
let now = Utc::now();
|
||||||
|
assert!(policy.permits("selected", &job, &caps, now));
|
||||||
|
assert!(!policy.permits("root-operator", &job, &caps, now));
|
||||||
|
for identity in ["root", "agent_service", "SYSTEM"] {
|
||||||
|
let mut other = job.clone();
|
||||||
|
other.execution_identity = identity.into();
|
||||||
|
assert!(!policy.permits("selected", &other, &caps, now));
|
||||||
|
}
|
||||||
|
for field in ["tenant", "asset", "agent", "enrollment", "assignment"] {
|
||||||
|
let mut other = job.clone();
|
||||||
|
match field {
|
||||||
|
"tenant" => other.tenant_id = Uuid::new_v4(),
|
||||||
|
"asset" => other.asset_id = Uuid::new_v4(),
|
||||||
|
"agent" => other.agent_id = Uuid::new_v4(),
|
||||||
|
"enrollment" => other.enrollment_generation += 1,
|
||||||
|
_ => other.assignment_version += 1,
|
||||||
|
}
|
||||||
|
assert!(!policy.permits("selected", &other, &caps, now));
|
||||||
|
}
|
||||||
|
for i in 0..caps.len() {
|
||||||
|
let mut missing = caps.clone();
|
||||||
|
missing.remove(i);
|
||||||
|
assert!(!policy.permits("selected", &job, &missing, now));
|
||||||
|
}
|
||||||
|
let mut mixed = caps.clone();
|
||||||
|
mixed.push("linux.base/1".into());
|
||||||
|
assert!(!policy.permits("selected", &job, &mixed, now));
|
||||||
|
let mut wrong = caps.clone();
|
||||||
|
wrong[4] = format!("helper.binary.sha256:{}", "ef".repeat(32));
|
||||||
|
assert!(!policy.permits("selected", &job, &wrong, now));
|
||||||
|
assert!(!policy.permits("selected", &job, &caps, policy.expires_at));
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn narrow_scm_ceiling_denies_unreviewed_effects_and_provider_inputs() {
|
||||||
|
let (mut policy, mut job, caps) = fixture();
|
||||||
|
let now = Utc::now();
|
||||||
|
for (unit, state) in [
|
||||||
|
("RmmDiscoveryWindows", "stopped"),
|
||||||
|
("RmmDiscoverySystemHelper", "stopped"),
|
||||||
|
("Spooler", "running"),
|
||||||
|
("RmmDiscoveryFixtureService", "restarted"),
|
||||||
|
] {
|
||||||
|
job.action = Action::SetServiceState {
|
||||||
|
unit: unit.into(),
|
||||||
|
state: state.into(),
|
||||||
|
};
|
||||||
|
assert!(!policy.permits("selected", &job, &caps, now));
|
||||||
|
}
|
||||||
|
job.action = Action::RunScript {
|
||||||
|
interpreter: "powershell".into(),
|
||||||
|
script_utf8: "Write-Output 'hello'".into(),
|
||||||
|
arguments: vec![],
|
||||||
|
expected_stdout: None,
|
||||||
|
};
|
||||||
|
assert!(!policy.permits("selected", &job, &caps, now));
|
||||||
|
job.action = Action::SetServiceState {
|
||||||
|
unit: "RmmDiscoveryFixtureService".into(),
|
||||||
|
state: "stopped".into(),
|
||||||
|
};
|
||||||
|
assert!(policy.permits("selected", &job, &caps, now));
|
||||||
|
job.max_runtime_seconds = 31;
|
||||||
|
assert!(!policy.permits("selected", &job, &caps, now));
|
||||||
|
job.max_runtime_seconds = 30;
|
||||||
|
policy.scopes[0].acceptance_evidence_id = Uuid::nil();
|
||||||
|
assert!(!policy.permits("selected", &job, &caps, now));
|
||||||
|
let invalid = json!({"schema_version":1,"profile":"development","expires_at":now,"scopes":[],"allow_system_scripts":true});
|
||||||
|
assert!(serde_json::from_value::<SystemPolicy>(invalid).is_err());
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn policy_file_refuses_symlinks_public_mode_wrong_owner_and_writable_parent() {
|
||||||
|
use std::os::unix::fs::symlink;
|
||||||
|
let directory = std::env::temp_dir().join(format!("rmm-windows-policy-{}", Uuid::new_v4()));
|
||||||
|
fs::create_dir(&directory).unwrap();
|
||||||
|
fs::set_permissions(&directory, fs::Permissions::from_mode(0o700)).unwrap();
|
||||||
|
let path = directory.join("policy.json");
|
||||||
|
fs::write(&path, b"{}").unwrap();
|
||||||
|
fs::set_permissions(&path, fs::Permissions::from_mode(0o600)).unwrap();
|
||||||
|
let owner = fs::metadata(&path).unwrap().uid();
|
||||||
|
assert_eq!(protected_bytes(&path, owner).unwrap(), b"{}");
|
||||||
|
assert!(protected_bytes(&path, owner.wrapping_add(1)).is_err());
|
||||||
|
let link = directory.join("link.json");
|
||||||
|
symlink(&path, &link).unwrap();
|
||||||
|
assert!(protected_bytes(&link, owner).is_err());
|
||||||
|
fs::set_permissions(&path, fs::Permissions::from_mode(0o640)).unwrap();
|
||||||
|
assert!(protected_bytes(&path, owner).is_err());
|
||||||
|
fs::set_permissions(&path, fs::Permissions::from_mode(0o600)).unwrap();
|
||||||
|
fs::set_permissions(&directory, fs::Permissions::from_mode(0o770)).unwrap();
|
||||||
|
assert!(protected_bytes(&path, owner).is_err());
|
||||||
|
fs::set_permissions(&directory, fs::Permissions::from_mode(0o700)).unwrap();
|
||||||
|
fs::write(&path, vec![b' '; POLICY_LIMIT as usize + 1]).unwrap();
|
||||||
|
assert!(protected_bytes(&path, owner).is_err());
|
||||||
|
let real = directory.join("real");
|
||||||
|
let nested = real.join("nested");
|
||||||
|
fs::create_dir_all(&nested).unwrap();
|
||||||
|
fs::set_permissions(&nested, fs::Permissions::from_mode(0o700)).unwrap();
|
||||||
|
let data = nested.join("policy.json");
|
||||||
|
fs::write(&data, b"{}").unwrap();
|
||||||
|
fs::set_permissions(&data, fs::Permissions::from_mode(0o600)).unwrap();
|
||||||
|
// The immediate parent remains protected throughout. A writable
|
||||||
|
// ancestor still permits substitution of that entire directory.
|
||||||
|
fs::set_permissions(&real, fs::Permissions::from_mode(0o777)).unwrap();
|
||||||
|
assert!(protected_bytes(&data, owner).is_err());
|
||||||
|
fs::set_permissions(&real, fs::Permissions::from_mode(0o1777)).unwrap();
|
||||||
|
assert_eq!(protected_bytes(&data, owner).unwrap(), b"{}");
|
||||||
|
fs::set_permissions(&real, fs::Permissions::from_mode(0o700)).unwrap();
|
||||||
|
let alias = directory.join("alias");
|
||||||
|
symlink(&real, &alias).unwrap();
|
||||||
|
assert!(protected_bytes(&alias.join("nested/policy.json"), owner).is_err());
|
||||||
|
fs::remove_dir_all(directory).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Exact pure server policy units: local release build, then parent-run Linux VM.
|
||||||
|
|
||||||
|
No server daemon, DB, networking, approval/job, package or device operation.
|
||||||
|
Native execution requires an explicit flag. Lost replies permit readback only.
|
||||||
|
"""
|
||||||
|
import argparse
|
||||||
|
import base64
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import remote_client_bootstrap as linux
|
||||||
|
import vm_mvp_acceptance as contract
|
||||||
|
|
||||||
|
ROOT=Path(__file__).resolve().parents[1]
|
||||||
|
STATE=ROOT/'devstate/server-windows-policy'
|
||||||
|
IMAGE='rust-discovery-durable-final-build:local'
|
||||||
|
REMOTE='/var/lib/rmm-server-policy-acceptance'
|
||||||
|
TESTS=(
|
||||||
|
'windows_policy::tests::system_permission_and_helper_requirement_are_distinct_from_root',
|
||||||
|
'windows_policy::tests::exact_system_scope_never_inherits_root_or_other_device_authority',
|
||||||
|
'windows_policy::tests::narrow_scm_ceiling_denies_unreviewed_effects_and_provider_inputs',
|
||||||
|
'windows_policy::tests::policy_file_refuses_symlinks_public_mode_wrong_owner_and_writable_parent',
|
||||||
|
'root_policy::tests::no_capability_or_relabel_shortcut',
|
||||||
|
'root_policy::root_log_tests::exact_root_log_plan_shape_and_selected_scope',
|
||||||
|
'root_policy::root_log_tests::default_empty_and_service_mutation_list_never_authorize_logs',
|
||||||
|
'root_policy::root_log_tests::scoped_allowlist_and_global_ceiling_are_exact',
|
||||||
|
'root_policy::root_log_tests::exact_log_bounds_not_rounded_hours',
|
||||||
|
'root_policy::root_log_tests::env_lists_are_bounded_data_not_paths_wildcards_or_bools',
|
||||||
|
'root_policy::root_log_tests::classification_cannot_be_bypassed_by_another_scope_or_empty_env',
|
||||||
|
'root_policy::root_log_tests::permissions_are_separate_root_read_and_sensitive_requirements',
|
||||||
|
'root_policy::root_log_tests::unknown_log_profile_version_denies',
|
||||||
|
)
|
||||||
|
require=contract.require
|
||||||
|
|
||||||
|
def sha(path):return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
||||||
|
def store(folder,name,value):
|
||||||
|
fd=os.open(folder/name,os.O_CREAT|os.O_EXCL|os.O_WRONLY|os.O_NOFOLLOW,0o600)
|
||||||
|
with os.fdopen(fd,'w') as out:json.dump(value,out,indent=2);out.write('\n');out.flush();os.fsync(out.fileno())
|
||||||
|
def sources():
|
||||||
|
paths=[ROOT/p for p in ('Cargo.toml','Cargo.lock','rust-toolchain.toml','tests/backend_root_logs.rs')]
|
||||||
|
for crate in ('server','domain','protocol','persistence','oidc-auth'):
|
||||||
|
base=ROOT/'crates'/crate
|
||||||
|
paths.extend(p for p in base.rglob('*') if p.is_file() and (p.suffix in ('.rs','.sql') or p.name=='Cargo.toml'))
|
||||||
|
paths.extend((ROOT/'proto').glob('*.proto'))
|
||||||
|
return {str(p.relative_to(ROOT)):sha(p) for p in sorted(set(paths))}
|
||||||
|
def command(args,timeout=300):
|
||||||
|
p=subprocess.run(args,capture_output=True,timeout=timeout)
|
||||||
|
if p.returncode:raise RuntimeError(p.stderr.decode(errors='replace')[-4000:])
|
||||||
|
return p.stdout
|
||||||
|
|
||||||
|
def build():
|
||||||
|
os.umask(0o077);STATE.mkdir(parents=True,exist_ok=True,mode=0o700)
|
||||||
|
folder=STATE/('build-'+str(uuid.uuid4()));folder.mkdir(mode=0o700)
|
||||||
|
before=sources();runner_before=sha(__file__);store(folder,'source-before.json',before)
|
||||||
|
target=STATE/'target';target.mkdir(mode=0o700,exist_ok=True)
|
||||||
|
args=['docker','run','--rm','--network','none','--read-only','--tmpfs','/tmp:rw,size=512m',
|
||||||
|
'-v',str(ROOT)+':/src:ro','-v',str(target)+':/target','-e','CARGO_TARGET_DIR=/target','--entrypoint','cargo',IMAGE]
|
||||||
|
command(args+['clippy','--manifest-path','/src/Cargo.toml','--locked','--offline','-p','rmm-server','--all-targets','--','-D','warnings'])
|
||||||
|
raw=command(args+['test','--manifest-path','/src/Cargo.toml','--locked','--offline','-p','rmm-server','--release','--no-run','--message-format=json'])
|
||||||
|
paths=[]
|
||||||
|
for line in raw.splitlines():
|
||||||
|
try:item=json.loads(line)
|
||||||
|
except ValueError:continue
|
||||||
|
if item.get('reason')=='compiler-artifact' and item.get('profile',{}).get('test') and item.get('target',{}).get('name')=='rmm-server' and item.get('executable'):
|
||||||
|
paths.append(target/Path(item['executable']).relative_to('/target'))
|
||||||
|
require(len(paths)==1,'one actual release server UNIT harness, not server daemon')
|
||||||
|
artifact=folder/'server-policy-tests';shutil.copyfile(paths[0],artifact);artifact.chmod(0o600)
|
||||||
|
elf=artifact.read_bytes();require(elf[:6]==b'\x7fELF\x02\x01' and elf[18:20]==b'\x3e\x00','x64 ELF unit harness')
|
||||||
|
# Exact-list inspection executes no tests; then only the thirteen named pure
|
||||||
|
# units run in an isolated local container without network/DB configuration.
|
||||||
|
run=['docker','run','--rm','--network','none','--read-only','--tmpfs','/tmp:rw,size=64m','-v',str(artifact.resolve())+':/server-policy-tests:ro','--entrypoint','/bin/sh',IMAGE,'-c']
|
||||||
|
listed=command(run+['exec /lib64/ld-linux-x86-64.so.2 /server-policy-tests --list --format terse'])
|
||||||
|
names=set(re.findall(rb'^(.+): test$',listed,re.M));require(all(name.encode() in names for name in TESTS),'all exact selected test names present')
|
||||||
|
local=[]
|
||||||
|
for name in TESTS:
|
||||||
|
output=command(run+['exec /lib64/ld-linux-x86-64.so.2 /server-policy-tests --exact '+name+' --test-threads=1'],timeout=15)
|
||||||
|
require(b'1 passed; 0 failed; 0 ignored;' in output,'one selected local policy guard passed')
|
||||||
|
local.append(dict(name=name,stdout_sha256=hashlib.sha256(output).hexdigest()))
|
||||||
|
require(sources()==before and sha(__file__)==runner_before,'source drift during qualification; never qualify stale binary')
|
||||||
|
manifest=dict(schema_version=1,target='x86_64-unknown-linux-gnu',profile='release-unit-harness',
|
||||||
|
source_files=before,source_before_after_equal=True,artifact=dict(path=str(artifact.resolve()),sha256=sha(artifact),bytes=artifact.stat().st_size),
|
||||||
|
selected_tests=list(TESTS),local_tests=local,runner_sha256=runner_before,clippy_all_targets_D_warnings=True,native_vm_executed=False,
|
||||||
|
database_tests_executed=False,server_daemon_started=False,rmm_jobs_created=False)
|
||||||
|
store(folder,'manifest.json',manifest);print(json.dumps(dict(manifest=str((folder/'manifest.json').resolve()),binary_sha256=sha(artifact),selected_tests=len(TESTS),native_vm_executed=False)))
|
||||||
|
|
||||||
|
def verified(path):
|
||||||
|
m=contract.protected_json(path)
|
||||||
|
require(m['runner_sha256']==sha(__file__),'frozen exact native test orchestrator')
|
||||||
|
require(m['source_files']==sources() and m['selected_tests']==list(TESTS) and m['source_before_after_equal'] is True,'frozen exact policy source/test selection')
|
||||||
|
p=Path(m['artifact']['path']);require(sha(p)==m['artifact']['sha256'] and p.stat().st_size==m['artifact']['bytes'],'actual unchanged unit harness')
|
||||||
|
require(m['profile']=='release-unit-harness' and m['native_vm_executed'] is False,'test harness only')
|
||||||
|
return m
|
||||||
|
|
||||||
|
# Sent only by the parent's explicitly invoked native phase through the existing
|
||||||
|
# pinned SSH bootstrap. It never reads credentials, product state or live logs.
|
||||||
|
def native_case(payload):
|
||||||
|
import resource
|
||||||
|
import stat
|
||||||
|
import time
|
||||||
|
root=Path('/var/lib/rmm-server-policy-acceptance');ident=str(uuid.UUID(payload['id']))
|
||||||
|
require(ident==payload['id'] and payload['action'] in ('prepare','run','read'),'fixed native case')
|
||||||
|
sha=payload['binary_sha256'];require(len(sha)==64 and all(c in '0123456789abcdef' for c in sha),'fixed unit artifact hash')
|
||||||
|
# Duplicate the frozen names in the remote source: payload cannot select an
|
||||||
|
# arbitrary test from the executable (in particular no DB/async/job tests).
|
||||||
|
names=[
|
||||||
|
'windows_policy::tests::system_permission_and_helper_requirement_are_distinct_from_root',
|
||||||
|
'windows_policy::tests::exact_system_scope_never_inherits_root_or_other_device_authority',
|
||||||
|
'windows_policy::tests::narrow_scm_ceiling_denies_unreviewed_effects_and_provider_inputs',
|
||||||
|
'windows_policy::tests::policy_file_refuses_symlinks_public_mode_wrong_owner_and_writable_parent',
|
||||||
|
'root_policy::tests::no_capability_or_relabel_shortcut',
|
||||||
|
'root_policy::root_log_tests::exact_root_log_plan_shape_and_selected_scope',
|
||||||
|
'root_policy::root_log_tests::default_empty_and_service_mutation_list_never_authorize_logs',
|
||||||
|
'root_policy::root_log_tests::scoped_allowlist_and_global_ceiling_are_exact',
|
||||||
|
'root_policy::root_log_tests::exact_log_bounds_not_rounded_hours',
|
||||||
|
'root_policy::root_log_tests::env_lists_are_bounded_data_not_paths_wildcards_or_bools',
|
||||||
|
'root_policy::root_log_tests::classification_cannot_be_bypassed_by_another_scope_or_empty_env',
|
||||||
|
'root_policy::root_log_tests::permissions_are_separate_root_read_and_sensitive_requirements',
|
||||||
|
'root_policy::root_log_tests::unknown_log_profile_version_denies']
|
||||||
|
require(payload['tests']==names and os.geteuid()==0,'explicit exact thirteen bootstrap unit tests')
|
||||||
|
def safe(path,directory):
|
||||||
|
m=path.lstat();require(m.st_uid==0 and not m.st_mode&0o077 and not stat.S_ISLNK(m.st_mode) and (stat.S_ISDIR(m.st_mode) if directory else stat.S_ISREG(m.st_mode)),'private fixed native test path')
|
||||||
|
def save(path,value):
|
||||||
|
fd=os.open(path,os.O_CREAT|os.O_EXCL|os.O_WRONLY|os.O_NOFOLLOW,0o600)
|
||||||
|
with os.fdopen(fd,'w') as f:json.dump(value,f);f.flush();os.fsync(f.fileno())
|
||||||
|
if not root.exists():root.mkdir(mode=0o700)
|
||||||
|
safe(root,True);case=root/ident
|
||||||
|
if payload['action']=='prepare':
|
||||||
|
case.mkdir(mode=0o700);save(case/'intent.json',payload);return dict(prepared=True)
|
||||||
|
safe(case,True);safe(case/'intent.json',False);intent=json.loads((case/'intent.json').read_bytes())
|
||||||
|
require(all(intent[k]==payload[k] for k in ('id','binary_sha256','manifest_sha256','tests')),'original native intent')
|
||||||
|
if payload['action']=='read':safe(case/'result.json',False);return json.loads((case/'result.json').read_bytes())
|
||||||
|
binary=case/'server-policy-tests';safe(binary,False)
|
||||||
|
require(hashlib.sha256(binary.read_bytes()).hexdigest()==sha,'native staged test bytes')
|
||||||
|
save(case/'started.json',dict(binary_sha256=sha,tests=names,no_rerun_after_lost_reply=True))
|
||||||
|
binary.chmod(0o500);temporary=case/'tmp';temporary.mkdir(mode=0o700)
|
||||||
|
env={'PATH':'/usr/bin:/bin','LANG':'C.UTF-8','TMPDIR':str(temporary),'RUST_BACKTRACE':'0'}
|
||||||
|
check=subprocess.run(['/usr/bin/unshare','--net','--','/usr/bin/true'],env=env,capture_output=True,timeout=3)
|
||||||
|
require(check.returncode==0,'network namespace required; do not weaken isolation')
|
||||||
|
def limits():resource.setrlimit(resource.RLIMIT_CORE,(0,0));resource.setrlimit(resource.RLIMIT_FSIZE,(1048576,1048576));resource.setrlimit(resource.RLIMIT_CPU,(10,10))
|
||||||
|
results=[];deadline=time.monotonic()+20
|
||||||
|
for number,name in enumerate(names):
|
||||||
|
out=case/(str(number)+'-stdout.bin');err=case/(str(number)+'-stderr.bin')
|
||||||
|
timed_out=False
|
||||||
|
with out.open('xb') as stdout,err.open('xb') as stderr:
|
||||||
|
out.chmod(0o600);err.chmod(0o600)
|
||||||
|
try:
|
||||||
|
remaining=deadline-time.monotonic();require(remaining>0,'aggregate pure test deadline')
|
||||||
|
result=subprocess.run(['/usr/bin/unshare','--net','--',str(binary),'--exact',name,'--test-threads=1'],cwd=case,env=env,stdin=subprocess.DEVNULL,stdout=stdout,stderr=stderr,timeout=min(5,remaining),preexec_fn=limits)
|
||||||
|
code=result.returncode
|
||||||
|
except subprocess.TimeoutExpired:timed_out=True;code=None
|
||||||
|
stdout.flush();stderr.flush();os.fsync(stdout.fileno());os.fsync(stderr.fileno())
|
||||||
|
raw=out.read_bytes();errors=err.read_bytes();require(len(raw)<=1048576 and len(errors)<=1048576,'bounded unit output')
|
||||||
|
results.append(dict(name=name,exit_code=code,timed_out=timed_out,stdout_b64=base64.b64encode(raw).decode(),stderr_b64=base64.b64encode(errors).decode()))
|
||||||
|
if code!=0:break
|
||||||
|
report=dict(id=ident,binary_sha256=sha,manifest_sha256=payload['manifest_sha256'],results=results,native_platform='linux',network_namespace=True,environment_cleared=True,server_daemon_started=False,database_tests_executed=False,rmm_jobs_created=False)
|
||||||
|
save(case/'result.json',report);return report
|
||||||
|
|
||||||
|
def native(manifest_path,ident=None):
|
||||||
|
m=verified(manifest_path);os.umask(0o077);STATE.mkdir(mode=0o700,parents=True,exist_ok=True)
|
||||||
|
if ident is None:
|
||||||
|
ident=str(uuid.uuid4());folder=STATE/ident;folder.mkdir(mode=0o700)
|
||||||
|
payload=dict(id=ident,binary_sha256=m['artifact']['sha256'],manifest_sha256=sha(manifest_path),tests=list(TESTS))
|
||||||
|
store(folder,'intent.json',dict(payload=payload,manifest_path=str(manifest_path.resolve())))
|
||||||
|
linux.rpc('linux-vm.conf',native_case,dict(payload,action='prepare'))
|
||||||
|
cfg=linux.access.load_config(ROOT/'credentials/linux-vm.conf')
|
||||||
|
args=['sftp','-F','/dev/null','-P',cfg.get('port','22'),'-o','StrictHostKeyChecking=yes','-o','BatchMode=yes','-o','IdentitiesOnly=yes','-o','ForwardAgent=no','-o','ConnectTimeout=10','-i',str(Path(cfg['ssh_key_path']).expanduser()),'-b','-',cfg['username']+'@'+cfg['address']]
|
||||||
|
result=subprocess.run(args,input=('put '+json.dumps(m['artifact']['path'])+' '+json.dumps(REMOTE+'/'+ident+'/server-policy-tests')+'\n').encode(),capture_output=True,timeout=120)
|
||||||
|
store(folder,'upload.json',dict(returncode=result.returncode));require(result.returncode==0,'fixed native test transfer')
|
||||||
|
store(folder,'run-intent.json',dict(execute_only_exact_pure_tests=True))
|
||||||
|
value=linux.rpc('linux-vm.conf',native_case,dict(payload,action='run'))
|
||||||
|
else:
|
||||||
|
ident=str(uuid.UUID(ident));folder=STATE/ident;intent=contract.protected_json(folder/'intent.json');payload=intent['payload']
|
||||||
|
require(intent['manifest_path']==str(manifest_path.resolve()) and payload['manifest_sha256']==sha(manifest_path),'original manifest only')
|
||||||
|
value=linux.rpc('linux-vm.conf',native_case,dict(payload,action='read'))
|
||||||
|
store(folder,'readback-'+str(uuid.uuid4())+'.json',value)
|
||||||
|
require(value['binary_sha256']==m['artifact']['sha256'] and len(value['results'])==len(TESTS),'all exact native pure tests observed')
|
||||||
|
for result,name in zip(value['results'],TESTS,strict=True):
|
||||||
|
raw=base64.b64decode(result['stdout_b64'],validate=True)
|
||||||
|
require(result['name']==name and result['exit_code']==0 and result['timed_out'] is False and b'1 passed; 0 failed; 0 ignored;' in raw,'exact native test passed, no ignored tests')
|
||||||
|
proof=dict(verified=True,case_id=ident,native_platform='linux',selected_tests=len(TESTS),manifest_sha256=sha(manifest_path),report=value)
|
||||||
|
if (folder/'passed.json').exists():require(contract.protected_json(folder/'passed.json')==proof,'retain identical original native proof')
|
||||||
|
else:store(folder,'passed.json',proof)
|
||||||
|
print(json.dumps(dict(verified=True,case_id=ident,selected_native_tests=len(TESTS))))
|
||||||
|
|
||||||
|
def main():
|
||||||
|
p=argparse.ArgumentParser(description=__doc__);p.add_argument('action',choices=('build-local','native','readback'));p.add_argument('--manifest',type=Path);p.add_argument('--case');p.add_argument('--execute-native-tests',action='store_true');a=p.parse_args()
|
||||||
|
if a.action=='build-local':require(not(a.manifest or a.case or a.execute_native_tests),'local build only');build()
|
||||||
|
elif a.action=='native':require(a.manifest and a.execute_native_tests and not a.case,'parent explicitly starts one native case');native(a.manifest)
|
||||||
|
else:require(a.manifest and a.case and not a.execute_native_tests,'readback only, no repeated native run');native(a.manifest,a.case)
|
||||||
|
if __name__=='__main__':main()
|
||||||
+6
-1
@@ -1,6 +1,11 @@
|
|||||||
# Linux-first-Entwicklung und reale VM-Abnahme
|
# Linux-first-Entwicklung und reale VM-Abnahme
|
||||||
|
|
||||||
Stand: 2026-11-13 · Spezifikation 1.13. **Windows-Override:** Entwicklung und native
|
Stand: 2026-11-14 · Spezifikation 1.16. Das begrenzte Linux-MVP ist inzwischen
|
||||||
|
dokumentiert abgenommen; aktuelle Nachweise stehen in [handover.md](handover.md).
|
||||||
|
Die getrennte Windows-SYSTEM-Grenze ist in Spezifikation0.1 und
|
||||||
|
[windows-system-policy.md](windows-system-policy.md) präzisiert; Quellen-/Build-
|
||||||
|
oder Linux-Unitnachweise aktivieren keine Windowswirkung.
|
||||||
|
**Windows-Override:** Entwicklung und native
|
||||||
Tests auf der neuen Windows-11-VM sind ausdrücklich parallel erlaubt, unabhängig
|
Tests auf der neuen Windows-11-VM sind ausdrücklich parallel erlaubt, unabhängig
|
||||||
von der noch offenen Linux-MVP-Abnahme. Die nachstehenden älteren Wartevorgaben
|
von der noch offenen Linux-MVP-Abnahme. Die nachstehenden älteren Wartevorgaben
|
||||||
sind hierfür überstimmt; keine Windows-Pflicht zur Linux-Abnahme.
|
sind hierfür überstimmt; keine Windows-Pflicht zur Linux-Abnahme.
|
||||||
|
|||||||
+9
-1
@@ -1,7 +1,8 @@
|
|||||||
# Übergabe — Linux-MVP abgeschlossen, Windows wird fortgesetzt
|
# Übergabe — Linux-MVP abgeschlossen, Windows wird fortgesetzt
|
||||||
|
|
||||||
**M0–M5 sind im vereinbarten begrenzten dev/test-Umfang vollständig
|
**M0–M5 sind im vereinbarten begrenzten dev/test-Umfang vollständig
|
||||||
nachgewiesen.** Spezifikation 1.15; aktueller Umfang und Grenzen stehen in
|
nachgewiesen.** Linuxabschluss unter Spezifikation1.15; aktueller Gesamtvertrag
|
||||||
|
ist1.16. Umfang und Grenzen der Linuxabnahme stehen in
|
||||||
[mvp-gates.md](mvp-gates.md) und [mvp-final-audit.md](mvp-final-audit.md).
|
[mvp-gates.md](mvp-gates.md) und [mvp-final-audit.md](mvp-final-audit.md).
|
||||||
Die frühere Entwicklungspause wurde durch den ausdrücklichen
|
Die frühere Entwicklungspause wurde durch den ausdrücklichen
|
||||||
Fortsetzungsauftrag aufgehoben. Ältere offene oder pausierte Zustände unten
|
Fortsetzungsauftrag aufgehoben. Ältere offene oder pausierte Zustände unten
|
||||||
@@ -52,6 +53,13 @@ Zugänge und private Rohbelege bleiben gitignoriert.
|
|||||||
|
|
||||||
## Aktuelle Windowsfortsetzung
|
## Aktuelle Windowsfortsetzung
|
||||||
|
|
||||||
|
Zentrale getrennte SYSTEM-Policy implementiert, lokal und anschließend13 reine
|
||||||
|
Policyguards nativ auf Cloud-Linux bestanden, Fall `13b11ce4…`, Binary `ca1df8b2…`.
|
||||||
|
Rootrecht ist kein SYSTEM-Recht, exakte Geräte-/Helperpins und enge Fixture-SCM-
|
||||||
|
Grenze; unsichere Policyvorfahren werden verweigert. Kein Deployment, neue Rechte,
|
||||||
|
Policyaktivierung oder Windowsjob. Domain/WebUI/Runtime-SCM-Route noch separat
|
||||||
|
offen. [Vertrag und Nachweis](windows-system-policy.md).
|
||||||
|
|
||||||
MSVC-Werkzeugbootstrap im neuen Fall `b208282f…` vor Downloads/Installation
|
MSVC-Werkzeugbootstrap im neuen Fall `b208282f…` vor Downloads/Installation
|
||||||
gestoppt: Die VM meldete bereits CBS- und Windows-Update-Neustartbedarf.
|
gestoppt: Die VM meldete bereits CBS- und Windows-Update-Neustartbedarf.
|
||||||
Beide Marker separat nur lesend bestätigt; kein Marker entfernt, kein Installer
|
Beide Marker separat nur lesend bestätigt; kein Marker entfernt, kein Installer
|
||||||
|
|||||||
@@ -1,5 +1,33 @@
|
|||||||
# Tatsächlicher Implementierungsstand
|
# Tatsächlicher Implementierungsstand
|
||||||
|
|
||||||
|
## Windowsfortsetzung: zentrale Policy nativ geprüft, MSI gebaut — 2026-11-14
|
||||||
|
|
||||||
|
Spezifikation1.16 präzisiert SYSTEM als eigene Identität mit eigenem Recht,
|
||||||
|
standardmäßig verweigernder Geräte-/Helperhashpolicy und unveränderter WebUI-
|
||||||
|
Grenze. Vier neue enge Policyguards und neun bestehende Root-/Logguards lokal
|
||||||
|
und anschließend auf der tatsächlichen Cloud-Linux-VM bestanden, Fall
|
||||||
|
`13b11ce4…`, Binary `ca1df8b2…`; keine DB-/Daemon-/Jobwirkung und noch kein
|
||||||
|
Cloudserverdeployment. Unsichere beschreibbare Policyvorfahren werden ebenfalls
|
||||||
|
verweigert. Domain-/UI-/Runtime-SCM-Integration und native Windowsjobs bleiben
|
||||||
|
offen. [Details](windows-system-policy.md).
|
||||||
|
|
||||||
|
MSI1.0.0 auf Windows nativ erstellt und unabhängig wieder gelesen; Fall
|
||||||
|
`48291dbe…`,20480Byte, `2204dc82…`, CAB-/Tabellen-/Downloadhash und lokale
|
||||||
|
Rust-Rezeptvalidierung bestanden. Zwei alte Fehlerfälle bleiben fehlgeschlagen;
|
||||||
|
ETS-Wrapper im COM-Argumentarray war die belegte Typfehlerursache. Keine
|
||||||
|
Produktinstallation/Upgrade/Noop oder Serverkatalogintegration ausgeführt.
|
||||||
|
[MSI-Bericht](windows-msi-fixture.md).
|
||||||
|
|
||||||
|
SYSTEM-Helper `921cf182…` im Fall `59c2fd6f…` nativ installiert und einmal
|
||||||
|
gestartet (LocalSystem/Manual/PID6240, leere Aktionsliste und Effects/Reboot aus).
|
||||||
|
Tatsächlicher Agent PID5140 meldet weiterhin `HELPER_NOT_AVAILABLE`; positive
|
||||||
|
Peerprüfung fehlgeschlagen. Neue interne Negativ-/Diagnosekontrollen noch ohne
|
||||||
|
erfolgreichen nativen Lauf: Vorbereitung scheiterte im ACL-Konstruktor vor jedem
|
||||||
|
Kontrolldienststart, Fall `4a60d264…`, Belege bleiben erhalten. MSVC-Prepare
|
||||||
|
`b208282f…` stoppte bereits vor Downloads/Installation an vorhandenem CBS-/WU-
|
||||||
|
Neustartbedarf. Kein Reboot angefordert, Marker/OS unverändert. Windowsjobs,
|
||||||
|
TrustedClock und SYSTEM-Capabilities bleiben gesperrt; Windows ist nicht fertig.
|
||||||
|
|
||||||
## Optionaler Windows-Helperclient nativ qualifiziert und ausgerollt — 2026-11-14
|
## Optionaler Windows-Helperclient nativ qualifiziert und ausgerollt — 2026-11-14
|
||||||
|
|
||||||
Neuer57-Quellen-Featurebuild und eigene native Qualifikation
|
Neuer57-Quellen-Featurebuild und eigene native Qualifikation
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
# Verbindliche Projektentscheidungen
|
# Verbindliche Projektentscheidungen
|
||||||
|
|
||||||
Stand: **2026-11-13**, Spezifikation **1.15** (`Rust_RMM_Implementierungsspezifikation.md`). Die ausdrücklichen normativen Entscheidungen in Kapitel 0 haben Vorrang vor früheren Architekturannahmen. Version 1.6 ersetzt die lokale Servertopologie durch den dedizierten Internetserver; Version 1.7 präzisiert das Notebook als reinen Entwicklungsrechner; Version 1.8 erlaubt vorgezogene parallele Windows-Entwicklung.
|
Stand: **2026-11-14**, Spezifikation **1.16** (`Rust_RMM_Implementierungsspezifikation.md`). Die ausdrücklichen normativen Entscheidungen in Kapitel 0 haben Vorrang vor früheren Architekturannahmen. Version 1.6 ersetzt die lokale Servertopologie durch den dedizierten Internetserver; Version 1.7 präzisiert das Notebook als reinen Entwicklungsrechner; Version 1.8 erlaubt vorgezogene parallele Windows-Entwicklung.
|
||||||
|
|
||||||
|
## Getrennte Windows-SYSTEM-Identität (Version1.16)
|
||||||
|
|
||||||
|
Technische Präzisierung der beauftragten Windows-Helpertrennung:
|
||||||
|
`execution_identity=system` benötigt eigenes `system:execute`; Linux-Rootrechte
|
||||||
|
enthalten dieses Recht nicht. Die erste enge Aktionsstrecke betrifft nur eigene
|
||||||
|
Fixturedienste und `running|stopped`. Zentrale konkrete Geräte-/Principal-/
|
||||||
|
Helperhashpolicy und unabhängig prüfender lokaler SYSTEM-Helper begrenzen beide;
|
||||||
|
keine Policy genehmigt einen Job. Alle bisherigen Plan-/WebUI-/Signatur-/Clock-/
|
||||||
|
Journal-/Einmalwirkungsgrenzen bleiben erhalten, einschließlich beider aktuellen
|
||||||
|
Akteursrechte bei Genehmigung/Zustellung/Start. Kein Start ohne tatsächlichen
|
||||||
|
Helperjournalbezug und bestätigten Sync. Standard ist deaktiviert; keine
|
||||||
|
Windowscapability aus Linux-Units, Crossbuild oder Bootstrap ableiten.
|
||||||
|
Dies ist keine ausgeführte Windowsaktion oder zusätzliche Scopeerteilung.
|
||||||
|
[Implementierung und tatsächliche Nachweise](windows-system-policy.md).
|
||||||
|
|
||||||
## Rechtzeitiger Rebootkontakt und spätere frische Verifikation (Version1.14)
|
## Rechtzeitiger Rebootkontakt und spätere frische Verifikation (Version1.14)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Windows-Client: Abnahmegates
|
# Windows-Client: Abnahmegates
|
||||||
|
|
||||||
Stand 2026-11-14, Spezifikation 1.15. Der Windows-11-x64-Gast ist ein eigenes
|
Stand 2026-11-14, Spezifikation 1.16. Der Windows-11-x64-Gast ist ein eigenes
|
||||||
Testgerät. Der Notebook-Host bleibt ausschließlich Entwicklungsrechner;
|
Testgerät. Der Notebook-Host bleibt ausschließlich Entwicklungsrechner;
|
||||||
Server ist `discovery.ease-technologies.de`. Das abgeschlossene Linux-MVP
|
Server ist `discovery.ease-technologies.de`. Das abgeschlossene Linux-MVP
|
||||||
bleibt eine eigenständige Abnahme. Dieser Bericht erweitert dessen Umfang nicht.
|
bleibt eine eigenständige Abnahme. Dieser Bericht erweitert dessen Umfang nicht.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Windows: verbleibende Umsetzung nach der passiven Foundation
|
# Windows: verbleibende Umsetzung nach der passiven Foundation
|
||||||
|
|
||||||
Stand 2026-11-14, Spezifikation1.15. **Umsetzungsplan, keine native Abnahme.**
|
Stand 2026-11-14, Spezifikation1.16. **Umsetzungsplan, keine native Abnahme.**
|
||||||
Linux-M0–M5 bleiben separat abgeschlossen. Der Windows-Testgast ist ein eigenes
|
Linux-M0–M5 bleiben separat abgeschlossen. Der Windows-Testgast ist ein eigenes
|
||||||
Gerät; das Notebook bleibt Entwicklungsrechner. Server bleibt
|
Gerät; das Notebook bleibt Entwicklungsrechner. Server bleibt
|
||||||
`discovery.ease-technologies.de`. RustDesk, PVE und M7 werden nicht vorgezogen.
|
`discovery.ease-technologies.de`. RustDesk, PVE und M7 werden nicht vorgezogen.
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
# Getrennte Windows-SYSTEM-Policy: Source-Stand
|
||||||
|
|
||||||
|
Stand 2026-11-14: Die Serverstrecke ist **implementiert, lokal geprüft und mit
|
||||||
|
13 ausgewählten reinen Policytests auf der tatsächlichen Cloud-Linux-VM geprüft**.
|
||||||
|
Sie wurde nicht auf den Cloudserver ausgerollt und nicht über einen echten
|
||||||
|
Windows-SYSTEM-Job abgenommen. Kein Principal erhielt ein neues Recht; keine
|
||||||
|
Policydatei oder Capability wurde installiert/veröffentlicht. Domain, Shared Core,
|
||||||
|
Windowsquellen, deren laufende native Qualifikation und WebUI bleiben unverändert.
|
||||||
|
Die derzeitige gemeinsame `Action::available_for` verweigert Windows-SCM weiterhin.
|
||||||
|
|
||||||
|
`system` ist eine explizite eigene Ausführungsidentität. Der Dispatcher in
|
||||||
|
`root_policy::authorize` führt ausschließlich diese Identität zur neuen
|
||||||
|
`windows_policy`; `root` bleibt der Linux-Root-Pfad. Unbekannte Identitäten werden
|
||||||
|
verweigert. Eine Windowsbasis-Capability kann auch mit Rootcaps keine Rootpolicy
|
||||||
|
erlangen. `root:execute` enthält niemals `system:execute`.
|
||||||
|
|
||||||
|
## Eng begrenzter Serververtrag
|
||||||
|
|
||||||
|
Die Policy wird ausschließlich bei `RMM_PROFILE=development`,
|
||||||
|
`RMM_DEV_SYSTEM_ENABLED=true` und gesetztem `RMM_DEV_SYSTEM_POLICY_FILE` gelesen.
|
||||||
|
Fehlende, abgelaufene, unbekannte oder ungültige Konfiguration verweigert. Der
|
||||||
|
Loader liest höchstens 64 KiB von einer regulären Datei mit Modus **0600** und der
|
||||||
|
UID der administrativen Job-Signierdatei. Von dieser Schlüsseldatei werden nur
|
||||||
|
Metadaten gelesen, keine privaten Schlüsselbytes. Symlinks in Dateipfad oder
|
||||||
|
Signing-Key-Pfad sind verboten. Der unmittelbare Parent muss ein geschütztes
|
||||||
|
Verzeichnis im Besitz von Root oder dieser UID ohne Gruppen-/Fremdschreibrechte
|
||||||
|
sein. Der offene Dateideskriptor und der anschließende lstat müssen dieselbe
|
||||||
|
Dateiidentität und unveränderte Metadaten besitzen; ungeschützte oder wechselnde
|
||||||
|
Dateien werden nicht als Policy akzeptiert.
|
||||||
|
Auch sämtliche Verzeichnisvorfahren müssen Root oder dieser UID gehören.
|
||||||
|
Beschreibbare Vorfahren werden nur mit Sticky-Bit akzeptiert, das zusammen mit
|
||||||
|
der vertrauenswürdigen Besitzerkette das Ersetzen des nächsten Bestandteils
|
||||||
|
verhindert; der direkte Parent bleibt ohne Gruppen-/Fremdschreibrecht.
|
||||||
|
Die Kette wird nach dem Lesen erneut geprüft. Ein nur privater direkter Parent
|
||||||
|
unter einem unsicheren nicht-sticky Vorfahren genügt nicht.
|
||||||
|
|
||||||
|
Das JSON-Schema enthält `schema_version=1`, `profile=development`, ein zukünftiges
|
||||||
|
`expires_at` und bis zu 64 `scopes`. Jeder Scope bindet exakt Tenant-, Asset- und
|
||||||
|
Agent-UUID, Enrollmentgeneration, Assignmentversion und eine begrenzte Liste
|
||||||
|
expliziter Principalnamen. Pflicht sind außerdem `helper_policy_sha256`,
|
||||||
|
`helper_binary_sha256`, eine nichtleere UUID `acceptance_evidence_id`, eine
|
||||||
|
Fixture-Dienstallowlist und `max_runtime_seconds` zwischen 1 und 120. Unbekannte
|
||||||
|
Felder werden abgewiesen. Die Evidence-UUID ist eine administrative Nachweispin;
|
||||||
|
sie erzeugt weder eine Genehmigung noch eine Autorisierung.
|
||||||
|
|
||||||
|
Erlaubt ist ausschließlich `set_service_state` für einen expliziten Namen
|
||||||
|
`RmmDiscoveryFixture…` mit ASCII-Buchstaben/Ziffern/Unterstrich/Bindestrich und
|
||||||
|
Zielzustand `running` oder `stopped`. Eigener Agent/Helper, fremde Dienste,
|
||||||
|
`restarted`, freie SYSTEM-Skripte, Pakete, Logs und Reboots erhalten keine
|
||||||
|
Berechtigung aus diesem Slice. Eine leere Allowlist erlaubt keine Wirkung.
|
||||||
|
Ausgabe und Laufzeit werden zusätzlich auf 64 KiB und den konkreten Scopewert
|
||||||
|
begrenzt. Die Policy ersetzt keine unabhängige lokale Helperpolicy oder deren
|
||||||
|
strengere SCM-/Prozess-/Abhängigkeits-/Recoveryprüfungen.
|
||||||
|
|
||||||
|
Der spätere tatsächliche Agent muss alle folgenden Caps besitzen; derzeit
|
||||||
|
veröffentlicht diese Änderung keine davon:
|
||||||
|
|
||||||
|
| Pflicht | Zweck |
|
||||||
|
| --- | --- |
|
||||||
|
| `windows.base/1`, ohne `linux.base/1` | Eindeutige Windowsplattform |
|
||||||
|
| `rmm.sync.v1` | Signed-Sync-Vertrag |
|
||||||
|
| `helper.system.v1` | Getrennte SYSTEM-Helperrolle |
|
||||||
|
| `helper.policy.sha256:<exakter Hash>` | Übereinstimmende lokale Policy |
|
||||||
|
| `helper.binary.sha256:<exakter Hash>` | Übereinstimmendes Helperimage |
|
||||||
|
| `system:set_service_state` und `set_service_state` | Expliziter typisierter SCM-Adapter |
|
||||||
|
|
||||||
|
## Unveränderte Genehmigungsgrenze und zusätzliche Verweigerungen
|
||||||
|
|
||||||
|
Planung und Submit prüfen `system:execute` sowohl gegen den tatsächlichen
|
||||||
|
Principal-Scope als auch gegen die aktuellen DB-Mitgliedschaftsrechte. Submit
|
||||||
|
prüft zusätzlich die konkrete Policy für seinen Akteur. Revalidation prüft die
|
||||||
|
unveränderlichen Jobs erneut für den ursprünglichen Planprincipal. Eine neue
|
||||||
|
WebUI-Genehmigung verlangt denselben zusätzlichen Scope und die aktuelle Policy
|
||||||
|
für den interaktiven Genehmiger. Bestehende `pending_approval`-Persistenz,
|
||||||
|
Plan-/Hashbindung und interaktive UI-Grenze bleiben erhalten. Keine neue
|
||||||
|
MCP-/API-/DB-Genehmigungsabkürzung existiert.
|
||||||
|
|
||||||
|
Delivery und Start prüfen die aktuelle Policy erneut für Planprincipal und
|
||||||
|
Genehmiger. Ein Startgrant für `root` **oder** `system` benötigt zusätzlich
|
||||||
|
`helper_sync_ready` und tatsächlich einen nichtleeren Helperjournal-Eintrag im
|
||||||
|
gebundenen Server-Synczustand. Sync setzt ohne Helperjournal keine Ready-Lease
|
||||||
|
für solche Versuche und gibt keinen Unlock aus. Die Verarbeitung erhaltener
|
||||||
|
Outcomes bleibt bestehen; ein fehlender Helper darf keine zweite Wirkung oder
|
||||||
|
blindes Wiederholen autorisieren.
|
||||||
|
|
||||||
|
## Tatsächliche Prüfungen und verbleibende Arbeit
|
||||||
|
|
||||||
|
Vier neue gezielte Tests bestanden: exakte Ziel-/Principal-/Hashbindung,
|
||||||
|
getrennte Root-/SYSTEM-Scopes und Helperanforderung, enge SCM-Wirkungsgrenze,
|
||||||
|
sowie Datei-/Owner-/Mode-/Symlink-/Parent-/Größenfehler. Neun bestehende
|
||||||
|
Rootpolicy-/Logpolicytests bestanden einschließlich einer zusätzlichen
|
||||||
|
Windows-Relabel-Verweigerung. Server-Clippy mit `--all-targets -D warnings` bestand.
|
||||||
|
Danach dieselben13 exakt benannten Tests nativ auf der Cloud-Linux-VM bestanden,
|
||||||
|
Fall `13b11ce4-7462-4bc4-9bbb-113bf5c9b034`, Release-Testbinary
|
||||||
|
`ca1df8b28a8ad5e2183fcbb876a35a5c34acb43c2ad41e90a7f81fb48856c884`,
|
||||||
|
Manifest `build-09ea8b57…`.52 Buildquellen und der feste Runner sind gehasht.
|
||||||
|
Jeder Test lief einzeln mit geleerter Umgebung, privatem Tempverzeichnis,
|
||||||
|
eigener Netzwerknamespace und begrenzter Laufzeit/Ausgabe;13 bestanden,
|
||||||
|
0 fehlgeschlagen,0 ignoriert. Der Datei-Guard verweigerte auch den unsicheren
|
||||||
|
nicht-sticky Vorfahren und akzeptierte den vertrauenswürdigen Sticky-Fall.
|
||||||
|
Runner: [`cloud_windows_policy_native.py`](../deploy/cloud_windows_policy_native.py).
|
||||||
|
Das ist ein nativer Linux-Unitnachweis der zentralen Regeln, keine DB-/WebUI-/
|
||||||
|
Windows-SYSTEM-Jobabnahme. Es wurden kein Serverdaemon oder DB-Test gestartet,
|
||||||
|
keine Dienste ersetzt, Schlüssel/Journale gelesen oder RMM-Jobs erzeugt.
|
||||||
|
Geschützte Rohbelege liegen unter `devstate/server-windows-policy/<Fall>/`.
|
||||||
|
|
||||||
|
Der nächste kleine Integrationspatch bleibt **geplant, nicht ausgeführt**:
|
||||||
|
Nach nativer Helper-/Clock-/SCM-Qualifikation im Shared Domain ausschließlich den
|
||||||
|
Windows-`SetServiceState`-Zweig für `system` und diese expliziten Caps ergänzen;
|
||||||
|
alle anderen Windows-SYSTEM-Aktionen bleiben verweigert. Danach im Agenten den
|
||||||
|
bereits typisierten Helper-Execute-Pfad mit unabhängiger Helper-Sync-Bestätigung
|
||||||
|
und erhaltenem Grant-/Outcomeledger anbinden. Die WebUI muss die konkrete
|
||||||
|
SYSTEM-Identität sichtbar im unveränderlichen SCM-Plan darstellen und weiterhin
|
||||||
|
interaktiv genehmigen. Erst nach gesondert geprüftem Policy-/Rechtesetup folgen
|
||||||
|
neue tatsächliche WebUI-Pläne und unabhängige OS-Nachprüfungen. Spezifikation und
|
||||||
|
Projektentscheidungen werden vom Eltern-Orchestrator nach dem Review abgestimmt.
|
||||||
Reference in New Issue
Block a user