← all systems · see it in The System
Weird machine
The unintended computer inside a target: a computational artifact where additional code execution can happen outside the program's original specification (src:wp:weird-machine), programmable by the attacker through crafted inputs (src:bratus-2011-weird-machines); formally, the device that arises when the intended machine's emulated transitions operate on weird states (src:dullien-2017-weird-machines). Walked as the phenomenon (the machines shown in memory corruption, metadata, page faults, microarchitecture and protocols) and as the theory behind language-theoretic security that names it, with the defences it led to.
Properties published scienceour proposal
Sourced fields, and our own readings.
| aliases | Weird machine (exploitation as programming the target's unintended computation) |
| born at | kind: 1996-2000 (Aleph One's stack smash, Solar Designer's return-into-libc 1997, Newsham's chaining May 2000); term 2009 |
| born precision | a few years |
| boundary | Inside: the weird states of a target (states with no meaning in the intended machine), the transitions that carry them (borrowed code, allocator and format-string automata, loader and unwinder automata, fault handling, microarchitectural side effects), the primitives distilled from them (weird instructions, gadgets, weird registers and gates), and the exploit as a program for them; and the theory that describes all this (the intended machine and its emulator, weird states, the language-theoretic reading of inputs). Outside: the intended machine and the program that emulates it (sys:software, sys:finite-state-machine), the parser that should recognise input (sys:parser), the person who programs the machine (sys:threat-actor) or studies it (sys:human), the CPU and OS it runs on, and the defences (mitigations, verified parsers). |
| nested level | A computational model inside computer systems (rung 12), found at every layer of the computing stack from the processor's microarchitecture to protocols and browsers (src:bangert-2013-page-fault); its theory is part of computer security (sys:computer-security) and of language-theoretic security. |
| scale | technological |
Measures (15) published science
| characteristic clock: weird gate execution rate (TSX gates, 1M iterations) | about 1.69-2.38 million executions a second (TSX_AND 1,692,047; TSX_ASSIGN 2,380,952); TSX_XOR 60,020 executions per second |
| weird gate accuracy (TSX gates, 1M iterations) | 97.9% (TSX_OR) to 99.2% (TSX_XOR); 98.5% (TSX_AND, TSX_ASSIGN) percent correct |
| SHA-1 on microarchitectural weird circuits: time per run | about 26; 10 of 10 runs correct minutes |
| pings needed to decrypt and run the hidden payload | 6 on average (100 experiments; each trigger evaluated 10 times) pings |
| readout threshold for a weird register | about 100 (shorter = logic 1, in cache) CPU cycles |
| page-fault weird machine: instructions per Game of Life cell | 31 movdbz instructions |
| page-fault weird machine: TSS slots usable (graph colouring) | 16 task-register values |
| relocation types: defined by the ABI, used by gcc, used by Cobbler | 37 / 13 / 3 relocation types |
| Dullien's emulation bound: extra interactions for a non-bit-flipping attacker to match a one-bit-flip attacker | 10,000 (the toy server holds at most 5,000 password-secret pairs) interactions |
| CFI bypass: binaries with powerful attacks under fully-precise static CFI | 5 of 6 binaries |
| CVEs related to XML against JSON | 850 (216 XXE) against 96, at the time of writing (2017) CVE entries |
| Daedalus PDF red team: defects found | 0 in the generated parser, 5 in its hand-written wrapper (4 stack exhaustion on deeply nested input, 1 unchecked offset); competing tools 'tens of defects'; over 70 billion documents parsed in 7 days |
| static-analysis weaknesses in generated parsers | 1 (Daedalus) against 42 (Apache Daffodil and Kaitai Struct together) warnings or weaknesses |
| EverParse: TLS message datatypes implemented | 293 (TLS 1.0-1.3 and extensions) datatypes |
| PDF parsers compared for differentials | 31 (with configurations and utilities); ontology over 15 parsers |
Open contentions (5) open contention
Where sources or readings disagree. Both stay on the map.
- C-3430 What exactly is a software vulnerability?
booked: The map keeps the competing readings; none is ruled.
the other reading: a flaw or weakness that can be exploited (the encyclopedia's definition) - C-3890 Can scattered, inconsistent checking of input be designed out of software?
booked: The map keeps the competing readings; none is ruled.
the other reading: Poll 2018 - C-4250 Do more powerful input formats lead to more security holes?
booked: The map keeps both readings side by side and rules on neither.
the other reading: supported: XML's 850 CVEs against JSON's 96 (an uncontrolled count); Daedalus's red team (no parser defects; competitors tens); not yet tested as such: no controlled study across formats read; Poll: forwarding flaws less covered (C-3890); the XML count is partly about a feature, not grammar class: XXE 'bring[s] actions into the recognition process' (src:bratus-2017-curing, o-xxe-feature); 216 of the 850 are XXE - C-4284 What does it prove when a hidden 'weird machine' is shown to be able to compute anything?
booked: The map keeps both readings side by side and rules on neither.
the other reading: Turing completeness as the demonstration's headline result (ROP, page faults, ELF, DWARF, printf, microarchitecture); Dullien: exploits defined by violated security properties, which matches real requirements better than Turing-completeness; Shapiro et al.: a finite automaton that yields a root shell is no less dangerous; every machine shown is finite, so 'Turing-complete' means given unbounded resources, the usual idealisation, plain in the page-fault demo's memory limit and the TLS preprint's 'unbounded memory' from connection state (o-gol-memory, o-tls-tape; the specialist's framing); two powers run together: the recogniser's power over the input language (LangSec's hypothesis) and the emergent machine's power (the demonstrations); separate axes (specialist) - C-4290 What exactly is a 'weird machine'?
booked: The map keeps both readings side by side and rules on neither.
the other reading: Dullien: from programming mistakes only; side channels and risky intended features out of scope; Paykin et al.: behaviours reachable after compilation and not in the source, timing side channels included; Bratus et al.: defined by example, arising from design, interaction or implementation, bug or no bug; well-formed ELF metadata and page tables need no bug; Benjamin et al.: microarchitectural machines that need no vulnerability; a reading (the specialist's, partly sourced, not ruled): the definitions share one shape and differ in the pair of levels they pick, each weird machine the witness that the lower level is not a faithful refinement of the upper: Dullien IFSM over its emulator (o-emulator), Paykin source over compiled target (o-insecure-compilation; secure compilation's frame, o-abate), Benjamin the architectural over the microarchitectural layer (o-arch-ma-levels); on this reading side channels fall outside Dullien's pair and inside Paykin's
Cross-scale patterns seen here (18) our proposal
Shapes that recur when the same kind of problem is solved at different scales, and how each shows in Weird machine. Each links to every other system that shows it.
- causal ceiling (structural)
Limits set by structure, not means: recognising a Turing-complete input language is undecidable, and parser equivalence is undecidable beyond deterministic context-free grammars; an analyser with full view of architectural state cannot see microarchitectural computation. The decidable side is not a - nested ladder (structural)
Two ladders, kept apart: (a) the input-language classes as LangSec's sidebar ranks them, regular, deterministic context-free, nondeterministic context-free (the source says 'ambiguous context-free grammars need nondeterministic pushdown automata'), context-sensitive, recursively enumerable, each nee - red-queen (structural)
Mitigations and bypasses in a 'series of tit-for-tat papers': W-xor-X met by return-into-libc and ROP, ROP countermeasures bypassed, CFI met by control-flow bending, COOP and DOP; ten years on, gadgets still found for all state-of-the-art defences. Both sides improve; 'nonexploitability is the excep - same role, different builds (structural)
One job, an unintended computer programmed by data, done by unrelated builds: stack frames and gadgets, heap free lists, printf's format automaton, ELF relocations, DWARF bytecode, x86 page-fault handling, caches and branch predictors, TLS handshake state (preprint), PLC timers; and outside security - same shape, opposite sign (structural)
One finite-state transducer, read two ways: code and memory operating on input (the intended machine) or input and code operating on memory (the weird machine); 'Each side views what it can control as the program'. The mechanism is one process, the transducer's transition function, with program and - The Payment to Entropy (structural)
Signal form: every weird gate hands on its bit with accuracy below one (97.9-99.2% for TSX gates), single-bit errors are magnified along a hash computation, so the chain pays in redundant runs (each trigger evaluated 10 times; SHA-1 about 26 minutes). Per-hand-off efficiency about 0.979-0.992. - trade one property for another (structural)
Speed bought, exploitability paid: Dullien's linked-list server is efficient and falls to one bit flip, the flat array traverses all 5,000 entries and is provably immune; Postel's principle buys interoperability with consistent parsing; rich metadata buys composability and diversity with attack surf - Umwelt: each system carves its own slice of one shared medium (structural)
Each analyser carves its slice of the machine: instruction traces miss page-fault computation, emulators such as QEMU miss hardware behaviour, architectural-state tools miss microarchitectural state; the weird machine lives in the slices others do not read. - who opens the door (structural)
The crafted input enters through a door the target opened itself, ahead of time: its own input-processing routines (the port), the loader's relocation processing, the unwinder; only the microarchitectural machine uses an open field (caches built for speed, not to listen). - barrier-gates-complexity (partial)
A barrier here keeps unwanted complexity out: full recognition before processing; registers the attacker cannot reach are needed for the non-exploitability proof. The without-the-barrier case is argued (shotgun parsing, Heartbleed) but not measured. - borrowed-then-held (partial)
Reversed: exploit writers first brought their own code (shellcode), then learned to borrow the target's (return-into-libc, ROP) until 'there was no longer any need to bring any of your own executable code'. Held first, borrowed later, booked as the reverse case. - lightning (partial)
A single bit flip discharges the machine into a weird state after which it is not the same; the hidden payload released all at once on a trigger value. - seed (partial)
One vulnerability, even one bit flip, opens an instruction set for 'a computer that has never been programmed before', with likely infinitely many programs for one goal: a small packet whose arrival opens far more combinations than it carries. - symmetry breaking (name the cut) (partial)
Before: the two readings of a transducer are mathematically the same. The cut: a weird state is entered. After: the attacker's reading (input as program) matters and sets what is built next. - templating (partial)
Weird-machine program fragments reused across related targets, and Shacham's thesis that any large body of x86 code yields the same gadgets: a module that keeps working when moved. - The carry (partial)
Overflow passed on: a buffer that holds only so much passes its excess into the next place, the return address, which waits there to be read at the function's end; and the movdbz step's underflow passes control to the branch target. Face: overflow passed on (the excess here unintended). - the whole sets the local reference (partial)
Whether a CPU state is sane, transitory or weird is fixed only against the intended machine through the abstraction mapping; 'it is impossible to even define flaw' without the bug-free version. - cephalization (surface)
Checking concentrated at the end that meets new input first: the recognizer pattern isolates input handling in one component at the entry; designed, not evolved.
Valence: what it trades, and with whom (12) published science
Each exchange with a neighbour, read from both sides: who gains, who pays, and what carries it.
- Human (Homo sapiens) via sys:written-record · Weird machine gain
- Software via sys:computer-memory · Weird machine gain
- Central processing unit via sys:computer-hardware · Weird machine gain
- Operating system via sys:computer-hardware · Weird machine gain
- Compiler via sys:written-record · Weird machine gain
- Malware via sys:operating-system · Weird machine even
- Threat actor via sys:internet · Weird machine mixed
- Software vulnerability via sys:software · Weird machine gain
- Buffer overflow via sys:computer-memory · Weird machine gain
- Parser via sys:written-record · Weird machine mixed
- Trust boundary via sys:information-system · Weird machine gain
- Attack surface via sys:software · Weird machine gain
Partners and parts published science
Built from / builds (5)
- Exploit
- The intended finite-state machine (IFSM)
- Weird states
- Weird instructions (exploit primitives, gadgets)
- Weird registers and gates (microarchitectural)
Sits inside / holds (3)
expressed by (19)
- Generation/Synthesis
- Recombination/Composition
- Templating / Standardization
- Sensing/Scanning
- Mapping/Modeling
- Active Experimentation / Probing (Optimal Experimental Design)
- Evade Detection
- Overcome Barrier
- Subversion & Co-optation
- Prepositioning & Latency
- Battlespace Shaping
- Leverage Host/Amplification
- Proactive Defense
- Physical/Virtual Barrier
- Technique-Based Identification (a.k.a. Technique-Based Detection)
- Validation of Effectiveness
- Deception
- Redundancy & Diversity
- Quality Control & Error Correction
floor filled by (18)
- Human (Homo sapiens)
- Computer memory
- Software
- Central processing unit
- Operating system
- Turing machine: the abstract machine that reads and writes one symbol at a time on an unbounded tape by a finite table of rules, the model of computation of logic and computer science
- Malware
- Threat actor
- Software vulnerability
- Exploit
- Buffer overflow
- Finite-state machine: an abstract machine in exactly one of finitely many states at a time, moved from state to state by its inputs; the lowest member of the automata hierarchy and a working design tool
- Parser
- Trust boundary
- Return-oriented programming
- Weird states
- Weird instructions (exploit primitives, gadgets)
- Weird registers and gates (microarchitectural)
represents (2)
- Finite-state machine: an abstract machine in exactly one of finitely many states at a time, moved from state to state by its inputs; the lowest member of the automata hierarchy and a working design tool
- the weird-machine framework held by computer security and language-theoretic security
Kinds (10)
- Memory-corruption weird machine
- Metadata-driven weird machine (ELF relocations, DWARF unwinding)
- Page-fault weird machine
- Microarchitectural weird machine
- Web and browser weird machines
- Protocol weird machine (TLS; preprint)
- Cyber-physical weird machine (industrial control)
- Weird machines in proof-carrying code
- Weird machine as emulated transitions on weird states (Dullien)
- Weird machine as insecure compilation (Paykin et al.)
Notes published science
- A computer that never runs an instruction: Bangert and colleagues made an Intel processor compute (Conway's Game of Life, 31 'instructions' per cell) using nothing but cascades of page faults, and no emulator they tried could reproduce it (src:bangert-2013-page-fault).
- Program and data are the same thing seen from two sides: Dullien shows every program can be read as code working on your input, or as your input working on its memory, and 'mathematically, there is no distinction'; an exploit is the moment the second reading wins (src:dullien-2017-weird-machines).
- Hidden computers pay a toll: logic gates built from a processor's cache timing are right only 97.9 to 99.2% of the time, so a SHA-1 hash computed on them needs redundant runs and takes about 26 minutes, yet came out right 10 times in 10 (src:benjamin-2024-uwm).
Layers
The ways it takes in its world, where they meet, and how it acts back, each from L1 (where it meets the world) up.
a weird machine as language-theoretic security describes it: crafted input and the target's own states, through the input-handling code and the weird states it reaches, up to the exploit as a program and the security property it breaks (reader's view)
- L1: The target and what reaches it: crafted input and the target's memory, code and hardware state, the whole composed environment
- L2: The intended machine and its emulator: the program specialises the CPU to an (implicit) finite-state machine; its input handling is meant to recognise valid input
- L3: Weird states: states with no meaning in the intended machine, entered by a bug, a fault or a feature
- L4: Weird instructions: primitives distilled from the target's own code and automata, driven by input as opcodes
- L5: The weird machine: emulated transitions acting on weird states; state space and power unknown in advance
- L6: The exploit: a program for the weird machine, and a constructive proof that it exists
- L7: The security property broken and the trust assumption shown false
the boardroom (shared floors)
- L5: The weird machine itself: the emulated transitions acting on weird states, with an unknown state space, unknown computational power and an emergent instruction set
- L6: The exploit as a program for the weird machine: setup, instantiation and programming; a constructive proof that the machine exists
- L7: What the computation does to the target: the security property of the intended machine violated (a secret out, a shell, a trust decision subverted); the aim is the programmer's
way in: Borrowed code: the target's own transitions and code snippets
- L1: The target's code in memory: the program's own routines and its libraries
- L2: Short instruction sequences found by static analysis, including sequences the assembler never placed
- L3: Gadgets: sequences chained into blocks that do one job each
- L4: Weird instructions: distilled, isolatable primitives (weird MOV, aa4bmo, 4-bytes-write-anything-anywhere)
way in: Crafted input: the attacker's bytes, the weird machine's instruction stream
- L1: Crafted input delivered to the target: the exploit expressed as input
- L2: The target's input-handling routines, meant to act together as a recognizer for valid input
- L3: Past the recognizer: a bug or feature that lets crafted clauses reach the artifacts inside (memory corruption, %n)
- L4: Input as opcodes: every further input executes an emulated transition on the weird state
way in: Faults: corrupted bits that move the machine into a weird state
- L1: Memory cells and their bits; registers the attacker may not reach
- L2: Sources of corruption: human error in the program, hardware faults (Rowhammer), transcription errors
- L3: The attacker model: a chosen bit flipped at an arbitrary or fixed program point
- L4: The first weird state, q_init: a state with no meaning in the intended machine
way in: Metadata: ELF relocations and DWARF unwinding data read as instructions
- L1: ABI metadata in the executable: relocation entries, symbol tables, DWARF exception data
- L2: Read by the runtime loader (RTLD) and the exception unwinder, each an automaton interpreting its section
- L3: Entries as operations: three relocation types (COPY, SYM, RELATIVE); DWARF bytecode
- L4: Well-formed metadata compiled from a Turing-complete language (Brainfuck, via Cobbler)
way in: Microarchitectural state: caches, branch predictors, transactional memory, read as time
- L1: Timing variations in executing instructions that meet side effects
- L2: Microarchitectural components: caches, prefetchers, branch predictors, buffers; not directly accessible to programs
- L3: Weird registers: one bit held in a component's state (a cached or flushed line; a trained branch)
- L4: Weird gates and circuits: AND, OR, XOR built from mistrained speculation and transaction races
way in: The analysts' channel: exploits and attack papers read as evidence about the target
- L1: Attack papers and exploits from the practitioner community
- L2: Read by peers and checked like proofs, studied for their tricks
- L3: The mechanism described: the target's artifacts that make it programmable, as elementary instructions
- L4: Formal accounts: the intended machine, weird states, the weird machine defined; weird machines as insecure compilation
way in: Traps: page tables, descriptor tables and the fault-handling logic
- L1: Cross-referencing, cross-mapped memory tables, all entries well-formed
- L2: The MMU and interrupt handling: hard-wired fault logic that reads and writes memory
- L3: Page faults and double faults as steps; the stack-pointer decrement as arithmetic
- L4: One instruction: move, branch if zero or decrement (movdbz), which can build subtract-and-branch-if-negative
way out: Back to sane: re-entering a sane or transitory state ends the weird machine
- L1: The program emulates the intended machine again
- L5: Sane and transitory states are the weird machine's terminating states
way out: Concealed payload: a hidden computation releases its payload on a trigger
- L1: The host acted on: the reverse shell runs
- L4: The payload decrypted and executed (a reverse shell)
- L7: Malware passive and invisible until it receives a trigger
way out: Hand-off to the CPU: the instruction pointer taken, leaving the weird machine for native code
- L1: Control transferred to code of the attacker's choosing
- L6: The attacker chooses to leave weird-machine programming
way out: Published: the exploit or construction written up as a constructive proof for others
- L1: Released code and papers (the movdbz compiler on GitHub)
- L6: The attack as a constructive proof that the execution model exists
way out: Security property violated: output the intended machine would never give
- L1: The secret (or a shell, or a write) delivered to the attacker's side
- L5: The weird machine's output alphabet, which may differ from the intended machine's
- L7: A security property of the intended machine violated
where weird machines have been shown, from the processor's hidden state up the software stack (placement reading)
- L1: Microarchitecture: caches and branch predictors computing in timing (microarchitectural weird machines)
- L2: Memory management and trap handling: the page-fault weird machine
- L3: Instruction-level code reuse: return-oriented programming from libc's sequences
- L4: The loader and the unwinder: ELF relocation metadata and DWARF bytecode
- L5: Library automata: the allocator's free lists, printf's format-string automaton
- L6: Protocol state: TLS session cache, renegotiation and certificate steps (preprint)
- L7: Applications: browser rendering engines (DOM, CSS) as weird machines