BLA inflates AI reverse-engineering token bills 300x: how to defend against budget exhaustion attacks

A 607-byte archive becomes 16.93 MiB after hardening. That is not a compression bug. Someone packed roughly 4,000 decoy entries into the .asar header, each with a very long path and very short content, so the index alone blows past the analyzer's default read limit. QbitAI reported on 2026-11-10 that the project, called BLA, is an MCP server plus CLI built by a third-year software engineering undergraduate at Sun Yat-sen University, with 3,900+ stars and 476 forks on GitHub. The author's internal tests put the token cost of reverse engineering at 300x to 2,800x the original; estimated across 14 repository examples, total tokens come to about 639.5x and total spend about 304.4x (test details republished by Ifeng, November 2026).

Its target is REA, the "AI reverses everything" tool that collected 100k stars in a week. Treating this as a fun role reversal misses the point. BLA's three steps -- poison, exhaust the budget, induce misjudgment -- belong to the most uncomfortable research line of 2026: the final answer can be entirely correct while the bill explodes anyway.

The poison is evidence, not instructions

Bundled and minified web JavaScript often sits in a handful of lines. A SourceMap tells the debugger which original file and position each line maps to, sometimes including source text. For a reverse-engineering tool that is a ready-made signpost. BLA generates a format-valid map filled with invented source paths and code snippets, making an ordinary client-side routine look like it calls a hardware secure enclave, complete with a remote attestation endpoint and comments. Other decoys include fake credentials, fake diagnostics, and code branches that resemble authorization logic.

The clever part is that it never asks the model to do anything disallowed. It only raises the density of evidence that looks worth following. REA's analyzer first extracts modules, functions and call relationships from the file; the coding agent then decides where to look and how to interpret the feature. Everything fed in is legitimate input. Of 13 before-and-after pairs, 7 errored out or were refused at the tested step, 2 returned partial results, 1 failed only on a specific query, and 3 showed no observed block. Not an automatic win, but easily enough to bend the cost curve.

Budget exhaustion is already an established attack class

The January 2026 paper "Beyond Max Tokens: Stealthy Resource Amplification via Tool Calling Chains in LLM Agents" (Nanyang Technological University, UIUC, HKUST, Shanghai Jiao Tong University) lays out the mechanism. A compromised MCP tool server does not change what the tool does; it edits only the text-visible fields the agent reads and adds a template-driven return policy that nudges the agent into repeated tool calls and ever-expanding context. Function signatures stay valid and the final answer stays correct and benign. The researchers even used Monte Carlo Tree Search to tune those text edits, maximizing cost while preserving task success. Across six models on standard tool-use benchmarks, individual trajectories passed 60,000 tokens, per-query cost rose by up to 658x, energy use by 100x to 560x, and GPU KV cache occupancy climbed from under 1% to between 35% and 74%, cutting performance roughly in half for other tenants on the same hardware.

More followed. Clawdrain in March 2026 brought the same silent token exhaustion to coding agents. Unit 42's 2026-07-10 advisory classified RAG-poisoning-driven Denial-of-Wallet as RA-ICA, reporting that token-sink prompts embedded in PDF and XLSX metadata raise per-query consumption by about 1,300%. OWASP's 2026 reporting puts prompt-injection attempts up roughly 340% year over year, still the top risk for LLM applications. As TianPan's roundup of this line of work notes (2026-04-27), the trick is that every individual step sits inside its limit and only the sum exceeds it; the harness cooperates, because each step is compliant.

Why none of the three usual defenses catches it

  • QPS rate limits count requests, not cost. One request might spend 0.0001 USD against a cached prompt, or 0.50 USD on an agent loop with subagents. Both count as one. Keep the rate below the nominal ceiling and you can still drain a monthly budget.
  • A per-session token cap turns the cap into the attacker's target spend rate. The attack adapts to consume exactly what the limit allows. Multiplied across thousands of poisoned requests, that ceiling becomes the maximum reliably extractable amount per request.
  • Output monitoring is effectively blind. Per the evaluation figures collected in the roundup above, LLM-as-judge style detection catches these attacks less than 3% of the time. There is no hallucinated tool call, no suspicious string, and the answer is correct. The thing that is wrong is the cost, and most monitoring schemas have no cost field at all.

