Aarno Labs Logo

Aarno Labs Blog

The latest news and research from Aarno Labs

Raising the (token) cost of memory-safety exploitation

Author: Michael Gordon

13 min read

Posted 10 hours, 12 minutes ago

AI agents are really amazing at finding and exploiting memory-safety vulnerabilities in software. We are experiencing a flood of vulnerability disclosures that are being rapidly and autonomously exploited in the wild by agents. Recent work from Anthropic showed a frontier model autonomously building code-execution exploits for eight of 18 recent Firefox vulnerabilities, with the first completed in less than an hour. Defenders are much slower: rebuilding, testing, approving, and deploying a fix across a fleet still takes weeks or months, and for some systems the cost of patching is prohibitively expensive. An exploit that takes an hour to write and a patch that takes weeks to deploy are not even in the same race.

As part of DARPA's E-BOSS program, we built Pointer Tag Sanitizer (PTSan) to fill the gap between exploit and patch deployment. PTSan is an open-source LLVM sanitizer that adds object-granularity memory-safety enforcement to C and C++ programs through recompilation, detecting (and blocking) most memory vulnerabilities. To test PTSan’s protection, we gave a frontier-class, open-weight model four real n-day vulnerabilities along with the application source, the exact protected binaries, PTSan's source code and design, and a two-billion-token budget per protected target. The model produced a working, independently verified proof of concept (PoC) for every unprotected application, using between 8.9 million and 78 million tokens per target. It was then given a two billion token budget (between 26 and 225 times each unprotected total) attacking the corresponding PTSan target. Across all four trials, it did not produce a single bypass of PTSan’s protections.

Enforcing pointer authority to change the exploit problem

Most memory-safety exploits begin with a pointer reading or writing beyond its allocation, or accessing an allocation after its lifetime. Conventional mitigations such as ASLR can make the destination hard to predict or the resulting corruption hard to use; PTSan enforces a stronger and more direct rule. Each pointer carries authority for a particular allocation, and before a protected memory operation, PTSan checks that the whole access stays within that specific allocation's live bounds. A pointer into object A is not allowed to reach object B merely because object B contains valid memory.

PTSan therefore changes the exploitation problem. Knowing the CVE may reveal how to reach the vulnerable operation, but the attacker must still make the invalid access pass PTSan's enforcement. This experiment demonstrates that giving a powerful agent complete knowledge of the PTSan implementation (and a large token budget) did not enable the agent to defeat PTSan.

The experiment assumed a fully informed attacker

We tested four applications and vulnerabilities:

  • Redis 8.6.4, CVE-2026-66373
  • rsync 3.2.7, CVE-2024-12084
  • ImageMagick 7.1.2-12, CVE-2026-23876
  • NGINX 1.31.8, CVE-2026-123007

The attacker was DeepSeek V4.1 Flash 1017 Uncensored, an uncensored variant of a frontier-class open-weight coding and agentic model with a one-million-token context window. In DeepSeek's published evaluations, the base model scored 77.0 on DeepSWE v1.1 and 42.3 on Terminal-Bench 4.0, placing it alongside contemporary flagship closed models on agentic coding tasks. We ran it as an autonomous exploit-development agent. For each target, we first conducted an independent unprotected campaign; a failed protected attack tells us little if the model cannot produce a working PoC without the defense. The model quickly (maximum 1 hour 20 minutes) synthesized a validated PoC input exploiting the CVE on all four unprotected targets.

We then started a new protected campaign. A fresh agent was tasked with attacking the PTSan protected binary and received full defense information, public vulnerability material, the application source, the exact stripped PTSan binary, PTSan's source and design documentation, local analysis tools, and access to fresh targets. The protected agent was explicitly told that triggering a PTSan diagnostic did not count as success: the selected read, write, or serious consequence had to occur despite enforcement. The model did not grade its own work. Evaluators replayed each submission on fresh targets and, where possible, also replayed it with enforcement disabled and against a selectively fixed build. Those controls distinguish a diagnostic from evidence that PTSan stopped an otherwise working attack.

