Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chapter 9: Security, Safety, and Correctness

Motivation

Traditional systems add security through layers of checks, monitors, and access controls. Memory safety requires bounds checking, garbage collection, or ownership rules. Correctness demands formal proofs often divorced from the actual implementation.

In the Hologram model, these properties aren’t added—they emerge from the fundamental structure. Type errors are physically impossible. Memory corruption cannot occur. Security vulnerabilities are conservation law violations that literally cannot exist. This chapter explores how lawfulness provides intrinsic safety.

Intrinsic Type Safety

Type Errors as Physical Impossibilities

In traditional systems:

int* ptr = (int*)"hello";  // Type confusion
*ptr = 42;                  // Undefined behavior

In the Hologram model:

string_obj = create_string("hello")  # R96 class 17
int_type = IntType()                 # Expects R96 class 42

# Attempting type confusion
try:
    cast_to_int(string_obj)
except ConservationViolation:
    # Cannot change R96 class without budget
    # At budget 0, cast is impossible
    print("Type cast violates conservation laws")

Theorem 9.1 (Type Safety): Well-typed programs cannot produce type errors at runtime.

Proof: Types are R96 equivalence classes. Operations preserve R96 (conservation law). Therefore, type is invariant during execution. □

No Type Confusion

Definition 9.1 (Type Confusion Impossibility): An object cannot be interpreted as a different type without explicit budget expenditure.

This eliminates:

  • Use-after-free (freed memory has different R96)
  • Type confusion attacks
  • Vtable hijacking
  • Return-oriented programming

The Safety Receipt

Every operation produces a safety receipt:

#![allow(unused)]
fn main() {
struct SafetyReceipt {
    type_preserved: bool,      // R96 unchanged
    bounds_checked: bool,       // Within lattice bounds
    ownership_valid: bool,      // Unique owner verified
    lifetime_valid: bool,       // Object still alive
    integrity_hash: [u8; 32],  // Content unchanged
}
}

Memory Safety

No Pointers, No Problems

The Hologram model has no pointers—only content addresses:

Traditional pointer problems:

  • Dangling pointers
  • Buffer overflows
  • Double frees
  • Memory leaks
  • Race conditions

Hologram solutions:

  • Content addresses are immutable
  • Lattice has fixed bounds
  • No explicit allocation/deallocation
  • Garbage collection via unreachable addresses
  • No mutable aliasing

Bounds Are Physics

Definition 9.2 (Lattice Bounds): All addresses are in T = ℤ/48 × ℤ/256.

Attempting to access outside T:

def access(page, byte):
    # Automatic modular arithmetic
    actual_page = page % 48
    actual_byte = byte % 256
    return lattice[actual_page][actual_byte]

# No buffer overflow possible!
access(1000, 5000)  # Wraps to (40, 136)

Spatial Memory Safety

Theorem 9.2 (Spatial Safety): No operation can access memory outside allocated regions.

Proof: All addresses are content-determined. Content hash maps to valid lattice site. No arbitrary address construction possible. □

Temporal Memory Safety

Theorem 9.3 (Temporal Safety): No operation can access freed memory.

Proof: “Freed” memory changes content (zeroing). Changed content → different address. Old address no longer resolves to freed location. □

Integrity & Non-interference

Information Flow Control

The Hologram model tracks information flow through receipts:

class InfoFlow:
    def __init__(self):
        self.taint_map = {}  # Site → SecurityLevel

    def propagate(self, source, dest, operation):
        source_level = self.taint_map.get(source, PUBLIC)

        # Information flows with operations
        if operation.increases_level():
            dest_level = upgrade_level(source_level)
        else:
            dest_level = source_level

        self.taint_map[dest] = dest_level

        # Generate flow receipt
        return FlowReceipt(
            source=source,
            dest=dest,
            level_change=source_level != dest_level,
            operation=operation
        )

Non-Interference Property

Definition 9.3 (Non-Interference): Low-security observations cannot depend on high-security inputs.

Theorem 9.4 (Receipt-Based Non-Interference): Programs with verified flow receipts satisfy non-interference.

Proof: Flow receipts track all information movement. Verification ensures no high→low flows. Therefore, low outputs independent of high inputs. □

Integrity via Conservation

Data integrity is a conservation law:

def verify_integrity(original, current):
    original_receipt = compute_receipt(original)
    current_receipt = compute_receipt(current)

    # Check R96 preservation
    if original_receipt.r96 != current_receipt.r96:
        return False, "Resonance violation"

    # Check authorized modifications only
    if not authorized_transform(original_receipt, current_receipt):
        return False, "Unauthorized modification"

    return True, "Integrity preserved"

Collision Resistance

Perfect Hashing Guarantee

Theorem 9.5 (Collision-Free Addressing): For lawful objects a,b: H(a) = H(b) ⟺ a ≡ᵍ b

This means:

  • No hash collisions for distinct lawful objects
  • Automatic deduplication
  • Content-addressable storage is secure

Birthday Attack Immunity

Traditional hashes suffer from birthday attacks:

  • n-bit hash → √(2ⁿ) trials for collision

Hologram hashes are different:

  • Lawfulness constraint eliminates most space
  • Gauge equivalence identifies semantically identical objects
  • Effective security much higher than bit count suggests

Cryptographic Properties

