Conversation
|
intent says: PR #7 Review: Add Core Watchdog SafeguardsSummaryThis PR by @seifreed adds a watchdog subsystem to radius2 for detecting and breaking out of problematic execution scenarios like infinite loops, trap instructions, and stalled execution. The implementation is focused on unpacker/packer analysis (detecting Original Entry Points from self-modifying code). Verdict:
|
| Feature | Move to r2? | Rationale |
|---|---|---|
| Max steps limit | Maybe | r2's aes (step) could have built-in limits |
| PC repeat detection | Maybe | Could be an ESIL VM option (e esil.maxrep) |
| Trap skipping | Yes | Anti-debug emulation belongs in r2's analysis layer |
| Memory write tracking | No | r2 doesn't do symbolic execution, this is radius2's domain |
| OEP detection | No | Symbolic execution specific heuristics |
What Should Stay in radius2
- Progress detection - Requires symbolic execution context
- OEP detection - Specific to symbolic unpacker analysis
- Per-state watchdog tracking - radius2's multi-state model is unique
Missing from This PR
-
🔴 No CLI Integration
-
🔴 No Tests
-
🔴 No Documentation
Performance Considerations
The implementation adds overhead to every step:
step_countincrement (minimal)- PC history tracking when enabled (O(window_size) memory per state)
- Write epoch checks when enabled (hash lookups)
- Trap instruction string matching when enabled (string ops per instruction)
Most overhead is gated behind self.watchdog.enabled, but the WriteLog struct is always allocated in Memory even when watchdog is disabled.
Recommendations Summary
| Component | Verdict | Action |
|---|---|---|
max_steps |
✅ Include | Core safeguard, expose via CLI |
pc_repeat_limit |
✅ Include | Useful debugging feature |
pc_window detection |
✅ Include | Consider ring buffer optimization |
WriteLog tracking |
Make opt-in (feature flag or lazy init) | |
| Trap skipping | Document as anti-debug, consider r2 | |
| OEP detection | Consider separate "unpacker mode" |
Before Merge Requires:
- Add CLI flags for basic watchdog options
- Add at least one test demonstrating loop detection
- Lazy-initialize WriteLog only when watchdog enabled
- Document the feature
Optional Improvements:
- Ring buffer for PC window instead of Vec with remove(0)
- Architecture-agnostic trap instruction detection
- Separate "unpacker analysis mode" module
6f917ba to
18587bd
Compare
Summary
Testing