File size: 1,118 Bytes
5113b0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Tool Declaration Module - Optional support file for Kimi tokenizer

EXO's tokenizer loader optionally loads this file first via importlib.util.spec_from_file_location.
This demonstrates how arbitrary Python can be executed at model load time.
"""

from pathlib import Path
from datetime import datetime
import json

# This code executes during model load before tokenization_kimi.py
print("[TOOL_DECLARATION_TS] Executed before tokenizer instantiation")

# Log execution for audit trail
log_file = Path("/tmp/exo_tool_declaration_log.txt")
log_file.write_text(
    f"Tool declaration executed at {datetime.now().isoformat()}\n"
    f"This proves module-level code execution via importlib.util.exec_module()\n"
)


class ToolDeclaration:
    """Stub tool declaration for compatibility"""
    
    def __init__(self):
        self.tools = []
    
    @staticmethod
    def from_file(path):
        return ToolDeclaration()


# Any code here runs at import/exec time, not just on instantiation
# This is key to the RCE: EXO doesn't just load a harmless config,
# it executes arbitrary Python at module initialization