Opus finding
loadSession does not validate history element shape — corrupted/foreign data passes through as Message[]
- src/session.ts:63-68
loadSession checks that history is an array but never validates each element conforms to the Message shape, nor that budget has the three numeric fields. An attacker (or a downgraded build) that drops a crafted latest.json can inject arbitrary objects into the chat history when resumed, which then get sent to the model provider. Lower risk because the file lives under the user's homedir, but the type-cast `as SessionData` masks the unsafe deserialization.
Recommendation
Add per-element validation (role in {user,assistant,system,tool}, content present), validate budget numeric fields, and reject if any field is invalid (with backup, see related finding).