TOFU (Trust-On-First-Use) Security Model
Date: December 18, 2025
Status: Implemented
Component: icn-net TLS layer
Overview
ICN implements a Trust-On-First-Use (TOFU) security model that balances network openness with security verification. This document describes the architecture, rationale, and security properties of the TOFU implementation.
Architecture
Three-Layer Security Model
- TLS Layer (Transport): Mutual TLS with permissive client cert acceptance
- Application Layer (Protocol): DID-TLS binding verification in Hello messages
- Authorization Layer (Access Control): Trust graph-based authorization
TLS Handshake Flow
Client Server
| |
|-- ClientHello --------------->|
|<----------- ServerHello ------|
|<----------- Certificate ------|
|<----- CertificateRequest -----| (requests client cert)
| |
|-- Certificate --------------->| (client sends self-signed cert)
|-- CertificateVerify --------->|
|-- Finished ------------------>|
|<----------- Finished ---------|
| |
[TLS session established] |
| |
|-- Hello (DID + X25519) ------>|
| | [Verify DID-TLS binding]
| | [Check trust score]
|<----------- HelloAck ---------|
Security Properties
What TOFU Provides
- Cryptographic Authentication: Ed25519 signatures verify TLS handshake integrity
- Confidentiality: TLS 1.3 encryption protects all traffic
- Certificate Binding: DID is bound to TLS certificate in SAN field
- Trust-Based Authorization: Trust graph enforces access control
- Replay Protection: Sequence numbers prevent replay attacks
What TOFU Doesn't Provide
- Pre-Connection Trust Verification: First connection happens before trust verification
- PKI Infrastructure: No certificate authorities or trust chains
- Revocation: Requires application-layer mechanisms
Implementation Details
TofuCertificateVerifier
Located in icn-net/src/tls.rs, this implements rustls::server::danger::ClientCertVerifier:
#[derive(Debug)]
struct TofuCertificateVerifier {}
impl ClientCertVerifier for TofuCertificateVerifier {
fn offer_client_auth(&self) -> bool {
true // Request client certificates
}
fn client_auth_mandatory(&self) -> bool {
false // Don't fail TLS if client doesn't send cert
}
fn verify_client_cert(&self, ...) -> Result<ClientCertVerified, Error> {
// Accept any certificate - verification deferred to Hello handler
Ok(ClientCertVerified::assertion())
}
fn verify_tls13_signature(&self, ...) -> Result<HandshakeSignatureValid, Error> {
// Verify Ed25519 signature on TLS handshake
verifying_key.verify(message, &signature)?;
Ok(HandshakeSignatureValid::assertion())
}
}
Hello Message Verification
The application layer verifies DID-TLS binding:
- Extract DID from Hello message
- Extract DID from peer TLS certificate SAN field
- Verify they match
- Verify X25519 encryption key signature
- Query trust graph for authorization decision
Threat Model
Threats Mitigated
| Threat | Mitigation |
|---|---|
| Man-in-the-Middle | TLS 1.3 mutual authentication |
| Replay Attacks | Sequence numbers + Bloom filter |
| Identity Spoofing | DID-TLS binding verification |
| Unauthorized Access | Trust graph authorization |
| Traffic Analysis | TLS encryption |
Threats Requiring Additional Defenses
| Threat | Defense Mechanism |
|---|---|
| Sybil Attacks | Trust graph + rate limiting |
| Byzantine Behavior | MisbehaviorDetector quarantine |
| Resource Exhaustion | Connection limits + timeouts |
| First-Use Attacks | Bootstrap trust establishment |
Security Rationale
Why TOFU Instead of Strict Pre-Verification?
- Network Bootstrap: Nodes need to connect before establishing trust
- Decentralization: No central authority to verify certificates
- Flexibility: Trust relationships evolve over time
- User Experience: Reduces friction for legitimate connections
Why Not PKI or Certificate Authorities?
- Single Point of Failure: CA compromise affects all nodes
- Centralization: Contradicts ICN's decentralized architecture
- Cost & Complexity: Requires certificate management infrastructure
- Trust Mismatch: Social trust != hierarchical CA trust
Comparison with Other Models
| Model | Bootstrap | Flexibility | Security | Implementation |
|---|---|---|---|---|
| PKI | Medium | Low | High | Complex |
| Web-of-Trust | Easy | High | Medium | Medium |
| TOFU (ICN) | Easy | High | Medium-High | Simple |
| Pre-Shared Keys | Hard | Low | High | Simple |
Testing
All previously flaky tests now pass reliably:
test_contract_deployment_integration(7 tests)test_topology_integration(6 tests)
These tests verify:
- Multi-node gossip synchronization
- Contract deployment across trust boundaries
- Regional topology formation
- Peer sampling with trust awareness
Future Enhancements
Potential Improvements
- Cert Pinning: Remember first-seen certificates
- Trust Attestations: Third-party trust vouchers
- Revocation Lists: Distributed revocation mechanism
- Threshold Signatures: Multi-party cert issuance
- Post-Quantum Crypto: Hybrid key exchange
Migration Path
If stricter security is needed:
- Add
min_trust_thresholdto TLS verifier (>0.0) - Implement cert pinning for known peers
- Add trust attestation gossip protocol
- Deploy distributed revocation system
References
See Also
- docs/ARCHITECTURE.md - Overall system architecture
- docs/security/production-hardening.md - Security hardening measures
- icn/crates/icn-net/src/tls.rs - TLS implementation
- icn/crates/icn-net/src/actor/mod.rs - Hello message handling