arXiv:2611.04356cs.CRNov 2026

Manuscript Offprint

arXiv:2611.04356

CloakFEM: Agentic FEM Code Generation for Red-Teaming Computational Resource Exhaustion

Li Zheng, Simin Chen

ABSTRACT

Finite element method (FEM) solvers are foundational to scientific and engineering simulation, yet their susceptibility to efficiency attacks remains largely unexplored. An adversary can craft syntactically valid and runnable FEM programs that complete successfully while forcing excessive computational work, enabling computational denial-of-service (DoS) attacks. Finding such inputs is challenging because FEM programs occupy a vast, structured space constrained by numerical, geometric, and constitutive requirements. We introduce CloakFEM, a domain-guided LLM-agent framework for automatically generating runnable adversarial FEM programs that amplify solver computation. CloakFEM combines LLM-guided search with an FEM-specific intermediate representation and a deterministic validity gate that enforces runnable constraints. Across three FEM stacks, 17 problem classes, and 1,068 seeds, CloakFEM discovers adversarial inputs that substantially amplify solver work while remaining valid and solvable. In the most extreme case, solver iterations increase from 43 to 247,367, a 5,752.72×5,752.72\times amplification. CloakFEM outperforms five generic black-box baselines and retains an advantage over evolutionary search under a controlled bounded action space. Cross-solver analysis further reveals both problem-intrinsic and solver-specific sources of vulnerability. Our results uncover an underexplored efficiency-attack surface in FEM solvers and show that runnable FEM programs can serve as adversarial inputs.

⟨⟩ GitHub: https://github.com/STAR-Computing/CloakFEM

Keywords Code Generation; LLM Agent; Adversarial Attack; FEM Testing

1 Introduction

Finite element method (FEM) solvers are essential tools for scientific and engineering simulation, supporting applications such as structural analysis, fluid dynamics, and electromagnetics. Users specify a physical problem through an FEM program, and the solver converts it into numerical systems for approximate solution (Hughes, 2000; Strang and Fix, 2008). As FEM workloads increasingly run in shared and automated computing environments (Stanke et al., 2020), their input-dependent computational behavior introduces a new security concern.

In particular, FEM solvers can be vulnerable to efficiency attacks, in which an adversary crafts a valid FEM program that forces the victim solver to perform excessive computation. Such an input can remain syntactically valid and satisfy numerical and constitutive constraints while inducing expensive solver behavior. Small changes to meshes, physical parameters, boundary conditions, or loads and sources can substantially alter conditioning and convergence, leading to excessive iterations, memory consumption, or runtime (Babuška and Suri, 1992; Saad, 2003; Trefethen and Bau, 1997). In shared clusters or simulation services, adversarial FEM

†This work is done during the internship in STAR Lab, George Mason University.

STAR LAB / RESEARCH PREPRINT

CloakFEM : Agentic Adversarial FEM Program Generation

programs can therefore monopolize computational resources, increase operational costs, and delay other users, potentially enabling computational denial-of-service (DoS) attacks (Crosby and Wallach, 2003; Staicu and Pradel, 2018; Davis et al., 2018). Unlike malformed-input attacks, these adversarial programs may remain runnable and complete successfully, making them difficult to distinguish from legitimate but computationally expensive workloads.

This raises a fundamental question about the security of FEM solvers against efficiency attacks:

Can an adversary systematically generate syntactically valid and runnable FEM programs that induce computational resource exhaustion in FEM solvers?

Existing attack techniques are poorly matched to this threat model for three reasons: (1) heterogeneous attack surfaces: FEM solvers use different input languages, APIs, data structures, and configuration formats, making it difficult to define a unified attack space across solver stacks; (2) compileable and runnable constraints: adversarial changes to geometry, meshes, materials, boundary conditions, or loads must preserve syntactic validity and satisfy runnable and numerical constraints, while arbitrary modifications can easily yield invalid or meaningless programs; and (3) limited search guidance under black-box access: unlike attacks on differentiable neural networks, FEM solvers provide no gradients or fine-grained optimization signals. The attacker observes only execution outcomes over a vast, structured program space, making it difficult to identify inputs that induce poor conditioning, slow convergence, or other expensive solver behavior.

To address these challenges, our key insight is to combine solver-independent abstraction, FEM domain knowledge, and LLM-guided black-box search. Based on this insight, we introduce CloakFEM, a domain-guided LLM-agent framework for generating runnable adversarial FEM programs that amplify victim-side computation. First, CloakFEM maps heterogeneous native FEM specifications into a solver-independent intermediate representation (IR) that exposes editable materials, boundary conditions, loads and sources, geometry, and mesh perturbations while protecting solver configurations. Second, it incorporates FEM domain knowledge and deterministic compileability and runnability checks to constrain modifications and ensure valid executable programs. Third, an LLM agent reasons over these semantic components and iteratively refines candidate programs using solver execution feedback, steering the search toward increasingly expensive behavior without requiring gradient information.

We evaluate CloakFEM across three FEM stacks, 17 problem classes, and 1,068 configurations against five generic black-box baselines under the same solver-query budget. CloakFEM finds runnable adversarial FEM programs that increase solver work by up to 5,752.72×, from 43 to 247,367 iterations. It outperforms generic black-box methods in the unrestricted setting and retains a smaller advantage over evolutionary search under a matched bounded action space. Cross-solver replay further shows that amplification can stem from both problem-intrinsic numerical difficulty and implementation- or discretization-specific sensitivity. Overall, these results expose an underexplored efficiency-attack surface in FEM software.

Our contributions are summarized as follows:

  • Problem Novelty. We identify and systematically study efficiency attacks against FEM solvers, in which syntactically valid and runnable FEM programs induce excessive victim-side computation and potentially enable computational DoS.

  • Technique Novelty. We propose CloakFEM, a domain-knowledge-guided LLM-agent framework that combines a solver-independent FEM IR, validity-aware adversarial transformations, and feedback-guided black-box search to generate computationally expensive FEM programs across heterogeneous solver stacks.

STAR LAB / RESEARCH PREPRINT

CloakFEM : Agentic Adversarial FEM Program Generation

Figure

Figure 1. Finite-element workflow and representative applications. Images are adapted from User A1 (2010); Howard (2008); SimScale GmbH (2014); Feel++ Project.

  • Empirical Evaluation. Across three FEM stacks, 17 problem classes, and 1,068 configurations, CloakFEM exposes substantial computational amplification, reaching up to 5,752.72× solver iterations, and outperforms generic black-box search methods under both unrestricted and controlled comparison settings.

To the best of our knowledge, this is the first large-scale study of LLM-agent-guided efficiency attacks against FEM solvers through runnable adversarial FEM program generation.

References (37)