Skip to content

Hardening JavaScript Programs Against LLM-Based Vulnerability DetectionHardening JavaScript Programs against LLM-Based Vulnerability Detection

arXiv: 其他 AI 安全论文· arXiv:2611.25718· Zhenhao Tian, Jintong Yu, Jingwei Feng, Jianwei Zhuge, Penghui LiNanyang Technological University; Tsinghua University; Shanghai Jiao Tong UniversityIndexed by this site · 4 days ago· Originally publishedDefenses· Its place in the scan record →

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose AntiAgent, which uses evolutionary search to discover code transformation rules that harden JavaScript programs, and the authors claim that on 40 real applications it reduces the number of vulnerabilities detected by four detection agents by 52.0–60.7%.

Threat modelDevelopers apply semantics-preserving transformations to JavaScript programs before release; the attacker is a motivated attacker who can inspect the transformed program and run off-the-shelf coding agents or dedicated vulnerability detection agents, but per the assumptions of prior anti-analysis work, the attacker does not have a copy of the untransformed original source code, and source code leakage is out of scope.

Questions
JavaScript is often distributed as source code, and attackers have used LLM agents such as Claude Code and Codex for malicious vulnerability analysis. Developers need a pre-release hardening method that reduces these agents' ability to detect vulnerabilities while preserving semantics.
Methods
AntiAgent performs evolutionary search on a corpus containing known vulnerabilities, uses the detection agent's analysis traces to guide mutations, retains transformations that cause the agent to miss or falsely report vulnerabilities and extracts them as reusable AST rules; when protecting a new program, an LLM selects rules and tunes parameters, the rules perform deterministic rewriting, and identifier renaming is added.
Experiments and results
On 40 real JavaScript applications, the authors report that AntiAgent reduces the number of vulnerabilities detected by four detection agents by 52.0–60.7%, outperforming JS-Obfuscator and FPA; transformed programs pass all 10,062 tests, with execution time 1.11× and size 1.37×; the rules also generalize to vulnerability types outside the corpus and to Python.
Limitations and future work
The authors point out that it is not formally proven that the rules preserve semantics, and that this is supported only empirically by manual inspection and testing experience; under a rule-aware attacker, DSR drops to 32.00%; each agent still reports about one quarter to one half of the vulnerabilities; the evaluation covers 4 detection agents, 40 JavaScript programs, and 10 Python cases.
Experimental setupCodex (GPT-6.1-sol)、Claude Code (Claude Opus 5.5) et al. · 40 个真实 JavaScript 应用数据集(漏洞来自 GitHub Security Advisory)、SecBench.js(规则发现语料) et al. · DSR、Recall et al.
Evaluated models
Codex (GPT-6.1-sol)Claude Code (Claude Opus 5.5)ZCode (GLM-5.3)OpenAnt (GPT-6.1-sol)
Benchmarks
40 个真实 JavaScript 应用数据集(漏洞来自 GitHub Security Advisory)SecBench.js(规则发现语料)10 个 Python 案例(跨语言扩展)
Metrics
DSRRecallPrecision检测时间与 API 成本测试通过率PoC 成功率执行时间与代码体积倍数
AI summaryResearchers propose a defense method, AntiAgent, that lets developers transform JavaScript programs before release to hinder LLM-based vulnerability detection agents from analyzing vulnerabilities in the source code. The method evolves variants using a corpus of programs with known vulnerabilities, traces the detection agent's analysis process for each variant, retains versions that the agent misses or misreports, and distills their transformations into reusable rules; when protecting a new program, an LLM and the rules divide the work so that the transformation adapts to the program while preserving semantics. In evaluation on real JavaScript applications against four detection agents (including Claude Code and Codex), AntiAgent reduces the number of vulnerabilities detected by each agent by 52.0-60.7%, outperforming the traditional obfuscator JS-Obfuscator and the LLM-based transformation method FPA on every agent; the transformed programs pass all project tests, and the transformation rules remain effective against vulnerability types not present in the corpus and against programs written in other languages such as Python.

