RAR archives can embed programs for RarVM, a small x86-inspired virtual machine intended to run reversible filters that make data more compressible. Although WinRAR supplied standard filters, archives could also define their own, opening the possibility of writing custom programs. Tavis Ormandy describes building an experimental toolchain - an assembler, linker, documentation, and sample code - to explore this feature. A basic program writes “Hello, World!” into RAR’s output buffer. The VM has eight registers, a 0x40000-byte address space, status flags, and a 250-million-instruction limit per filter; filters can be chained to divide larger tasks into multiple execution chunks.
The main technical obstacle is that WinRAR checks a filter’s output against a CRC recorded in the archive header. That requirement seems to prevent producing output that varies at runtime, since its checksum would not be known when the archive is created. Ormandy overcomes this by porting a dynamic CRC-compensation algorithm into RarVM: the program alters reserved bytes in its output buffer so the resulting data matches a chosen CRC. This lets a self-contained archive generate dynamic output while satisfying the check, demonstrated by a sample that prints padding followed by “Hello, World!” The project is presented as an amusing, mostly impractical programming experiment, while the ability to run archive-supplied code also prompts questions about how securely the VM is isolated.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.