hn.today

Fun with Constrained Programming

blog.cmpxchg8b.com5 points0 comments
Screenshot of Fun with Constrained Programming

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.

Read on blog.cmpxchg8b.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Aristotle Expands into Rust

Aristotle Expands into Rust

Aristotle has expanded its formal verification platform to Rust, allowing developers to prove code meets specifications and contains no undefined behavior, including in unsafe blocks. It can also verify that Rust rewrites behave like their original C code, targeting critical software such as smart contracts and infrastructure. (harmonic.fun)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.