Researchers propose a defense method, AntiAgent, that lets developers transform JavaScript programs before release to hinder LLM-based vulnerability detection agents from analyzing vulnerabilities in the source code. The method evolves variants using a corpus of programs with known vulnerabilities, traces the detection agent's analysis process for each variant, retains versions that the agent misses or misreports, and distills their transformations into reusable rules; when protecting a new program, an LLM and the rules divide the work so that the transformation adapts to the program while preserving semantics. In evaluation on real JavaScript applications against four detection agents (including Claude Code and Codex), AntiAgent reduces the number of vulnerabilities detected by each agent by 52.0-60.7%, outperforming the traditional obfuscator JS-Obfuscator and the LLM-based transformation method FPA on every agent; the transformed programs pass all project tests, and the transformation rules remain effective against vulnerability types not present in the corpus and against programs written in other languages such as Python.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    How to harden JavaScript source code before release so that LLM vulnerability detection agents find it harder to discover vulnerabilities in it while preserving semantics.

    Core problem: JavaScript programs are distributed as source code, attackers can use LLM vulnerability detection agents to analyze vulnerabilities in them, and developers need a pre-release hardening method.

    • Setting and motivation: The authors cite OALABS's analysis of attack logs and a report from Anthropic, saying attackers have used Claude Code and Codex to identify vulnerable services, develop exploits, and exfiltrate customer data. Developers cannot stop others from analyzing the code and can only transform the program before release.
    • Shortcomings of existing methods: The authors say traditional obfuscators such as JS-Obfuscator change only surface syntax with fixed patterns, agents can still trace vulnerable data flow, and at medium configuration execution time and size more than double; FPA and CoTDeceptor do not guarantee behavior preservation, and in this paper's evaluation FPA-transformed programs pass only 68.52% of the projects' tests.
    • Core observation: Effectiveness requires novel transformations that the detection agent does not recognize, and semantic preservation requires transformations to be limited to predefined operations; therefore the authors discover transformations through search and extract them as reusable rules.
    • The paper proposes: AntiAgent, which evolutionarily searches for effective transformations on a corpus containing known vulnerabilities, extracts them as rules, and then has an LLM select rules and the rules perform deterministic rewriting to protect new programs.
    • Threat model (§3):
      • Goal: Developers transform the program before release to reduce the probability that agents detect vulnerabilities, while preserving semantics.
      • Attacker: a motivated attacker who inspects the transformed program to find exploitable vulnerabilities.
      • Capability: can run off-the-shelf coding agents or dedicated vulnerability detection agents.
      • Assumption: the attacker does not have a copy of the untransformed original source code; source code leakage is out of scope.
  2. What related research exists?

    Related work falls into three groups: LLM vulnerability detection agents, JS obfuscation and transformations targeting LLMs, and anti-analysis techniques; the baselines are JS-Obfuscator and FPA.

    LLM vulnerability detection agents

    • RepoAudit (ICML 2025), Enigma (ICML 2025), etc. — dedicated harnesses that combine models with analysis tools or code property graphs for repository-level auditing.
    • Claude Code, Codex — general-purpose coding agents that can directly audit codebases; the authors cite the CyberGym leaderboard as saying Claude Code with GLM-5.3 achieves an 84.5% success rate on real vulnerability reproduction tasks.

    JavaScript obfuscation and code transformations targeting LLMs

    • Minification and JS-Obfuscator — shorten identifiers, encode strings, flatten control flow; the authors criticize them for changing only surface syntax with fixed patterns, so agents can still trace data flow.
    • FPA (NDSS 2026) — embeds modified familiar patterns in branch conditions to mislead models; the authors criticize it for validating only the injection pattern itself, and in this paper's evaluation its transformed programs pass only 68.52% of tests.
    • CoTDeceptor (2025) — uses the detector's chain of thought to search for transformations program by program; the authors criticize it for requiring prior knowledge of the vulnerability, not guaranteeing semantics, and not being evaluated under a full-repository audit setting.
    • RedHerring (2026) — inserts provably safe decoys to divert the agent's verification effort; the authors note it does not hide the real vulnerability and is evaluated only on a single agent framework and C/C++ memory-safety vulnerabilities. Natural (2026) — relies on a coding agent to rewrite natural-language skills program by program, with semantic preservation depending on each generated edit.

    Anti-code-analysis (anti-analysis)

    • Popov et al. (2007), Loki (USENIX Security 2022) — binary obfuscation that resists disassembly and symbolic execution.
    • Fuzzification (USENIX Security 2019), AntiFuzz (USENIX Security 2019) — anti-fuzzing, slowing fuzzing and hiding crashes; the authors say AntiAgent has a similar goal but targets LLM agents' code search and data-flow tracing.

    Baselines and benchmarks: the comparison baselines are JS-Obfuscator v5.9.0 (medium configuration) and FPA (also configured with GLM-5.3 for transformation); CoTDeceptor, RedHerring, and Natural were not compared because they are not publicly available. The rule-discovery corpus uses SecBench.js, and evaluation uses the authors' self-built dataset of 40 real applications.

    The authors position this paper as: an anti-analysis defense against LLM detection agents, sharing the goal of "making vulnerabilities harder to find" with anti-fuzzing, but targeting agents' code investigation methods.

  3. How does the paper address this problem?

    Evolutionary search discovers effective transformations → extracts them as AST rules → LLM selects rules, rules deterministically rewrite, plus identifier renaming.

    Overall approach: AntiAgent separates "discovering effective transformations" from "preserving semantics" — it searches using semantics-preserving predefined operations, extracts transformations that mislead detection agents as rules, and at application time the LLM only makes selections and does not write code.

    Transformation discovery (§4.1)

    • Evolutionary tree search: using the 40 programs in SecBench.js with known vulnerabilities and PoCs as the corpus, each program has one evolutionary tree, and each node records the program, detection trace, policy set, degradation score Dv, and novelty score Nv; each corpus program is searched for 300 iterations.
    • Trace guidance: the LLM evolution agent decides where to obfuscate next based on the data-flow trace (the source-to-sink paths reported by the agent) and the agent trace (tool call sequence), and is required to use policies not yet appearing in the tree.
    • Degradation score: each detection run is scored sv,j = wd dv,j + wa (1 − av,j) + wh hv,j, combining path distance, type accuracy, and detection time, with weights (0.50, 0.30, 0.20); Dv is the mean over valid runs, and runs that do not report the vulnerability receive the full score of 1.
    • Node selection: with probability 1−p select exploit mode (favoring nodes with high Dv), with probability p select explore mode (favoring nodes with high Nv), p = 0.25.

    Rule extraction (§4.2)

    • Rule form: a rule = a matching condition on the AST + an operation; operations reference captured expressions via placeholders and can declare string parameters, and rules of the same policy form a family.
    • Extraction process: extracted from parent-child pairs where Dv exceeds a threshold and is higher than the parent node; the LLM extraction agent generates the matching condition and operation, and applying them to the parent node must exactly reproduce the child program and the PoC must still trigger.
    • Manual filtering: a family is included only if supported by changes from two different nodes; the authors manually check that each rule preserves behavior and introduces no new vulnerabilities, yielding 13 families and 111 rules.

    Rule application (§4.3)

    • Division of labor: the LLM application agent selects rules at each matching point and adjusts the editable parameters declared by the rules (or skips), and the rules perform fixed, deterministic AST operations; the agent cannot change the matching conditions or operations.
    • Checking and retry: changes from each family are retained only after passing syntax and interface checks (comparing exports with registered endpoints), otherwise the failure is fed back and selection is repeated, up to k times, with k set to 2.
    • Identifier renaming: identifiers of key functions whose names contain predefined keywords are renamed, method and property accesses are changed to encoded strings invoked via Reflect.apply(), and a static check is performed at the end.

    Implementation and setup (§5)

    • Implementation: 13.4K lines of Python + 2K lines of TypeScript, evolution based on OpenEvolve 0.3.0, AST operations using Babel 7.28, checks using Node.js 24.14.0.
    • Models used: in the discovery stage the detection agent is Claude Code CLI 2.1.146 with GLM-5.3, network-isolated with web search disabled; the application agent defaults to Claude Code with GLM-5.3 (the authors say because its cost is far lower than frontier models).
  4. What experiments did the paper conduct?

    Defense effectiveness, semantic preservation, generalization, component contribution, deployment cost, and rule characteristics were tested on 40 real JS applications and 4 detection agents.

    Experimental setup

    • Detection agents tested (4): Codex (GPT-6.1-sol), Claude Code (Claude Opus 5.5), ZCode (GLM-5.3), OpenAnt (running on Codex CLI, GPT-6.1-sol); all have web search disabled, a unified audit template, and the high effort setting.
    • Dataset: 40 real JavaScript applications, each containing one known vulnerability, selected from GitHub Security Advisory with disclosure dates later than the release of all tested models (earliest April 2026); on average 151.8 files and 36,875 lines of code, covering 13 vulnerability types (Table 7).
    • Baselines: JS-Obfuscator v5.9.0 (medium configuration, controlFlowFlatteningThreshold and deadCodeInjectionThreshold both 0.5) and FPA (configured with GLM-5.3).
    • Metrics: DSR (relative decrease in the number of ground-truth vulnerabilities detected after defense), recall, precision, detection time, and API cost; precision is confirmed by manual review of reports by two authors.
    • Repetitions: each setting repeats detection 3 times and reports the mean.

    Main results

    According to Table 2(a) (DSR / Recall / Precision, %):

    Swipe horizontally to read the table

    Detection agentUndefended RecallJS-Obfuscator DSRFPA DSRAntiAgent DSRAntiAgent Recall
    Codex62.5020.008.0052.0030.00
    Claude Code100.0047.5022.5055.0045.00
    ZCode70.0025.0010.7160.7127.50
    OpenAnt87.5045.7151.4360.0035.00
    • The authors say AntiAgent's DSR is higher than both baselines on every agent, and more consistent across agents; baseline effectiveness fluctuates across agents.
    • The authors say AntiAgent reduces each agent's precision to the lowest (32.3–58.8%), requiring attackers to verify more false positives.
    • Detection cost: the authors report that the detection API cost for AntiAgent-transformed programs is 1.22–2.70× that of undefended (Table 2b).

    Semantic preservation and overhead (§6.3, Table 3)

    • Tests and PoCs: AntiAgent passes all 10,062 test cases and all 40 PoCs still trigger; JS-Obfuscator passes 88.46% of tests with 37 PoCs triggering; FPA passes 68.52% of tests with 33 PoCs triggering.
    • Differential testing: under 20,000 inputs (500 per program) AntiAgent shows no functional divergence, while JS-Obfuscator and FPA have divergence rates of 91.70% and 83.74% respectively.
    • Overhead: execution time 1.11×, size 1.37×; JS-Obfuscator is 2.46× and 2.63×.

    Generalization (§6.4)

    • Vulnerability types outside the corpus: for 24 programs whose types are not among the five categories in the discovery corpus, DSR is 50.0–62.5%, comparable to 45.6–66.7% for the 16 programs with in-corpus types.
    • Cross-agent: the rules were discovered only against Claude Code (GLM-5.3), but DSR is comparable across four agents with different harnesses or models (Table 2a).
    • Cross-language: AntiAgent-Py, with 60 rules manually ported, reduces Codex recall from 70.0% to 40.0% on 10 Python cases, with DSR 42.86% (Table 8).

    Component analysis (§6.5, Table 4, all using Codex for detection)

    • Application agent: removing it and selecting rules in a fixed order drops DSR from 52.00% to 12.00%; switching to Claude Opus 5.5 gives DSR 56.00%.
    • Rule set: with no rules and letting the LLM rewrite directly, DSR is 0.00% and only 79.13% of tests pass; identifier renaming alone gives DSR 12.00%; a random half of the rules gives DSR 40.00%.
    • Defense-aware detection: telling the agent that a defense may exist drops DSR to 40.00%; under a rule-aware attacker that is further given rule family descriptions and first removes comments and dead code, DSR is 32.00% (recall 42.50%).

    Other ablations and analyses

    • Discovery process ablation (10 corpus programs, 100 mutations each): full discovery yields 14 rules and DSR 28.0%; removing trace or policy guidance yields only 3 and 4 rules, both with DSR 12.0% (text related to Table 5).
    • Deployment cost (§6.6, Table 6): rule discovery and extraction is a one-time cost of about 433 hours and $731; per program an average of $1.94 and 45.01 minutes, median $1.31 and 11.94 minutes.
    • Rule usage (§6.7, Table 5): 60/111 rules were applied, covering all 13 families; F13 is used for all 40 programs, F08 for 39, and F02 for only 1.
    • Failure cases (§6.2.2): among 12 reproducible failure cases under Codex, 8 key checks remain readable and 4 decoding helpers provide the information needed to recover the encoded expressions.
  5. What are some points that can be further explored?

    The authors point out that semantic preservation is not formally proven and plan a conditional release; the experiments cover 4 agents, 40 JS programs, and 10 Python cases.

    Limitations noted by the authors and future directions

    • No formal proof of semantic preservation (§7 Limitations): the authors say they do not formally prove that the rules preserve semantics, and instead empirically support this by manually checking each rule and running tests on transformed programs; they also note that formally proving equivalence for dynamic languages such as JavaScript remains difficult and leave it for future work.
    • Dual-use risk and release plan (§7 Dual Use): the authors say the same transformations could be misused to hide vulnerabilities in malicious code or obstruct legitimate security review, and they plan to release AntiAgent only conditionally after reviewing requesters' intended use.
    • Reduced effectiveness under defense-aware attacks (§6.5): under a rule-aware attacker DSR drops to 32.00%, and the authors only say "it remains effective even if the attacker knows the rules," without proposing countermeasures.
    • Cross-language port is a prototype (§E.3): the authors say AntiAgent-Py manually ported only some rules, its DSR is lower than the results on JavaScript, and it could be improved by porting the remaining rules or discovering rules directly on Python programs.

    Scope of experimental coverage

    • The detection agents tested are Codex, Claude Code, ZCode, and OpenAnt, 4 in total; the rule discovery stage uses only one agent, Claude Code (GLM-5.3).
    • The evaluation dataset is 40 real JavaScript applications with 13 vulnerability types, one known vulnerability per program; the cross-language experiment is 10 Python cases.
    • The comparison baselines are JS-Obfuscator and FPA, two in total; CoTDeceptor, RedHerring, and Natural were not included in the comparison because they are not publicly available (§6.1).
    • Each setting repeats detection 3 times and reports the mean; the paper does not report human agreement statistics on detection agent outputs (such as inter-annotator agreement).
    • Both the component analysis and the defense-aware experiment use Codex (GPT-6.1-sol) as the detection agent (§6.5).
  6. Summarize the main content of the paper

    AntiAgent hardens JavaScript programs with transformation rules found via evolutionary search; the authors say the number of vulnerabilities detected by four detection agents drops by more than half while semantics are preserved.

    AntiAgent is a JavaScript program hardening defense against LLM vulnerability detection agents, targeting the threat of attackers using coding agents to analyze released source code for vulnerabilities.

    • Problem: the authors cite attack logs and vendor reports as saying LLM agents have been used for malicious vulnerability analysis; traditional obfuscators change only surface syntax, and existing transformations targeting LLMs do not guarantee semantics.
    • Method: evolutionary search on the SecBench.js corpus, using the detection agent's data-flow and tool-call traces to guide mutations, selecting nodes by degradation score and novelty score; extracting effective transformations as 13 families and 111 AST rules; at application time the LLM only selects rules and tunes parameters, the rules perform deterministic rewriting, and identifier renaming is then applied.
    • Defense effectiveness: on 40 real applications, the authors report DSR of 52.0–60.7% for four detection agents, higher than JS-Obfuscator (20.0–47.5%) and FPA (8.0–51.4%); Claude Code, which has 100% recall when undefended, detects only 45.0% after transformation.
    • Semantics and overhead: transformed programs pass all 10,062 tests and all 40 PoCs still trigger, with execution time 1.11× and size 1.37×; the baselines' test pass rates are only 88.46% and 68.52%.
    • Generalization and robustness: the rules achieve DSR 50.0–62.5% on vulnerability types outside the corpus, and the Python prototype achieves DSR 42.86%; under a rule-aware attacker DSR drops to 32.00%.
    • Authors' conclusion: the authors consider protecting code against analysis-oriented agents an important and growing direction and hope AntiAgent will drive more such defense research; they also acknowledge the absence of a formal proof of semantic equivalence and plan to release conditionally after reviewing intended use.
Read originalarxiv.org