arXiv:2611.08711cs.CLNov 2026

Manuscript Offprint

arXiv:2611.08711

RL-ATTACK: A Generalized Black-Box Adversarial Attack on Language Models via Reinforcement Learning

Taikun Chen, Yue Zhang, Wei Qian, Hui Fang

Taikun Chen*, Yue Zhang†, Wei Qian*‡, and Hui Fang*†

*Financial Services Analytics

†Department of Electrical and Computer Engineering

‡Department of Applied Economics and Statistics

University of Delaware, Newark, DE, USA

{taikun, zhangyue, weiqian, hfang}@udel.edu

Corresponding author: taikun@udel.edu

Abstract—Large language models (LLMs) exhibit vulnerabilities to adversarial perturbations that can induce unintended responses. These vulnerabilities can be identified via intentional attacks and subsequently used to improve model safety. In black-box settings where gradients are inaccessible, existing methods tend to guess adversarial transformations using external knowledge, ignoring the information provided by the target model. To mitigate this, we propose a trainable black-box framework based on reinforcement learning, which learns from the target model to generate tailored adversarial transformations. We demonstrate that our approach achieves lower post-attack accuracy, greater query efficiency and better semantic preservation on both natural language inference and generative Q&A tasks. On natural language inference, it drives post-attack accuracy to 2% within 20 queries. Against generative language models, our trained attacker consistently achieves lower post-attack accuracy than the untrained attacker and wins in 4 out of 6 settings when compared to a strong optimization-based baseline. We further experiment with multiple reward designs and training settings, and we find that no design or setting is consistently dominant. Our code is available at https://github.com/taikunudel/RL-ATTACK.

Index Terms—Adversarial machine learning, large language models (LLMs), natural language inference, question answering, reinforcement learning

I. INTRODUCTION

Large language models (LLMs) such as BERT-based classifiers [1]–[4] and generative models like Llama, Gemini and ChatGPT [5]–[7] have achieved significant performance jumps in various natural language understanding tasks such as natural language inference and generative question answering. However, their internal mechanisms remain poorly understood, and the models exhibit unexpected vulnerabilities.

Modern natural language classifiers and generative LLMs are susceptible to adversarial prompts [8], [9], as they may generate incorrect or unsafe answers violating social standards. Figure 1 illustrates some observed vulnerabilities in language

References (34)