# What an attacker can recover (reversal classes)

The static-attacker classes AfterPack's transforms fall into, and what recovering each one gets an attacker.

Source: https://www.afterpack.dev/docs/reversal-classes

AfterPack sorts its protections into classes. Each class raises the cost of reversal differently. Knowing which class covers [a region](https://www.afterpack.dev/docs/directives#what-you-can-set) of your code tells you what an attacker recovers if they read it. The [Protection Map](https://www.afterpack.dev/docs/protection-map) colors every token by its complexity score and names the class of the code you select.

## Static attacker, defined

These are **static-attacker** classes. They describe what someone who reads the bytes faces: grep, AST tooling, a deobfuscator pass, or an LLM that explains code without running it. An attacker who runs the artifact under instrumentation is a separate, stronger case, covered in the [threat model](https://www.afterpack.dev/docs/threat-model).

*(interactive reversal-classes diagram — see the web page)*

## The classes

| Class | What a static attacker recovers | Tier |
|---|---|---|
| **Renamed & encoded** (polynomial-injective) | The structure, with effort. Names, literals, flattened control flow and fused identities all take real pattern-recognition work. That work has to be redone on [every build](https://www.afterpack.dev/docs/config#seed). | Free |
| **Flattened & fused** (polynomial-non-injective) | An equivalent program with [the same behavior](https://www.afterpack.dev/docs/semantic-contract). The logic is rewritten so several different original computations collapse to the same output, and the mapping back to which one you wrote is gone. No shipped transform reaches this class today. | — |

The Free tier produces the renamed & encoded class across your entire bundle ([the full matrix is in Plans & tiers](https://www.afterpack.dev/docs/tiers)). Higher [presets](https://www.afterpack.dev/docs/presets) push harder within that class. The default preset is `light` ([complexity target](https://www.afterpack.dev/docs/config#complexity) `5`); a stronger preset such as [`--preset=hard`](https://www.afterpack.dev/docs/config#preset) pushes harder and multiplies page startup time across the bundle ([load cost](https://www.afterpack.dev/docs/presets#load-cost)). From `medium` up, the engine adds control-flow flattening, identity fusion, and [constant destruction](https://www.afterpack.dev/docs/config#strings-encode) uniformly across the bundle, all within the renamed & encoded class.

> **Flattened & fused and destroyed & fused are not produced today**
>
> No build reaches them, and no region is ever classed "flattened & fused" or "destroyed & fused". [`/* @afterpack preset=extreme */`](https://www.afterpack.dev/docs/config#preset) raises a region to [complexity target](https://www.afterpack.dev/docs/config#complexity) `25` with the [string floor](https://www.afterpack.dev/docs/config#strings-encode) on, which is real, measurable protection inside the renamed & encoded class.

## What recovering a class gets an attacker

What a class gets an attacker depends on what they were after.

- **A secret** (an API key, a license threshold, a hardcoded table): neither class hides it on its own. A secret comes out of any program that behaves the way yours does, including the one recovered from a protected region. Protecting a secret takes a different mechanism. See [Protecting a secret](https://www.afterpack.dev/docs/threat-model#protecting-a-secret).
- **Understanding and cloning your code**: a static reader can recover a working, readable equivalent, but only after the real pattern-recognition work the renamed & encoded class costs, and that work has to be redone for every build. See [What AfterPack does not replace](https://www.afterpack.dev/docs/threat-model#what-afterpack-does-not-replace) for the limits of this property.
- **Locating and patching one check** (disabling a paywall, flipping one `return true`): neither class helps much on its own. The attacker only needs to find that one node. Finding it again costs something, and it [resets on every release](https://www.afterpack.dev/docs/config#seed). Self-integrity ([`transforms.selfIntegrity.enabled`](https://www.afterpack.dev/docs/config#transforms-kind-enabled)) does not catch this: it detects edits to its own check table only. See [Best practices](https://www.afterpack.dev/docs/best-practices) on rotation.

## Verify it on your own build

The [Protection Map](https://www.afterpack.dev/docs/protection-map) shows the per-token proof: your original source, colored by each token's complexity score, with the class and the transform stack behind it on hover. [Open the live demo](https://www.afterpack.dev/protection-map-demo) or generate your own with [`npx afterpack@latest`](https://www.afterpack.dev/docs/cli#usage).

## Next

- [Threat model](https://www.afterpack.dev/docs/threat-model): the adversary ladder these classes are scoped against.
- [Protection Map](https://www.afterpack.dev/docs/protection-map): the per-token view for your own build.
- [Best practices](https://www.afterpack.dev/docs/best-practices): what to mark and why.
- [Directives](https://www.afterpack.dev/docs/directives): the markers that move a region between classes.
- [Presets](https://www.afterpack.dev/docs/presets): the ladder and the complexity target each rung sets.