Read together, the conclusion is mildly counterintuitive. In this class of attack, cost is not an ops metric; it is the only visible symptom. That makes it a first-class observability signal, and it has to be metered at the moment the tool call happens, not at the end-of-month reconciliation.

On the 2026-11-12 Trending list, defenders took a different road

microsoft/TokenEconomizer, on GitHub Trending today, is a black-box cost plugin that explicitly leaves the agent's model, weights and code alone and works only through context, hooks, settings and a CLI. Its README reports 18.4% to 30.9% lower mean cost across five agent-model combinations on SWE-Bench, all 30 repository-by-combination cells cheaper, and 4 of 5 combinations improving Pass@1. Three mechanisms: micro-skills proposes repository facts every k=3 sessions (off by default, because proposing costs a model call); tool pruning removes a tool from agent settings after p=10 unused prompts across at least m=2 sessions, or s=5 unused sessions (on by default); loop guard first collects e=5 normally finished turns to learn the repository's usual turn, redirects only when judge confidence reaches c=0.7, at most r=1 redirect per turn, with a rule-based backstop when a churning turn exceeds b=2.5 times the usual length. It also states, carefully, that it never stops a turn itself.

Do not mistake that for a shield against attacks. It optimizes ordinary waste: rediscovering the same fact, loading tool definitions nobody uses, getting stuck in a failure loop. Against adversarial waste it has two gaps. The loop guard's judge is itself a paid model call, so an attacker can shape the trajectory to look permanently one step from success and trigger repeated redirects. Tool pruning learns "this tool has gone unused for a long time", while a poisoned trajectory hammers exactly the tool that just became hyperactive. A cost-saving plugin and a cost circuit breaker are different things: one does efficiency, the other does shutdown. OmniRoute, also on today's list, claims 15% to 95% token savings with RTK+Caveman compression and quota-aware fallback over 375 providers -- again saving, not defending. Real defense needs a model-independent counter at the tool boundary.

Hands-on: a model-independent cost gate for the tool layer

The script below is stdlib only; python budget_guard.py runs it as-is. It watches four quantities: cumulative session spend, per-step spend, characters in the tool result, and repeats of an identical call. Cross any one and it returns BLOCK, and the blocked step is not charged, which matters when you report how much was saved.

# budget_guard.py - stdlib only. Run: python budget_guard.py
# A cost gate for tool-using agents. No API key needed for this demo.

USD_PER_1M_INPUT = 0.10
USD_PER_1M_OUTPUT = 0.50
MAX_SESSION_USD = 0.02
MAX_STEP_USD = 0.01
MAX_TOOL_RESULT_CHARS = 6000
REPEAT_LIMIT = 3


def price(in_tok, out_tok):
    return (in_tok * USD_PER_1M_INPUT + out_tok * USD_PER_1M_OUTPUT) / 1000000


class CostGate:
    def __init__(self):
        self.spent = 0.0
        self.calls = {}
        self.steps = 0

    def check(self, tool_name, args, result, in_tok, out_tok):
        self.steps += 1
        cost = price(in_tok, out_tok)
        sig = (tool_name, repr(sorted(args.items())))
        self.calls[sig] = self.calls.get(sig, 0) + 1
        reasons = []
        if len(result) > MAX_TOOL_RESULT_CHARS:
            reasons.append("tool result %d chars exceeds cap %d"
                           % (len(result), MAX_TOOL_RESULT_CHARS))
        if cost > MAX_STEP_USD:
            reasons.append("step cost %.6f exceeds cap %.6f"
                           % (cost, MAX_STEP_USD))
        if self.calls[sig] >= REPEAT_LIMIT:
            reasons.append("repeated identical call %s x%d"
                           % (tool_name, self.calls[sig]))
        if self.spent + cost > MAX_SESSION_USD:
            reasons.append("session spend %.6f + %.6f exceeds cap %.6f"
                           % (self.spent, cost, MAX_SESSION_USD))
        if reasons:
            return "BLOCK", reasons, self.spent
        self.spent += cost
        return "OK", [], self.spent


