> your AI agent picks dependencies from memory; give it dated facts — try starlog.dev ↗ vet your agent's deps ↗ vibe-coding is fine. vibe-importing isn’t. — try starlog.dev ↗ vibe-importing isn’t fine ↗ your agent has never seen your private packages — try starlog.dev ↗ facts for private packages ↗ a linter for the dependencies your AI agent picks — try starlog.dev ↗ a linter for agent deps ↗ whois is redacted, cdns mask the rest — get the real operator — try whoisgeni.us ↗ who really runs that domain ↗ domain attribution that shows its work — full evidence chain — try whoisgeni.us ↗ domain intel w/ evidence ↗

← Back to Articles

Kuna: The Decompiler Built for LLMs to Refine Themselves

[ View on GitHub ]

Kuna: The Decompiler Built for LLMs to Refine Themselves

Hook

What if your decompiler was designed not for human reverse engineers, but for AI agents that could systematically test thousands of optimization combinations and evolve better output on their own?

Context

Decompilers have always been tools for human analysts—Ghidra, IDA, and Binary Ninja prioritize GUI workflows, interactive exploration, and manual analysis patterns. But as LLMs become capable of reading code and running experiments, the bottleneck shifts from human time to tool architecture. Traditional decompilers are black boxes: you feed in a binary, get output, and have no programmatic way to understand which internal transforms produced which results. If an LLM wants to improve decompilation quality, it's stuck doing prompt engineering on final output rather than tweaking the underlying algorithms.

Kuna takes a radically different approach: it's an agent-first decompiler where every optimization pass is exposed as a toggleable CLI flag, every phase is documented in natural language specifications designed for LLM context windows, and the entire tool is architected for autonomous refinement loops. An agent can toggle transform combinations, run DecBench benchmarks, measure quality deltas, and iterate—no human in the loop. The project emerged from Noelo Lab as a Rust port of Ghidra's decompiler with an explicit goal: build a tool that LLMs can improve faster than human developers can. With 726 stars and top-tier DecBench performance despite being a young rewrite, it's gaining traction among researchers building automated binary analysis pipelines.

Technical Insight

Nine-Phase Transform Pipeline

toggleable passes

kuna-cli

CLI Interface

kuna-analysis

Loader & Analyzer

kuna-wasm

Browser Module

kuna-ghidra

Ghidra Bridge

kuna-sleigh

SLEIGH Runtime

.sla Bytecode

Instruction Specs

kuna-decomp

Core Pipeline

Knowledge

Extraction

Control Flow

Recovery

SSA

Construction

Type

Propagation

Simplification

Structure

Recovery

Variable

Naming

High-Level

Transforms

Code

Emission

Transform Registry

Decompiled Code

+ Metrics

DecBench

Scoring

System architecture — auto-generated

Kuna's architecture centers on a nine-phase decompilation pipeline ported from Ghidra's C++ codebase but rebuilt in Rust with clean phase separation: knowledge extraction, control-flow recovery, SSA construction, type propagation, simplification, structure recovery, variable naming, high-level transforms, and code emission. Unlike Ghidra's monolithic design, each phase is composed of individually toggleable transforms registered in a transform registry pattern. Here's what this looks like at the CLI level:

# Disable aggressive loop normalization, enable experimental structure recovery
kuna decompile binary.elf \
  --disable-transform=normalize_loops_aggressive \
  --enable-transform=recover_switch_tables_experimental \
  --benchmark=decbench \
  --output-metrics=metrics.json

This seemingly simple interface hides sophisticated engineering. Each transform has machine-readable metadata describing preconditions, postconditions, and interaction effects. The metrics output includes per-function quality scores, compilation success rates, and runtime performance—exactly what an LLM needs to evaluate whether toggling a transform improved results. The natural language specifications in docs/spec/ provide context:

## Phase 4: Type Propagation
Owner: @type-system-team

Transforms:
- `propagate_pointer_arithmetic` [default: enabled]
  Infers pointer types from arithmetic patterns like `base + index * sizeof(type)`.
  Symptom if disabled: Variables typed as `int` when they're actually `char*`.
  
- `infer_struct_fields` [default: enabled]
  Recovers structure member accesses from constant offset patterns.
  Symptom if disabled: `*(ptr + 0x10)` instead of `obj->field_name`.

This symptom-indexed documentation is deliberately LLM-friendly. An agent diagnosing poor output quality on a specific binary can search specs for symptoms, identify candidate transforms, toggle them, and measure impact—no need to read Rust implementation details.

The SLEIGH integration demonstrates pragmatic engineering. SLEIGH is Ghidra's instruction specification language—a domain-specific language describing how processor instructions decode into intermediate representation. Kuna ships with a Rust SLEIGH compiler (slacomp) that produces .sla bytecode consumed at runtime. For standalone CLI usage, specs are embedded directly in the binary. For Ghidra GUI integration, Kuna loads specs from existing Ghidra installations:

