-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathattack_track_fe.py
More file actions
2025 lines (1641 loc) · 74.8 KB
/
attack_track_fe.py
File metadata and controls
2025 lines (1641 loc) · 74.8 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Track FE: LCT-Dictionary Binding Attacks (Attacks 281-286)
Attacks on the relationship between Linked Context Tokens (identity) and
Dictionary entities (meaning keepers). When identities bind to dictionaries
for semantic context, new attack surfaces emerge.
Key insight: Dictionaries transform compressed meaning between domains.
If the dictionary binding is weak, identity can be given wrong meaning.
Reference:
- whitepaper/sections/02-glossary/dictionary-entities.md
- web4-standard/core-spec/LCT-linked-context-token.md
Added: 2026-02-08
"""
import random
import hashlib
import time
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Set, Tuple
from enum import Enum
@dataclass
class AttackResult:
"""Result of an attack simulation."""
attack_name: str
success: bool
setup_cost_atp: float
gain_atp: float
roi: float
detection_probability: float
time_to_detection_hours: float
blocks_until_detected: int
trust_damage: float
description: str
mitigation: str
raw_data: Dict
# ============================================================================
# LCT-DICTIONARY INFRASTRUCTURE
# ============================================================================
class Domain(Enum):
"""Semantic domains with different compression needs."""
FINANCE = "finance"
LEGAL = "legal"
TECHNICAL = "technical"
SOCIAL = "social"
GOVERNANCE = "governance"
MEDICAL = "medical"
@dataclass
class LCT:
"""Linked Context Token - verifiable presence anchor."""
token_id: str
component: str # Component type (agent, device, service)
instance: str # Unique instance identifier
role: str # Current role
network: str # Network anchor
public_key: str
creation_block: int
attestation_chain: List[str] = field(default_factory=list)
def uri(self) -> str:
return f"lct://{self.component}:{self.instance}:{self.role}@{self.network}"
@dataclass
class DictionaryEntry:
"""Entry in a domain dictionary."""
term: str
domain: Domain
meaning: str
context_requirements: List[str]
compression_ratio: float # 0.0 = no compression, 1.0 = full compression
decompression_artifacts: List[str] # What's needed to decompress
trust_minimum: float # Minimum trust to use this meaning
@dataclass
class Dictionary:
"""Domain-specific meaning keeper."""
dictionary_id: str
domain: Domain
lct: LCT # Dictionary's own identity
entries: Dict[str, DictionaryEntry] = field(default_factory=dict)
translation_partners: Dict[str, float] = field(default_factory=dict) # dict_id -> trust
def add_entry(self, entry: DictionaryEntry):
self.entries[entry.term] = entry
def translate(self, term: str, target_domain: Domain,
target_dict: 'Dictionary') -> Optional[Tuple[str, float]]:
"""
Translate a term to another domain.
Returns (translated_meaning, trust_loss).
"""
if term not in self.entries:
return None
source_entry = self.entries[term]
# Trust loss during translation
partner_trust = self.translation_partners.get(target_dict.dictionary_id, 0.5)
trust_loss = 1.0 - partner_trust * source_entry.compression_ratio
# Find equivalent in target dictionary
for target_term, target_entry in target_dict.entries.items():
if target_entry.term == term or term in target_entry.decompression_artifacts:
return target_entry.meaning, trust_loss
return None
@dataclass
class LCTDictionaryBinding:
"""Binding between an LCT and its dictionary for semantic context."""
lct: LCT
dictionary: Dictionary
binding_strength: float # 0.0 - 1.0
binding_signature: str
binding_block: int
exclusive: bool = False # Whether LCT is bound exclusively to this dictionary
class BindingRegistry:
"""Registry of LCT-Dictionary bindings."""
def __init__(self):
self.bindings: Dict[str, List[LCTDictionaryBinding]] = {} # lct_id -> bindings
self.dictionary_lcts: Dict[str, str] = {} # dict_id -> lct_id
def register_binding(self, binding: LCTDictionaryBinding) -> bool:
"""Register a new binding."""
lct_id = binding.lct.token_id
# Check exclusivity
if lct_id in self.bindings:
existing = self.bindings[lct_id]
for b in existing:
if b.exclusive:
return False # Cannot bind, exclusive binding exists
if lct_id not in self.bindings:
self.bindings[lct_id] = []
self.bindings[lct_id].append(binding)
return True
def get_dictionary_for_lct(self, lct_id: str, domain: Domain) -> Optional[Dictionary]:
"""Get dictionary binding for an LCT in a specific domain."""
if lct_id not in self.bindings:
return None
for binding in self.bindings[lct_id]:
if binding.dictionary.domain == domain:
return binding.dictionary
return None
# ============================================================================
# ATTACK FE-1a: DICTIONARY IMPERSONATION
# ============================================================================
def attack_dictionary_impersonation() -> AttackResult:
"""
ATTACK FE-1a: Dictionary Impersonation
Create a fake dictionary with similar name/identity to a trusted one,
then bind LCTs to the fake dictionary.
Vectors:
1. Name collision
2. Visual similarity (homographs)
3. Trust transfer exploitation
4. Binding race conditions
5. Legacy compatibility attacks
"""
defenses = {
"unique_naming": False,
"lct_verification": False,
"trust_chain_validation": False,
"binding_witness": False,
"dictionary_attestation": False,
"temporal_consistency": False,
}
registry = BindingRegistry()
# Legitimate finance dictionary
legit_dict_lct = LCT(
token_id="lct_finance_main",
component="dictionary",
instance="finance_standard",
role="semantic_keeper",
network="mainnet",
public_key="pubkey_legit_abc123",
creation_block=1000,
attestation_chain=["genesis", "foundation", "finance_council"]
)
legit_dict = Dictionary(
dictionary_id="finance_standard_v2",
domain=Domain.FINANCE,
lct=legit_dict_lct
)
legit_dict.add_entry(DictionaryEntry(
term="default",
domain=Domain.FINANCE,
meaning="Failure to meet loan payment obligations",
context_requirements=["loan_context"],
compression_ratio=0.3,
decompression_artifacts=["loan_terms", "payment_history"],
trust_minimum=0.7
))
# Attack: Create fake dictionary with similar name
fake_dict_lct = LCT(
token_id="lct_finance_main_", # Trailing underscore (subtle)
component="dictionary",
instance="finance_standard", # Same instance name!
role="semantic_keeper",
network="mainnet",
public_key="pubkey_fake_xyz789",
creation_block=50000, # Much newer
attestation_chain=["fake_genesis"] # Short chain
)
fake_dict = Dictionary(
dictionary_id="finance_standard-v2", # Dash instead of underscore
domain=Domain.FINANCE,
lct=fake_dict_lct
)
fake_dict.add_entry(DictionaryEntry(
term="default",
domain=Domain.FINANCE,
meaning="Standard configuration option", # Different meaning!
context_requirements=[],
compression_ratio=0.1,
decompression_artifacts=[],
trust_minimum=0.1
))
# ========================================================================
# Vector 1: Unique Naming Defense
# ========================================================================
def check_unique_naming(dict1: Dictionary, dict2: Dictionary) -> bool:
"""Check for name collision or confusion."""
# Exact match
if dict1.dictionary_id == dict2.dictionary_id:
return False
# Levenshtein-like similarity
id1 = dict1.dictionary_id.lower().replace("-", "_")
id2 = dict2.dictionary_id.lower().replace("-", "_")
if id1 == id2:
return False
# Instance name collision
if dict1.lct.instance == dict2.lct.instance:
return False
return True
if not check_unique_naming(legit_dict, fake_dict):
defenses["unique_naming"] = True
# ========================================================================
# Vector 2: LCT Verification Defense
# ========================================================================
def verify_dictionary_lct(dictionary: Dictionary) -> bool:
"""Verify dictionary's LCT is legitimate."""
lct = dictionary.lct
# Check component type
if lct.component != "dictionary":
return False
# Check creation block (older = more trust)
if lct.creation_block > 10000: # Newer than threshold
return False
# Check attestation chain length
if len(lct.attestation_chain) < 2:
return False
return True
if not verify_dictionary_lct(fake_dict):
defenses["lct_verification"] = True
# ========================================================================
# Vector 3: Trust Chain Validation Defense
# ========================================================================
def validate_trust_chain(attestation_chain: List[str],
trusted_anchors: Set[str]) -> bool:
"""Validate attestation chain reaches trusted anchor."""
if not attestation_chain:
return False
# First element should be in trusted anchors
return attestation_chain[0] in trusted_anchors
trusted_anchors = {"genesis", "foundation"}
if not validate_trust_chain(fake_dict.lct.attestation_chain, trusted_anchors):
defenses["trust_chain_validation"] = True
# ========================================================================
# Vector 4: Binding Witness Defense
# ========================================================================
# Defense: Bindings require witness signatures
def require_binding_witness(binding: LCTDictionaryBinding,
witnesses: List[str]) -> bool:
"""Require multiple witnesses for binding."""
MIN_WITNESSES = 3
return len(witnesses) >= MIN_WITNESSES
attack_witnesses = ["witness_1"] # Only one witness (fake)
if not require_binding_witness(
LCTDictionaryBinding(
lct=fake_dict_lct,
dictionary=fake_dict,
binding_strength=0.9,
binding_signature="fake_sig",
binding_block=50001,
),
attack_witnesses
):
defenses["binding_witness"] = True
# ========================================================================
# Vector 5: Dictionary Attestation Defense
# ========================================================================
# Defense: Dictionary must have hardware attestation
def verify_dictionary_attestation(dictionary: Dictionary) -> bool:
"""Verify dictionary has valid attestation."""
# Check for known attestation providers
known_attestors = {"foundation", "finance_council", "governance_board"}
for attestor in dictionary.lct.attestation_chain:
if attestor in known_attestors:
return True
return False
if not verify_dictionary_attestation(fake_dict):
defenses["dictionary_attestation"] = True
# ========================================================================
# Vector 6: Temporal Consistency Defense
# ========================================================================
# Defense: Dictionary age must be consistent with claimed trust
def check_temporal_consistency(dictionary: Dictionary) -> bool:
"""Check dictionary age matches claimed authority."""
# Finance standard dictionary should be old
if dictionary.domain == Domain.FINANCE:
if dictionary.lct.creation_block > 5000:
return False # Too new for a "standard" dictionary
return True
if not check_temporal_consistency(fake_dict):
defenses["temporal_consistency"] = True
# ========================================================================
# Results
# ========================================================================
defenses_held = sum(defenses.values())
total_defenses = len(defenses)
attack_success = defenses_held < 4
return AttackResult(
attack_name="Dictionary Impersonation (FE-1a)",
success=attack_success,
setup_cost_atp=20000.0,
gain_atp=150000.0 if attack_success else 0.0,
roi=(150000.0 / 20000.0) if attack_success else -1.0,
detection_probability=0.70 if defenses_held >= 4 else 0.35,
time_to_detection_hours=72.0,
blocks_until_detected=500,
trust_damage=0.80,
description=f"""
DICTIONARY IMPERSONATION ATTACK (Track FE-1a)
Impersonate a trusted dictionary to hijack meaning.
Attack Pattern:
1. Create dictionary with similar name ("finance_standard-v2" vs "finance_standard_v2")
2. Copy legitimate entries with altered meanings
3. Bind target LCTs to fake dictionary
4. Exploit semantic confusion
Comparison:
- Legitimate: {legit_dict.dictionary_id} (block {legit_dict.lct.creation_block})
- Fake: {fake_dict.dictionary_id} (block {fake_dict.lct.creation_block})
- Instance collision: {legit_dict.lct.instance == fake_dict.lct.instance}
Meaning Drift:
- Legitimate "default": "{legit_dict.entries['default'].meaning}"
- Fake "default": "{fake_dict.entries['default'].meaning}"
Defense Analysis:
- Unique naming: {"HELD" if defenses["unique_naming"] else "BYPASSED"}
- LCT verification: {"HELD" if defenses["lct_verification"] else "BYPASSED"}
- Trust chain: {"HELD" if defenses["trust_chain_validation"] else "BYPASSED"}
- Binding witness: {"HELD" if defenses["binding_witness"] else "BYPASSED"}
- Dictionary attestation: {"HELD" if defenses["dictionary_attestation"] else "BYPASSED"}
- Temporal consistency: {"HELD" if defenses["temporal_consistency"] else "BYPASSED"}
Defenses activated: {defenses_held}/{total_defenses}
""".strip(),
mitigation="""
Track FE-1a: Dictionary Impersonation Defense:
1. Enforce unique naming with similarity checks
2. Verify dictionary LCT (component, age, chain)
3. Validate trust chain to known anchors
4. Require multiple witness signatures for binding
5. Dictionary hardware attestation
6. Temporal consistency (old claims = old LCTs)
Trusted meaning keepers must prove their lineage.
""".strip(),
raw_data={
"defenses": defenses,
"defenses_held": defenses_held,
"legit_dict_id": legit_dict.dictionary_id,
"fake_dict_id": fake_dict.dictionary_id,
}
)
# ============================================================================
# ATTACK FE-1b: MEANING INJECTION
# ============================================================================
def attack_meaning_injection() -> AttackResult:
"""
ATTACK FE-1b: Meaning Injection
Inject malicious meaning definitions into legitimate dictionaries
through contribution/update mechanisms.
Vectors:
1. Contribution poisoning
2. Update race conditions
3. Context manipulation
4. Compression artifact injection
5. Trust minimum manipulation
"""
defenses = {
"contribution_validation": False,
"update_consensus": False,
"context_verification": False,
"artifact_sanitization": False,
"trust_minimum_bounds": False,
"rollback_capability": False,
}
# Setup: Legitimate dictionary accepting contributions
dict_lct = LCT(
token_id="lct_legal_main",
component="dictionary",
instance="legal_standard",
role="semantic_keeper",
network="mainnet",
public_key="pubkey_legal_abc",
creation_block=500,
attestation_chain=["genesis", "foundation", "legal_council"]
)
legal_dict = Dictionary(
dictionary_id="legal_standard_v3",
domain=Domain.LEGAL,
lct=dict_lct
)
# Legitimate entry
legal_dict.add_entry(DictionaryEntry(
term="consent",
domain=Domain.LEGAL,
meaning="Voluntary agreement to terms after informed disclosure",
context_requirements=["disclosure_provided", "capacity_verified"],
compression_ratio=0.4,
decompression_artifacts=["disclosure_text", "capacity_proof"],
trust_minimum=0.8
))
# Attack: Inject poisoned entry
poisoned_entry = DictionaryEntry(
term="consent",
domain=Domain.LEGAL,
meaning="Implied agreement through continued service usage", # Weaker meaning!
context_requirements=[], # No requirements!
compression_ratio=0.9, # High compression (loses context)
decompression_artifacts=[], # No proof needed
trust_minimum=0.2 # Low trust accepted
)
# ========================================================================
# Vector 1: Contribution Validation Defense
# ========================================================================
def validate_contribution(existing: DictionaryEntry,
proposed: DictionaryEntry) -> Tuple[bool, str]:
"""Validate a proposed entry update."""
# Meaning drift check
if proposed.meaning != existing.meaning:
# Major meaning change requires high threshold
return False, "meaning_drift_detected"
# Context requirements can't be reduced
if len(proposed.context_requirements) < len(existing.context_requirements):
return False, "context_reduction"
# Trust minimum can't be lowered significantly
if proposed.trust_minimum < existing.trust_minimum * 0.8:
return False, "trust_minimum_reduction"
return True, "valid"
valid, reason = validate_contribution(legal_dict.entries["consent"], poisoned_entry)
if not valid:
defenses["contribution_validation"] = True
# ========================================================================
# Vector 2: Update Consensus Defense
# ========================================================================
# Defense: Updates require consensus from dictionary council
def require_update_consensus(entry: DictionaryEntry,
approvals: List[str],
council_members: Set[str]) -> bool:
"""Require majority approval for updates."""
MIN_APPROVAL_RATIO = 0.66
valid_approvals = [a for a in approvals if a in council_members]
approval_ratio = len(valid_approvals) / len(council_members)
return approval_ratio >= MIN_APPROVAL_RATIO
council = {"member_1", "member_2", "member_3", "member_4", "member_5"}
attack_approvals = ["member_1", "fake_member"] # Only 1 real approval
if not require_update_consensus(poisoned_entry, attack_approvals, council):
defenses["update_consensus"] = True
# ========================================================================
# Vector 3: Context Verification Defense
# ========================================================================
# Defense: Verify context requirements are semantically appropriate
def verify_context_requirements(entry: DictionaryEntry,
domain: Domain) -> bool:
"""Verify context requirements match domain expectations."""
domain_required_contexts = {
Domain.LEGAL: {"disclosure_provided", "capacity_verified", "witness_present"},
Domain.FINANCE: {"risk_disclosure", "suitability_verified"},
Domain.MEDICAL: {"informed_consent", "professional_witnessed"},
}
required = domain_required_contexts.get(domain, set())
provided = set(entry.context_requirements)
# Must have at least 50% of domain-required contexts
if not required:
return True
overlap = len(required & provided) / len(required)
return overlap >= 0.5
if not verify_context_requirements(poisoned_entry, Domain.LEGAL):
defenses["context_verification"] = True
# ========================================================================
# Vector 4: Artifact Sanitization Defense
# ========================================================================
# Defense: Decompression artifacts must be non-empty for high-stakes terms
def sanitize_artifacts(entry: DictionaryEntry) -> bool:
"""Ensure artifacts are present for important terms."""
HIGH_STAKES_TERMS = {"consent", "liability", "warranty", "indemnity", "default"}
if entry.term in HIGH_STAKES_TERMS:
if not entry.decompression_artifacts:
return False
return True
if not sanitize_artifacts(poisoned_entry):
defenses["artifact_sanitization"] = True
# ========================================================================
# Vector 5: Trust Minimum Bounds Defense
# ========================================================================
# Defense: Domain-specific trust minimum floors
def enforce_trust_minimum(entry: DictionaryEntry, domain: Domain) -> bool:
"""Enforce minimum trust thresholds by domain."""
domain_trust_floors = {
Domain.LEGAL: 0.6,
Domain.FINANCE: 0.65,
Domain.MEDICAL: 0.7,
Domain.GOVERNANCE: 0.75,
}
floor = domain_trust_floors.get(domain, 0.5)
return entry.trust_minimum >= floor
if not enforce_trust_minimum(poisoned_entry, Domain.LEGAL):
defenses["trust_minimum_bounds"] = True
# ========================================================================
# Vector 6: Rollback Capability Defense
# ========================================================================
# Defense: Ability to rollback malicious updates
@dataclass
class EntryVersion:
entry: DictionaryEntry
version: int
timestamp: float
approved_by: Set[str]
entry_history: List[EntryVersion] = [
EntryVersion(
entry=legal_dict.entries["consent"],
version=1,
timestamp=time.time() - 86400,
approved_by={"member_1", "member_2", "member_3"}
)
]
def can_rollback(history: List[EntryVersion]) -> bool:
"""Check if rollback is possible."""
return len(history) >= 1 and history[0].version > 0
if can_rollback(entry_history):
defenses["rollback_capability"] = True
# ========================================================================
# Results
# ========================================================================
defenses_held = sum(defenses.values())
total_defenses = len(defenses)
attack_success = defenses_held < 4
return AttackResult(
attack_name="Meaning Injection (FE-1b)",
success=attack_success,
setup_cost_atp=15000.0,
gain_atp=100000.0 if attack_success else 0.0,
roi=(100000.0 / 15000.0) if attack_success else -1.0,
detection_probability=0.65 if defenses_held >= 4 else 0.30,
time_to_detection_hours=48.0,
blocks_until_detected=300,
trust_damage=0.70,
description=f"""
MEANING INJECTION ATTACK (Track FE-1b)
Inject malicious meanings into legitimate dictionaries.
Attack Pattern:
1. Propose "update" to existing entry
2. Weaken meaning (consent = "implied agreement")
3. Remove context requirements
4. Lower trust minimums
5. Exploit high compression to hide changes
Meaning Comparison:
- Original: "{legal_dict.entries['consent'].meaning}"
- Poisoned: "{poisoned_entry.meaning}"
Property Changes:
- Context requirements: {len(legal_dict.entries['consent'].context_requirements)} → {len(poisoned_entry.context_requirements)}
- Trust minimum: {legal_dict.entries['consent'].trust_minimum} → {poisoned_entry.trust_minimum}
- Compression ratio: {legal_dict.entries['consent'].compression_ratio} → {poisoned_entry.compression_ratio}
Defense Analysis:
- Contribution validation: {"HELD" if defenses["contribution_validation"] else "BYPASSED"}
- Update consensus: {"HELD" if defenses["update_consensus"] else "BYPASSED"}
- Context verification: {"HELD" if defenses["context_verification"] else "BYPASSED"}
- Artifact sanitization: {"HELD" if defenses["artifact_sanitization"] else "BYPASSED"}
- Trust minimum bounds: {"HELD" if defenses["trust_minimum_bounds"] else "BYPASSED"}
- Rollback capability: {"HELD" if defenses["rollback_capability"] else "BYPASSED"}
Defenses activated: {defenses_held}/{total_defenses}
""".strip(),
mitigation="""
Track FE-1b: Meaning Injection Defense:
1. Validate contributions for meaning drift
2. Require council consensus for updates
3. Verify context requirements match domain
4. Sanitize decompression artifacts
5. Enforce domain-specific trust minimum floors
6. Maintain version history for rollback
Dictionary updates are governance decisions.
""".strip(),
raw_data={
"defenses": defenses,
"defenses_held": defenses_held,
"validation_reason": reason,
}
)
# ============================================================================
# ATTACK FE-2a: TRANSLATION TRUST LAUNDERING
# ============================================================================
def attack_translation_trust_laundering() -> AttackResult:
"""
ATTACK FE-2a: Translation Trust Laundering
Exploit cross-dictionary translation to launder untrusted meanings
through chains of partially-trusted translations.
Vectors:
1. Multi-hop trust dilution
2. Domain boundary exploitation
3. Compression loss accumulation
4. Context stripping chains
5. Meaning drift amplification
"""
defenses = {
"translation_chain_limit": False,
"cumulative_trust_tracking": False,
"domain_boundary_checks": False,
"context_preservation": False,
"meaning_hash_verification": False,
"translation_attestation": False,
}
# Setup: Chain of dictionaries across domains
finance_dict = Dictionary(
dictionary_id="finance_v3",
domain=Domain.FINANCE,
lct=LCT(
token_id="lct_fin",
component="dictionary",
instance="finance",
role="keeper",
network="mainnet",
public_key="pk_fin",
creation_block=100
)
)
finance_dict.add_entry(DictionaryEntry(
term="investment_risk",
domain=Domain.FINANCE,
meaning="Potential for financial loss in exchange for potential gain",
context_requirements=["risk_tolerance_assessed", "investor_qualified"],
compression_ratio=0.3,
decompression_artifacts=["risk_disclosure", "investor_profile"],
trust_minimum=0.8
))
legal_dict = Dictionary(
dictionary_id="legal_v3",
domain=Domain.LEGAL,
lct=LCT(
token_id="lct_leg",
component="dictionary",
instance="legal",
role="keeper",
network="mainnet",
public_key="pk_leg",
creation_block=150
)
)
legal_dict.add_entry(DictionaryEntry(
term="investment_risk",
domain=Domain.LEGAL,
meaning="Disclosed hazard with documented informed consent",
context_requirements=["disclosure_signed", "cooling_period_passed"],
compression_ratio=0.4,
decompression_artifacts=["disclosure_document", "signature"],
trust_minimum=0.75
))
social_dict = Dictionary(
dictionary_id="social_v2",
domain=Domain.SOCIAL,
lct=LCT(
token_id="lct_soc",
component="dictionary",
instance="social",
role="keeper",
network="mainnet",
public_key="pk_soc",
creation_block=5000 # Newer, less established
)
)
social_dict.add_entry(DictionaryEntry(
term="investment_risk",
domain=Domain.SOCIAL,
meaning="Exciting opportunity with potential upside", # Weaker meaning!
context_requirements=[], # No requirements
compression_ratio=0.8, # High compression = meaning loss
decompression_artifacts=[],
trust_minimum=0.3 # Low trust
))
# Setup translation partnerships
finance_dict.translation_partners = {"legal_v3": 0.9, "social_v2": 0.5}
legal_dict.translation_partners = {"finance_v3": 0.9, "social_v2": 0.6}
social_dict.translation_partners = {"finance_v3": 0.5, "legal_v3": 0.6}
# Attack: Launder meaning through chain
# FINANCE -> LEGAL -> SOCIAL -> use weak meaning
@dataclass
class TranslationHop:
source_dict: str
target_dict: str
trust_factor: float
meaning_at_hop: str
cumulative_trust: float
def trace_translation_chain(start_dict: Dictionary,
end_dict: Dictionary,
term: str,
path: List[str]) -> List[TranslationHop]:
"""Trace translation through dictionary chain."""
hops = []
current_trust = 1.0
for i in range(len(path) - 1):
source_id = path[i]
target_id = path[i + 1]
# Get trust factor for this hop
trust_factor = 0.5 # Default
if source_id == "finance_v3":
trust_factor = finance_dict.translation_partners.get(target_id, 0.5)
elif source_id == "legal_v3":
trust_factor = legal_dict.translation_partners.get(target_id, 0.5)
elif source_id == "social_v2":
trust_factor = social_dict.translation_partners.get(target_id, 0.5)
current_trust *= trust_factor
# Get meaning at this hop
meaning = ""
if target_id == "finance_v3":
meaning = finance_dict.entries.get(term, DictionaryEntry("", Domain.FINANCE, "unknown", [], 0, [], 0)).meaning
elif target_id == "legal_v3":
meaning = legal_dict.entries.get(term, DictionaryEntry("", Domain.LEGAL, "unknown", [], 0, [], 0)).meaning
elif target_id == "social_v2":
meaning = social_dict.entries.get(term, DictionaryEntry("", Domain.SOCIAL, "unknown", [], 0, [], 0)).meaning
hops.append(TranslationHop(
source_dict=source_id,
target_dict=target_id,
trust_factor=trust_factor,
meaning_at_hop=meaning[:50] + "..." if len(meaning) > 50 else meaning,
cumulative_trust=current_trust
))
return hops
attack_path = ["finance_v3", "legal_v3", "social_v2"]
translation_chain = trace_translation_chain(finance_dict, social_dict, "investment_risk", attack_path)
# ========================================================================
# Vector 1: Translation Chain Limit Defense
# ========================================================================
MAX_TRANSLATION_HOPS = 2
if len(translation_chain) > MAX_TRANSLATION_HOPS:
defenses["translation_chain_limit"] = True
# ========================================================================
# Vector 2: Cumulative Trust Tracking Defense
# ========================================================================
MIN_CUMULATIVE_TRUST = 0.5
final_trust = translation_chain[-1].cumulative_trust if translation_chain else 1.0
if final_trust < MIN_CUMULATIVE_TRUST:
defenses["cumulative_trust_tracking"] = True
# ========================================================================
# Vector 3: Domain Boundary Checks Defense
# ========================================================================
# Defense: Certain domain transitions are restricted
RESTRICTED_TRANSITIONS = {
(Domain.FINANCE, Domain.SOCIAL),
(Domain.LEGAL, Domain.SOCIAL),
(Domain.MEDICAL, Domain.SOCIAL),
}
def check_domain_transitions(path: List[str]) -> bool:
"""Check for restricted domain transitions."""
domain_path = []
for dict_id in path:
if dict_id == "finance_v3":
domain_path.append(Domain.FINANCE)
elif dict_id == "legal_v3":
domain_path.append(Domain.LEGAL)
elif dict_id == "social_v2":
domain_path.append(Domain.SOCIAL)
for i in range(len(domain_path) - 1):
transition = (domain_path[i], domain_path[i + 1])
if transition in RESTRICTED_TRANSITIONS:
return False
return True
if not check_domain_transitions(attack_path):
defenses["domain_boundary_checks"] = True
# ========================================================================
# Vector 4: Context Preservation Defense
# ========================================================================
# Defense: Track context requirements through translation
def check_context_preservation(start_entry: DictionaryEntry,
end_entry: DictionaryEntry) -> bool:
"""Verify context requirements are preserved."""
start_contexts = set(start_entry.context_requirements)
end_contexts = set(end_entry.context_requirements)
# At least 50% of original contexts must be preserved
if not start_contexts:
return True
preservation_rate = len(start_contexts & end_contexts) / len(start_contexts)
return preservation_rate >= 0.5
start_entry = finance_dict.entries["investment_risk"]
end_entry = social_dict.entries["investment_risk"]
if not check_context_preservation(start_entry, end_entry):
defenses["context_preservation"] = True
# ========================================================================
# Vector 5: Meaning Hash Verification Defense
# ========================================================================
# Defense: Semantic hash should be similar across translations
def compute_meaning_hash(meaning: str) -> str:
"""Compute semantic hash of meaning."""
# Simplified: real implementation would use embedding similarity
words = set(meaning.lower().split())
return hashlib.sha256(str(sorted(words)).encode()).hexdigest()[:8]
start_hash = compute_meaning_hash(start_entry.meaning)
end_hash = compute_meaning_hash(end_entry.meaning)
if start_hash != end_hash: # Meanings differ significantly
defenses["meaning_hash_verification"] = True
# ========================================================================
# Vector 6: Translation Attestation Defense
# ========================================================================
# Defense: Each translation hop must be attested
def verify_translation_attestation(chain: List[TranslationHop]) -> bool:
"""Verify each hop has proper attestation."""
for hop in chain:
# Simulated: check for attestation signature
# Low trust hops require higher scrutiny
if hop.trust_factor < 0.7:
# Require additional attestation
return False
return True
if not verify_translation_attestation(translation_chain):
defenses["translation_attestation"] = True
# ========================================================================
# Results
# ========================================================================
defenses_held = sum(defenses.values())
total_defenses = len(defenses)