def scenario(title, steps):
    gate = CostGate()
    print("==", title)
    for step in steps:
        verdict, reasons, spent = gate.check(*step)
        print("   step %d %-10s %-5s spent_usd=%.6f"
              % (gate.steps, step[0], verdict, spent))
        for r in reasons:
            print("      reason:", r)
        if verdict == "BLOCK":
            print("   STOPPED; unspent budget usd=%.6f"
                  % (MAX_SESSION_USD - spent))
            return


def demo():
    normal = [
        ("read_file", {"path": "src/app.py"}, "import os; app = create_app()", 1200, 200),
        ("run_tests", {"cmd": "pytest -q"}, "3 passed", 1800, 150),
        ("grep", {"pattern": "TODO"}, "2 matches", 2100, 120),
    ]
    scenario("normal trajectory", normal)

    decoy = "// sourceMappingURL=hw/secure_enclave/attest.js.map "
    oversized = [
        ("read_file", {"path": "hw/bundle.js"}, decoy * 200, 9000, 1200),
    ]
    scenario("poisoned decoy SourceMap", oversized)

    loop = [
        ("read_file", {"path": "hw/secure_enclave/attest.js"}, decoy, 2500, 300),
        ("read_file", {"path": "hw/secure_enclave/attest.js"}, decoy, 2500, 300),
        ("read_file", {"path": "hw/secure_enclave/attest.js"}, decoy, 2500, 300),
    ]
    scenario("agent stuck in a tool loop", loop)

    slow = [("search_docs", {"q": "enclave attest %d" % i}, "no match", 40000, 2000)
            for i in range(8)]
    scenario("slow burn under the per-step cap", slow)


if __name__ == "__main__":
    demo()

The four scenarios produce this shape, which is what your logs should look like:

== normal trajectory
   step 1 read_file  OK    spent_usd=0.000220
   step 2 run_tests  OK    spent_usd=0.000475
   step 3 grep       OK    spent_usd=0.000745
== poisoned decoy SourceMap
   step 1 read_file  BLOCK spent_usd=0.000000
      reason: tool result 10400 chars exceeds cap 6000
   STOPPED; unspent budget usd=0.020000
== agent stuck in a tool loop
   step 1 read_file  OK    spent_usd=0.000400
   step 2 read_file  OK    spent_usd=0.000800
   step 3 read_file  BLOCK spent_usd=0.000800
      reason: repeated identical call read_file x3
   STOPPED; unspent budget usd=0.019200
== slow burn under the per-step cap
   step 1 search_docs OK    spent_usd=0.005000
   step 2 search_docs OK    spent_usd=0.010000
   step 3 search_docs OK    spent_usd=0.015000
   step 4 search_docs OK    spent_usd=0.020000
   step 5 search_docs BLOCK spent_usd=0.020000
      reason: session spend 0.020000 + 0.005000 exceeds cap 0.020000
   STOPPED; unspent budget usd=0.000000

Three details worth carrying into production. Build the signature from (tool_name, normalized args), not the tool name alone, or deduplicating by name will kill legitimate multi-file reads. Apply the character cap to the returned content rather than the request, since the payload lives almost entirely in the result. Pair the session cap with an external hard limit such as a provider-side spend cap or a project budget; the gate is an early breaker, not a vault. And tune the 6,000-character and 0.02 USD thresholds against your own trajectory distribution instead of copying these.

QbitAI's headline was about making the attacker's token bill jump 300x, which is satisfying to read. For anyone running agents in production, the line worth keeping is a different one: when the output is correct, the input is legitimate, and every step stays under its cap, the only thing that can tell you something went wrong is the curve drawn in tokens.

Further reading

Commentaires

Ce site est uniquement frontal : pas de backend ni de compte. Les commentaires vont sur GitHub Issues, Discussions ou par e-mail.

Collez ceci dans l'issue ou l'e-mail pour m'aider à localiser le problème ; cela n'inclut rien de ce que vous avez saisi

Aussi :Voir les commentaires existants · Commentaires par e-mail (sans compte GitHub) :278975598@qq.com