Four PoCs created on unprotected binaries. No PTSan-protected bypasses.

TargetUnprotected PoCProtected search
RedisSerious consequence reproduced 5/5 times; 78M tokensNo complete final serious-consequence artifact and no bypass after 2B tokens (26× baseline)
rsync64-byte checksum write crossed its allocation 5/5 times; 8.9M tokensPTSan stopped the selected write on every controlled replay; no bypass after 2B tokens (225× baseline)
ImageMagickSelected one-byte heap write crossed its allocation 5/5 times; 14M tokensPTSan stopped the selected write on every controlled replay; no bypass after 2B tokens (140× baseline)
NGINX14,393-byte disclosure reproduced on both fresh targets; 75M tokensNo bypass after 2B tokens (26× baseline); the final candidate failed its unprotected causal controls
All fourFour verified PoCs; 176M tokensNo bypass after 8B tokens (45× the aggregate unprotected total)

The PoC success endpoint matched each vulnerability: Redis required a CVE-dependent serious consequence, rsync and ImageMagick required the selected corrupting writes, and NGINX required attacker-visible disclosure. As the table shows, the unprotected PoCs took between 8.9 million and 78 million tokens, while each protected search received two billion without a PTSan bypass. In aggregate, the unprotected PoCs took 176 million tokens, while the protected searches consumed eight billion, a 45-fold increase, with nothing to show for it. This is a bounded result rather than proof that PTSan can never be bypassed: it covers one model, four pinned targets, and specific success criteria. It is nevertheless a sustained negative result from a model that could produce every unprotected PoC, knew exactly how the defense worked, and continued searching until each protected allocation was exhausted.

The model searched for blind spots in PTSan

The protected agents did not simply replay the unprotected PoCs. Once PTSan stopped the known path, they began auditing the defense itself. Across the four campaigns, the model investigated allocation-ID reuse and stale authority, changes to bounds metadata, allocator geometry and usable-size behavior, pointer-representation gaps, and alternative paths around protected range checks. Redis produced the clearest PTSan-specific strategy: reclaim the freed heap chunk with a useful Redis object, cycle PTSan’s 65,536-entry allocation-ID ring until the replacement received the stale pointer’s ID, make the second deletion pass the lifetime and bounds checks, and then re-arm the ID so a forged object remained usable for the exploit endgame. The model measured ring occupancy and allocation offsets and tried multiple drain and sentinel strategies. It occasionally made the second deletion survive locally, but it could not stabilize the required sequence on fresh targets or complete an exploit.

The other campaigns explored different PTSan-specific failure modes without finding a usable route around enforcement. In rsync, a debugger-forced change to the bounds metadata showed what would be sufficient to let the protected copy pass, but the model found no program-reachable way to create that state. ImageMagick and NGINX probed allocator behavior, pointer representations, and alternate paths around protected operations, but none produced an artifact that committed the selected effect under PTSan. Across the four targets, the agents moved well beyond replaying public PoCs and tested plausible seams in the defense itself.

PTSan turned exploitation into a defense-research problem

This change in the attacker’s problem is the experiment’s central economic result. Without PTSan, each public vulnerability led to a verified PoC. With PTSan, reaching the known bug became the beginning of the work rather than the end: the model had to reverse-engineer and defeat a general enforcement mechanism, preserve the exploit’s useful effect, and pass independent replay. Eight billion tokens later, it had not done so. A defense does not need to make exploitation mathematically impossible to be valuable; it must change the attacker’s cost, reliability, and time horizon. An exploit that requires an extended defense-specific research campaign presents a very different operational risk from one an agent can derive directly from a patch.

Protection begins with rebuilding, not rewriting

AI is shrinking the time between disclosure and exploitation, creating a need for controls that apply before the next CVE is known and remain useful while a patch moves through testing and deployment. The long-term direction for new security-critical software is clear: use memory-safe languages, reduce unsafe components, and design for high assurance from the start. That direction does not, however, replace the C and C++ already running databases, proxies, media parsers, and network services.

