T09 · Insecure Skill Coding Practices
- Location
SKILL.md:274- Finding
Unsafe Hard-Cut Logic Can Corrupt or Destroy Active Session State
- Content
View full analysis
/.openclaw/agents/main/sessions/sessions.json # 2. Finde alle Keys die ":channel:" enthalten UND KEIN ":thread:" haben # 3. Für jeden solchen Key: prüfe Zeilenanzahl der sessionFile (wc -l) # 4. Wenn > 500 Zeilen UND updatedAt > 2h her: # a. Generiere Hash: TRIM_READY_<4 random chars> # b. sessions_send(sessionKey=, timeoutSeconds=90, # message="[WARTUNG] Schreibe jetzt alle offenen Themen und wichtigen Kontext # in memory/active-context.md. Füge danach exakt diese Zeile am Ende ein: # TRIM_HASH: # Antworte ausschließlich mit NO_REPLY.") # c. Lese memory/active-context.md → suche nach "TRIM_HASH: " # d. Hash gefunden: # - tail -60 > /tmp/trim.jsonl && mv /tmp/trim.jsonl # - Entferne TRIM_HASH-Zeile aus active-context.md # - Log: " | | TRIMMED" → memory/trim-log.txt # e. Hash nicht gefunden (Timeout): # - tail -60 > /tmp/trim.jsonl && mv /tmp/trim.jsonl # - Log: " | | FORCE-TRIM" → memory/trim-log.txt ``` `tools/safe-trim.py:86-116`: ```python # Find safe cutpoints: assistant turns with no pending toolCall candidates = [] for i, line in enumerate(lines): try: entry = json.loads(line) msg = entry.get("message", {}) if msg.get("role") != "assistant": continue content = msg.get("content", []) has_tool_call = any( isinstance(c, dict) and c.get("type") == "toolCall" for c in content ) if not has_tool_call: candidates.append(i) except Exception: continue # Pick the last candidate that s ...[truncated 3614 chars]- Remediation
View remediation