def hologram_hash_properties():
    # Preimage resistance
    # Given h, cannot find x where H(x) = h without lawful x

    # Second preimage resistance
    # Given x₁, cannot find x₂ where H(x₁) = H(x₂) unless x₁ ≡ᵍ x₂

    # Collision resistance
    # Cannot find any x₁,x₂ where H(x₁) = H(x₂) unless x₁ ≡ᵍ x₂

Defense Against Common Attacks

Buffer Overflow

Traditional buffer overflow:

char buffer[10];
strcpy(buffer, attacker_controlled);  // Overflow!

Hologram defense:

def safe_copy(dest_region, source):
    # Regions have fixed size in lattice
    dest_size = region_size(dest_region)
    source_size = len(source)

    if source_size > dest_size:
        # Cannot overflow - physics prevents it
        raise ConservationViolation("Would exceed region")

    # Copy preserves receipts
    copy_with_receipt(dest_region, source)

SQL Injection

Traditional SQL injection:

query = f"SELECT * FROM users WHERE name = '{user_input}'"
# user_input = "'; DROP TABLE users; --"

Hologram defense:

def safe_query(table, condition):
    # Queries are lawful objects with types
    query_obj = create_query(
        table=table,       # Type: TableReference
        condition=condition # Type: Condition
    )

    # Verify query lawfulness
    receipt = compute_receipt(query_obj)
    if not verify_receipt(receipt):
        raise ValueError("Malformed query")

    # Execute only lawful queries
    return execute_lawful(query_obj)

Cross-Site Scripting (XSS)

Traditional XSS:

<div>{{user_input}}</div>
<!-- user_input = <script>alert('XSS')</script> -->

Hologram defense:

def render_safe(template, data):
    # Templates and data have different R96 classes
    template_class = R96_TEMPLATE
    data_class = R96_DATA

    # Cannot mix without explicit budget
    rendered = apply_template(
        template,  # Must be R96_TEMPLATE
        data       # Must be R96_DATA
    )

    # Script injection would violate R96 conservation
    verify_no_code_injection(rendered)
    return rendered

Race Conditions

Traditional race:

# Thread 1
if balance >= amount:
    balance -= amount

# Thread 2
if balance >= amount:
    balance -= amount
# Double withdrawal!

Hologram solution:

def atomic_withdraw(account, amount):
    # Operations are atomic process objects
    withdraw_process = create_process(
        operation=WITHDRAW,
        account=account,
        amount=amount
    )

    # C768 schedule ensures atomicity
    schedule_slot = assign_c768_slot(withdraw_process)

    # Only one operation per slot
    execute_at_slot(withdraw_process, schedule_slot)

Formal Verification Integration

Receipts as Proofs

Every execution produces a proof:

def verified_execution(program, input):
    # Execute
    result, trace = execute_with_trace(program, input)

    # Extract proof from trace
    proof = trace_to_proof(trace)

    # Verify proof
    if not verify_proof(proof, program.spec):
        raise VerificationError("Execution doesn't meet spec")

    return VerifiedResult(
        value=result,
        proof=proof,
        receipt=compute_receipt(trace)
    )

Compositional Verification

def compose_verified(f, g):
    # f: A → B with proof P_f
    # g: B → C with proof P_g

    # Composed function
    h = lambda x: g(f(x))

    # Composed proof
    proof_h = compose_proofs(f.proof, g.proof)

    # Verification is preserved
    assert verify(h, proof_h)

    return VerifiedFunction(h, proof_h)

Implementation of Security Monitors

#![allow(unused)]
fn main() {
pub struct SecurityMonitor {
    type_checker: TypeChecker,
    flow_tracker: InfoFlowTracker,
    integrity_checker: IntegrityChecker,
}

impl SecurityMonitor {
    pub fn check_operation(&self, op: &Operation) -> SecurityReceipt {
        SecurityReceipt {
            type_safe: self.type_checker.verify(op),
            memory_safe: self.verify_memory_safety(op),
            flow_safe: self.flow_tracker.verify(op),
            integrity: self.integrity_checker.verify(op),
        }
    }

    fn verify_memory_safety(&self, op: &Operation) -> bool {
        // Check bounds
        for access in op.memory_accesses() {
            if !self.in_bounds(access) {
                return false;
            }
        }

        // Check lifetime
        for object in op.accessed_objects() {
            if !self.is_alive(object) {
                return false;
            }
        }

        true
    }
}
}

Exercises

Exercise 9.1: Prove that use-after-free is impossible in the Hologram model.

Exercise 9.2: Design a capability system using receipts. What properties does it guarantee?

Exercise 9.3: Show that timing attacks are mitigated by C768 scheduling.

Exercise 9.4: Implement a secure communication channel using conservation laws.

Exercise 9.5: Prove that verified programs cannot have undefined behavior.

Takeaways

  1. Type safety is physics: Conservation laws prevent type confusion
  2. Memory safety is automatic: No pointers, fixed bounds, content addressing
  3. Integrity via conservation: Unauthorized changes violate receipts
  4. Collision resistance is perfect: Lawful objects never collide
  5. Common attacks impossible: Buffer overflows, injections prevented by structure
  6. Verification is intrinsic: Proofs are receipts, not separate artifacts

Security isn’t added to the Hologram model—it emerges from conservation laws.


Next: Chapter 10 provides concrete micro-examples demonstrating these principles in action.