PTSan is designed for workloads in that installed base. PTSan offers configurations for different allocation and overhead requirements, while its compiler analyses remove checks that can be proven redundant. Adoption starts by rebuilding an application and its dependencies with the PTSan LLVM toolchain. PTSan requires neither an application rewrite nor bug-specific annotations. The resulting instrumented code enforces allocation-level pointer authority at runtime, including for vulnerabilities that have not yet been discovered, and its software configurations run on commodity systems without special hardware or kernel changes.

PTSan is open source and ready for deployment. We are looking for teams that want to evaluate it on real workloads. If you operate an exposed, rebuildable Linux C or C++ service or parser, start with one compatible workload: rebuild it and its native dependencies, replay representative traffic, and measure the result. Read the build and dependency guide and performance data, or contact us at [email protected] to evaluate PTSan against your codebase and performance requirements.


Appendix: Detailed Methodology and Results

Research question and targets

The experiment asked an adversarial question: given a known vulnerability, the exact protected target, and full information about PTSan, could an autonomous model produce a replayable PoC that made a predeclared security-relevant effect occur despite strict PTSan enforcement? This was not a test of whether secrecy could delay an attacker, nor was it a vulnerability-discovery benchmark. Each CVE was already public, and the protected agent could study the application, the protected binary, and PTSan itself. The purpose was to determine whether the model could preserve or reconstruct the vulnerable effect while defeating the allocation-level checks intended to stop it. Because the vulnerabilities exposed different effects, each target had its own predeclared success criterion; a crash, PTSan report, allocator-corruption symptom, or theoretical exploitation argument did not count.

TargetPredeclared protected success criterion
Redis 8.6.4 / CVE-2026-66373A CVE-dependent serious consequence: remote code execution, an exact arbitrary file write, or retrieval of an unknown file
rsync 3.2.7 / CVE-2024-12084The selected 64-byte checksum write commits across the boundary of its allocation
ImageMagick 7.1.2-12 / CVE-2026-23876The selected one-byte out-of-bounds heap write commits
NGINX 1.31.8 / CVE-2026-123007An allocation-crossing copy commits and produces an attacker-visible 14,393-byte disclosure

Independent unprotected and protected campaigns

Each application first received an independent unprotected campaign. This established that the model and harness could produce a working PoC for the selected CVE before any failure against PTSan was interpreted as evidence for the defense. Evaluators replayed each submitted PoC on fresh vulnerable and selectively fixed targets; rsync and ImageMagick also used a still-vulnerable matched control to detect explanations based only on layout changes. All four unprotected campaigns passed their predeclared criteria, using a combined 176 million provider-reported tokens.

The protected campaign for each application began separately and did not receive the unprotected agent's PoC, transcript, or internal notes. It did receive the public vulnerability material, application source, exact stripped strict-PTSan target, PTSan source and design documentation, local compilation and binary-analysis tools, and access to fresh protected targets. The agent could inspect and disassemble the target, compile helpers, debug the supplied local material, and preserve notes and candidate artifacts. The selective fix, enforcement-disabled controls, evaluator witnesses, baseline outputs, and artifacts from other campaigns remained withheld. This design made the defense fully known while preserving an independent protected search.

The attacking model was DeepSeek V4.1 Flash 1017 Uncensored, run with a one-million-token available context, a 32,768-token maximum completion, and maximum reasoning effort. General internet access, package installation, subagents, and hidden cross-session model memory were disabled. The worker could interact only with the supplied local materials and the in-scope target interface. When a protected campaign continued into a new session, continuity came from preserved files and explicit evaluator feedback rather than undisclosed model state.

Independent replay and causal controls

The model did not grade its own submissions. At evaluation time, a frozen evaluator copied an immutable artifact to fresh matched targets and used evaluator-only symbols or process mappings to determine whether the selected operation was reached and whether it committed. This distinction was essential because a PTSan diagnostic demonstrates that a check fired, but does not by itself show that PTSan stopped an otherwise viable PoC. For rsync and ImageMagick, the decisive protected evaluation used five strict-PTSan replays, five enforcement-disabled replays, and five selectively fixed replays. A causally supported block required the exact operation to be reached and stopped before commit on strict PTSan, the same artifact to commit it with the decisive enforcement disabled, and the selective fix to remove or safely change the operation. Both applications produced this complete pattern.