// Simplified from kuna-sleigh runtime
pub struct SleighEngine {
    spec: SleighSpec,
    context: DecoderContext,
}

impl SleighEngine {
    pub fn from_embedded(arch: Architecture) -> Result<Self> {
        // Embedded .sla bytecode compiled at build time
        let spec_bytes = include_bytes!(concat!("specs/", arch.name(), ".sla"));
        let spec = SleighSpec::deserialize(spec_bytes)?;
        Ok(Self { spec, context: DecoderContext::new() })
    }
    
    pub fn from_ghidra_install(ghidra_path: &Path, arch: &str) -> Result<Self> {
        // Load specs from existing Ghidra installation
        let spec_path = ghidra_path.join("Processors").join(arch).join("data/languages");
        let spec = SleighSpec::load_from_directory(&spec_path)?;
        Ok(Self { spec, context: DecoderContext::new() })
    }
}

This dual-mode design means agents get a single-binary tool with no dependencies, while human users working in Ghidra can drop Kuna in as a native decompiler replacement without rebuilding anything.

The regression testing strategy is unusually rigorous for a research tool. Kuna maintains 675 XML assertion tests ported from Ghidra's upstream test suite. Each test encodes expected intermediate representation at specific pipeline phases—not just final output, but control-flow graphs, SSA forms, and type inference results. When agents iterate on transforms, these assertions catch correctness regressions invisible in end-to-end benchmarks:

<!-- Example assertion from test suite -->
<test name="pointer_arithmetic_inference">
  <input arch="x86:LE:64:default">
    <hex>488b45f0 4863c8 488d0c88</hex>
  </input>
  <phase name="ssa_construction">
    <assert>contains("tmp_0 = LOAD ram[rbp + -0x10]")</assert>
  </phase>
  <phase name="type_propagation">
    <assert>variable("tmp_0").type == "int64_t*"</assert>
  </phase>
</test>

This architecture enables the autonomous refinement loop: an agent toggles transforms, runs the benchmark suite, checks metrics and assertions, and iterates. The project includes a reference implementation of this loop in Python, where an LLM generates transform combinations based on current performance gaps, executes benchmarks, and curates successful experiments into configuration presets.

The speed gains over Ghidra are substantial—Kuna processes a 19MB binary in under 3 minutes where Ghidra's JVM-based decompiler takes 15+ minutes. This isn't just Rust versus Java overhead; the phase-based rewrite exposed optimization opportunities. Control-flow recovery now parallelizes across functions, SSA construction uses persistent data structures instead of copying entire graphs, and the SLEIGH runtime compiles hot paths to native code at startup rather than interpreting bytecode per-instruction.

Gotcha

The agent-first philosophy means human usability is deliberately deprioritized. If you're doing manual reverse engineering and expect GUI features, interactive type editing, or exploratory workflows, Kuna is frustrating. The Ghidra plugin integration exists but lacks feature parity—no custom analyzers, limited scripting API exposure, and undefined behavior for PyGhidra workflows. The project maintainers are upfront about this: they're building for agents, and human-facing polish is a non-goal.

More fundamentally, the autonomous refinement loop optimizes for DecBench scores, which means Kuna inherits whatever biases exist in that benchmark corpus. DecBench emphasizes C codebases compiled with standard optimizations—if you're analyzing hand-written assembly, obfuscated malware, or Rust/Go binaries with different ABI conventions, Kuna's transforms may be poorly tuned. The agent refinement loop will only improve what the benchmark measures, and there's no evidence yet that improvements transfer to out-of-distribution binaries. The project acknowledges this limitation but hasn't published data on generalization.

The hundreds of toggleable transforms create a complex configuration space. Without automated search or deep understanding of transform interactions, finding optimal settings for a specific binary class requires exhaustive experimentation. The symptom-indexed documentation helps LLMs navigate this space, but human users are left guessing. There's no "run with sane defaults for malware analysis" or "optimize for embedded firmware" presets—those would need to emerge from agent-driven curation, which hasn't materialized yet beyond reference benchmarks.

Verdict

Use if: You're building automated binary analysis pipelines where an LLM or agent orchestrates decompilation and needs programmatic control over optimization strategies. You're researching decompilation algorithms and need a tool you can systematically iterate on with measurable quality metrics. You have bulk analysis workloads where Kuna's 5x speed advantage over Ghidra justifies dealing with a less mature tool. You want Rust's memory safety guarantees and are comfortable reading source to understand behavior.

Skip if: You're doing manual reverse engineering and rely on interactive GUI workflows, custom scripts, or mature plugin ecosystems—use Ghidra or Binary Ninja instead. You need battle-tested reliability for production security tooling rather than research-grade experimentation. You're analyzing binaries outside DecBench's domain (obfuscated code, non-C languages, embedded firmware) and have no way to validate that Kuna's optimizations transfer. You want a tool that's documented for human practitioners rather than LLM context windows.