File size: 12,305 Bytes
7104590 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | # verify_v3.py hardening patch
#
# pre-hardening sha256 507a53d2c6fd38fba3eb4cbe50c73cb43c1689061920f944c18995b748afcc3d (attested in sha256sums.txt line 30)
# post-hardening sha256 d6c1d4299aab831d61174daea651e8e779b6fa46ae7279cc17bd33a6de1f47c4
#
a/verify_v3.py 2026-08-10 19:40:29.385003841 -0400
+++ b/verify_v3.py 2026-08-10 19:43:40.148932456 -0400
@@ -29,10 +29,12 @@
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
+import exclusivity_model # noqa: E402
import preflight # noqa: E402
import privilege_graph # noqa: E402
ATTACK_RESULTS = os.path.join(HERE, "attack_results.json")
+TOPOLOGY = os.path.join(HERE, "PRIVILEGE_TOPOLOGY.json")
CARRIER_MATRIX = os.path.join(HERE, "carrier_matrix.json")
REGISTRY = os.path.join(HERE, "ROOT_EQUIVALENCE_REGISTRY.json")
ANALYSIS = os.path.join(HERE, "AUTHORITY_PRINCIPAL_ANALYSIS.json")
@@ -40,16 +42,17 @@
HISTORY_PATH = os.path.join(HERE, "run_history.jsonl")
REQUIRED_IDENTICAL_RUNS = 4
-VERIFIED = "VERIFIED_EXCLUSIVE_AUTHORITY"
-BLOCKED_ROOT = "BLOCKED_ROOT_EQUIVALENCE"
-BLOCKED_AUTHORITY = "BLOCKED_AUTHORITY_EQUIVALENCE"
+VERIFIED = exclusivity_model.VERIFIED
+BLOCKED_ROOT = exclusivity_model.BLOCKED_ROOT
+BLOCKED_AUTHORITY = exclusivity_model.BLOCKED_AUTHORITY
+BLOCKED_UNCERTAIN = exclusivity_model.BLOCKED_UNCERTAIN
INTEGRATION_BLOCKED = "INTEGRATION_BLOCKED"
PROVABLY_UNREACHABLE = "PROVABLY_UNREACHABLE"
ENV_NOT_EQUIVALENT = "ENVIRONMENT_NOT_EQUIVALENT"
#: Conditions whose failure is caused by the host's privilege configuration
#: rather than by the architecture. Used to compute the conditional result.
-CUTOVER_DEPENDENT = {"06", "07", "12", "17"}
+CUTOVER_DEPENDENT = {"06", "07", "12", "17", "19"}
def die(label: str, message: str) -> None:
@@ -64,7 +67,13 @@
return subprocess.run(argv, cwd=HERE, capture_output=True, text=True, timeout=1800)
-def conditions_from(attacks: dict, registry: dict, analysis: dict, graph: dict) -> dict:
+def conditions_from(
+ attacks: dict,
+ registry: dict,
+ analysis: dict,
+ graph: dict,
+ topology: dict | None = None,
+) -> dict:
carriers = {entry["carrier"]: entry for entry in attacks["carriers"]}
attack = attacks["attacks"]
protocol = attacks["protocol"]
@@ -241,6 +250,13 @@
# Condition 18 is filled in by `repeatability()` once the verdict and digest
# for this run are known; it is the only condition that cannot be evaluated
# from a single run's measurements.
+ #
+ # Condition 19 is the hardening added after the cutover preflight found that
+ # `registry["unknown_paths"]` was recorded and consumed by nothing: a host
+ # whose only remaining escalation path was UNKNOWN would have been reported
+ # VERIFIED. It unions the registry's UNKNOWNs with the read-only topology
+ # inventory's.
+ conditions["19"] = exclusivity_model.unknown_condition(registry, topology)
return conditions
@@ -275,7 +291,7 @@
)
return {
"text": f"{REQUIRED_IDENTICAL_RUNS} consecutive verifier runs produce the "
- f"same result and evidence digest",
+ f"same result and evidence digest",
"met": identical,
"evidence": {
"runs_recorded": len(history),
@@ -289,8 +305,11 @@
def property_split(conditions: dict, registry: dict) -> dict:
"""Section 15: three properties that fail independently."""
dac = all(conditions[key]["met"] for key in ("03", "04", "05"))
+ # 19 belongs to exclusivity: an unresolved escalation path is exactly the
+ # question "can the agent obtain equivalent capability", left unanswered.
exclusivity = all(
- conditions[key]["met"] for key in ("06", "07", "08", "09", "10", "11", "12")
+ conditions[key]["met"]
+ for key in ("06", "07", "08", "09", "10", "11", "12", "19")
)
liveness = all(conditions[key]["met"] for key in ("13", "14", "15", "16"))
return {
@@ -318,8 +337,11 @@
# architecture or of the host's privilege configuration. Counting it as an
# architectural failure while the run window fills would misreport every
# run before the fourth.
- failed = [key for key, entry in conditions.items()
- if entry["met"] is False and key != "18"]
+ failed = [
+ key
+ for key, entry in conditions.items()
+ if entry["met"] is False and key != "18"
+ ]
failed_independent = [
key for key in failed if not conditions[key].get("cutover_dependent")
]
@@ -342,8 +364,9 @@
}
-def evidence_digest(attacks: dict, registry: dict, analysis: dict,
- graph: dict, conditions: dict) -> str:
+def evidence_digest(
+ attacks: dict, registry: dict, analysis: dict, graph: dict, conditions: dict
+) -> str:
"""A digest over the security-relevant surface only.
Built from an explicit whitelist rather than by filtering volatile keys out
@@ -354,32 +377,42 @@
hashed.
"""
surface = {
- "carriers": {entry["carrier"]: entry["verdict"]
- for entry in attacks["carriers"]},
+ "carriers": {
+ entry["carrier"]: entry["verdict"] for entry in attacks["carriers"]
+ },
"attacks": {
"D_subuid": attacks["attacks"]["D_subuid"]["verdict"],
"E_setns_procfs": attacks["attacks"]["E_setns"]["procfs_route"]["verdict"],
"E_setns_docker": attacks["attacks"]["E_setns"]["docker_route"]["verdict"],
"F_ptrace": attacks["attacks"]["F_ptrace"]["verdict"],
"F_ptrace_control": attacks["attacks"]["F_ptrace"][
- "control_attached_agent_owned_process"],
+ "control_attached_agent_owned_process"
+ ],
"H_rootful": attacks["attacks"]["container_roots"][
- "H_rootful_container_root"]["verdict"],
+ "H_rootful_container_root"
+ ]["verdict"],
"I_rootless": attacks["attacks"]["container_roots"][
- "I_rootless_container_root"]["verdict"],
- "J1": attacks["attacks"]["J_broker_replacement"][
- "J1_host_write_to_code"]["verdict"],
+ "I_rootless_container_root"
+ ]["verdict"],
+ "J1": attacks["attacks"]["J_broker_replacement"]["J1_host_write_to_code"][
+ "verdict"
+ ],
"J2": attacks["attacks"]["J_broker_replacement"][
- "J2_docker_cp_into_container"]["verdict"],
+ "J2_docker_cp_into_container"
+ ]["verdict"],
"K_socket": attacks["attacks"]["K_socket_impersonation"]["verdict"],
"Q_key": attacks["attacks"]["Q_key_material"]["verdict"],
},
- "protocol": {name: entry.get("pass")
- for name, entry in attacks["protocol"].items()
- if isinstance(entry, dict)},
- "leakage": {name: entry.get("verdict")
- for name, entry in attacks["leakage"].items()
- if isinstance(entry, dict)},
+ "protocol": {
+ name: entry.get("pass")
+ for name, entry in attacks["protocol"].items()
+ if isinstance(entry, dict)
+ },
+ "leakage": {
+ name: entry.get("verdict")
+ for name, entry in attacks["leakage"].items()
+ if isinstance(entry, dict)
+ },
"git_all_passed": attacks["workspace_git"]["all_passed"],
"git_check_count": attacks["workspace_git"]["count"],
"identity_separation": {
@@ -387,8 +420,10 @@
"broker_uid": attacks["environment"]["broker_uid"],
"decision_uid": attacks["environment"]["decision_uid"],
},
- "registry": {name: entry["classification"]
- for name, entry in registry["mechanisms"].items()},
+ "registry": {
+ name: entry["classification"]
+ for name, entry in registry["mechanisms"].items()
+ },
"root_equivalent_paths": sorted(registry["root_equivalent_paths"]),
"authority_uid": analysis["selected_authority_uid"],
"graph_edges": sorted(
@@ -396,8 +431,9 @@
for entry in graph["edges"]
),
"graph_closed": graph["closure"]["closed"],
- "conditions": {key: entry["met"] for key, entry in conditions.items()
- if key != "18"},
+ "conditions": {
+ key: entry["met"] for key, entry in conditions.items() if key != "18"
+ },
}
return hashlib.sha256(
json.dumps(surface, sort_keys=True, separators=(",", ":")).encode()
@@ -431,6 +467,16 @@
if analysis_run.returncode != 0 or not os.path.exists(ANALYSIS):
die(BLOCKED_ROOT, f"analysis failed: {analysis_run.stderr.strip()[:400]}")
+ topology_run = run_stage(
+ "privilege topology inventory",
+ [sys.executable, os.path.join(HERE, "privilege_topology.py")],
+ )
+ if topology_run.returncode != 0 or not os.path.exists(TOPOLOGY):
+ die(
+ BLOCKED_UNCERTAIN,
+ f"topology inventory failed: {topology_run.stderr.strip()[:400]}",
+ )
+
attacks_run = run_stage(
"attack suite",
[sys.executable, os.path.join(HERE, "attack_suite", "run_attacks_v3.py")],
@@ -445,18 +491,23 @@
with open(ANALYSIS, encoding="utf-8") as handle:
analysis = json.load(handle)
+ with open(TOPOLOGY, encoding="utf-8") as handle:
+ topology = json.load(handle)
+
graph = privilege_graph.build_and_save(attacks, registry)
- conditions = conditions_from(attacks, registry, analysis, graph)
+ conditions = conditions_from(attacks, registry, analysis, graph, topology)
digest = evidence_digest(attacks, registry, analysis, graph, conditions)
- # Section 16's ordering: root-equivalence dominates everything else.
- if registry["agent_is_root_equivalent"]:
- verdict = BLOCKED_ROOT
- elif not graph["closure"]["conditions"]["no_path_to_authority_principal"]["holds"]:
- verdict = BLOCKED_AUTHORITY
- elif all(entry["met"] for key, entry in conditions.items() if key != "18"):
- verdict = VERIFIED
- else:
- verdict = BLOCKED_AUTHORITY
+ # Section 16's ordering, now computed by exclusivity_model: root-equivalence
+ # dominates everything, then authority-equivalence, then UNRESOLVED privilege
+ # paths -- which can no longer be silently absorbed into a VERIFIED verdict.
+ exclusivity = exclusivity_model.compute(
+ registry,
+ topology,
+ graph["closure"],
+ conditions,
+ ignore_conditions={"18"},
+ )
+ verdict = exclusivity["verdict"]
conditions["18"] = repeatability(verdict, digest)
split = property_split(conditions, registry)
@@ -478,6 +529,12 @@
"privilege_graph_closure": graph["closure"],
"root_equivalent_paths": registry["root_equivalent_paths"],
"unknown_paths": registry["unknown_paths"],
+ "exclusivity": exclusivity,
+ "privilege_topology": {
+ "counts": topology["counts"],
+ "root_equivalent_paths": topology["root_equivalent_paths"],
+ "unknown_privilege_paths": topology["unknown_privilege_paths"],
+ },
"selected_authority_uid": analysis["selected_authority_uid"],
"prior_packages_unchanged": prior_unchanged,
"environment_equivalence": pre["environment_equivalence"],
@@ -518,7 +575,15 @@
f"{conditional['would_hold_after_cutover']}"
)
print()
- print(f"root-equivalent paths: {registry['root_equivalent_paths']}")
+ print(f"root-equivalent paths: {exclusivity['root_equivalent_paths']}")
+ print(
+ f"unresolved privilege paths: "
+ f"{len(exclusivity['unknown_privilege_paths'])} "
+ f"{exclusivity['unknown_privilege_paths'][:4]}"
+ f"{' ...' if len(exclusivity['unknown_privilege_paths']) > 4 else ''}"
+ )
+ for reason in exclusivity["reasons"]:
+ print(f" verdict reason: {reason}")
print(f"privilege graph closed: {graph['closure']['closed']}")
print(f"prior packages unchanged: {prior_unchanged}")
print(f"evidence digest: {result['evidence_digest'][:32]}")
|