NGINX used two fresh unprotected replays, one selectively fixed replay, and one strict-PTSan replay because its HTTP/2 path was substantially heavier. Redis used fresh vulnerable and fixed targets and required an externally observable serious consequence rather than accepting a memory-access witness alone. Across the experiment, a PTSan bypass required the selected effect to commit on strict PTSan while all causal controls passed. A causally supported PTSan block required strict PTSan to stop an effect that the same artifact committed with enforcement disabled and that the selective fix removed. An artifact that failed to reproduce, did not reach the selected operation, lacked a required control, or was absent was classified as inconclusive or as a causal-gate failure rather than being credited to PTSan.

Budgets, continuation, and recovery

The Redis, rsync, and ImageMagick protected campaigns initially received one-billion-token allocations. After an early rsync candidate produced a valid PTSan-blocked result, the stopping rule was amended so that a blocked candidate became intermediate evidence rather than the end of the search. Later sessions received the replay result and were instructed to pursue a materially different bypass until either a bypass was verified or the cumulative allocation was exhausted. After observing the interim results and token mix, the first three allocations were extended to two billion tokens. All earlier usage continued to count. NGINX began later under the two-billion-token, bypass-or-exhaustion design.

Recoverable completion boundaries, tool failures, and valid-but-blocked submissions could start a new session without resetting the experiment. The controller preserved the workspace, notes, best runnable artifact, evaluator feedback, and cumulative accounting. Across the four protected chains, this produced 101 model sessions, but every session remained charged to its application's single cumulative allocation. Each chain stopped at an approximately 1.999-billion-token live guard immediately below the two-billion-token hard cap. Together, the four chains consumed eight billion provider-reported tokens and produced no PTsan bypasses.

What the eight-billion-token total represents

The token mix matters because the eight-billion figure should not be read as eight billion newly generated reasoning tokens or eight billion uniformly priced uncached tokens. The accounting records separated cached input, uncached input, and model output; uncached input was derived from total input and reported cached input where necessary. A small number of calls whose final usage metadata was unavailable were charged conservative input and completion upper-bound debits. Because the cache status and exact completion composition of those debits were unknown, they are shown separately rather than assigned to the observed categories.

Token categoryProtected-campaign tokensShare of protected total
Cached input7.82B97.73%
Uncached input143M1.79%
Output/completion32M0.40%
Conservative unclassified debits6.5M0.08%
Total8.0B100%

Of the 32 million output tokens, approximately 27 million were reported as reasoning tokens. Reasoning is a subset of output and is therefore not added to the total a second time. Cached input remained part of the fixed resource allocation because it was processed and reported on each request, while its large share reflects the repeated long context needed to sustain an autonomous research chain across many iterations. The eight-billion total is therefore a measure of all provider-reported context and generation processed during the protected campaigns, not of eight billion fresh input or output tokens. It excludes target and evaluator compute as well as engineering time. The total is appropriate for enforcing the study's fixed provider-token allocations, but comparisons with other models, providers, or studies should preserve the token-type distinction.

Interpretation and limitations

The four protected outcomes are not interchangeable. rsync and ImageMagick ended with causally supported strict-PTSan blocks. Redis exhausted its allocation without a complete final serious-consequence artifact, while its earlier candidates did not establish the required causal controls. The defensible aggregate conclusion is that all four protected searches exhausted their allocations without a PTSan bypass.

This study is a four-target case series rather than a representative study over vulnerabilities or AI models. Failure to find a bypass within two billion tokens is not proof that no bypass exists; it is evidence that, for these four targets and this capable model, converting a known vulnerability into a verified PTSan bypass remained unsolved after a search budget 26 to 225 times larger than the corresponding unprotected PoC campaign.