[인공지능 서비스 보안] 탈옥 공격으로부터 LLM을 보호하는 방법 , How to Protect LLMs from Jailbreaking Attacks
[인공지능 서비스 보안] 탈옥 공격으로부터 LLM을 보호하는 방법 , How to Protect LLMs from Jailbreaking Attacks
탈옥 공격으로부터 LLM을 보호하는 방법
노아 플라이슈만, 에이미 와고너 박사, 앙드레 응우옌 박사

Booz Allen은 모델 무결성을 강화하는 방법을 조사합니다.
연방 기관들은 업무를 간소화하고 질문에 답하기 위해 Llama-2 및 ChatGPT와 같은 대규모 언어 모델(LLM)을 운영에 점점 더 통합하고 있습니다. 엔지니어들은 이러한 모델이 “유용하고 무해하도록” 설계하고 위험한 요청은 거부합니다. 미세 조정, 인간 피드백을 활용한 강화 학습, 직접 선호도 최적화와 같은 기법은 모델 안전성을 더욱 향상시킬 수 있습니다. 그러나 이러한 조치에도 불구하고, 탈옥 프롬프트라는 심각한 LLM 취약점이 AI 시스템을 계속 위험에 빠뜨리고 있습니다.
탈옥 프롬프트는 LLM이 해서는 안 될 일을 하도록 속이는 특정 입력값입니다. 교묘하게 설계되었지만 악의적인 이러한 프롬프트는 가장 강력한 보안 조치조차 우회하여 연방 정부 업무에 심각한 위험을 초래할 수 있습니다.
이러한 과제를 해결하기 위해 부즈 앨런은 탈옥에 대한 새로운 방어책을 모색하고 있습니다. 이러한 접근 방식은 기관에 상당한 임무 이점을 제공할 수 있습니다. 즉, LLM이 무해한 프롬프트에 응답하는 능력을 저해하지 않으면서 LLM을 보호하여 기업 생산성 향상의 원동력으로 계속 기능할 수 있도록 합니다.
탈옥 작동 방식
공격자는 탈옥 메시지를 조작하여 LLM을 조작하여 개인 식별 정보와 같은 민감한 정보를 노출하거나, 불법 행위(예: 폭탄 제조, 피싱 이메일 작성) 또는 증오 표현과 같은 유해한 콘텐츠를 생성합니다. 공격자는 다음과 같은 다양하고 창의적인 기법을 사용합니다.
- 롤 플레이: 민감하거나 보호된 정보를 공개하는 데 대한 기존 가드레일을 우회하기 위해 AI에게 특정 역할이나 페르소나를 수행하도록 요청하는 것입니다.
- 주의 전환: AI의 안전 프로토콜을 우회하기 위해 AI의 주의를 분산시키는 행위.
- 권한 확대: AI 시스템 내에서 더 높은 수준의 액세스 권한을 얻는 것입니다.
- 접두사 삽입: AI의 응답을 조작하기 위해 특정 구문을 추가합니다.
- 거부 억제: AI가 거부 프로토콜을 무시하도록 속이는 것입니다.
- 단어 게임과 난독화: 복잡한 언어를 사용하여 AI를 혼란스럽게 함.
- 다국어 입력 및 암호: 보안을 우회하기 위해 다양한 언어나 암호화된 메시지를 사용합니다.
이러한 기법은 얼마나 효과적일까요? 연구에 따르면 탈옥 프롬프트는 Vicuna, ChatGLM3, GPT-3.5, PaLM2를 포함한 다양한 LLM에서 지속적으로 높은 공격 성공률을 보이며 , 이는 안전 조치에도 불구하고 그 견고성과 전이성을 강조합니다. 또한, 자동화된 트리 오브 어택스 프루닝 (TAP) 기법은 단 몇 번의 쿼리만으로 80% 이상의 성숙 LLM 프롬프트를 성공적으로 탈옥할 수 있습니다.
탈옥이 왜 그렇게 효과적일까요? 이는 LLM 내부의 상충되는 목표와 관련이 있습니다. 한편으로는 모델이 지침을 준수하여 도움을 주는 것을 목표로 하지만, 다른 한편으로는 피해를 입히지 않기 위해 안전 지침을 준수해야 합니다. 다른 경우에는 일반화의 불일치 때문일 수 있습니다. 즉, 안전 훈련 데이터의 양이 전체 훈련 데이터를 완전히 대표하지 못하여 일부 공격 시나리오가 누락되는 것입니다. 오늘날 우리는 새로운 탈옥 공격이 등장하고, 끝없는 고양이와 쥐의 게임에서 새로운 방어책이 개발되는 악순환을 목격하고 있습니다.
정부를 위한 위험 시나리오
LLM에 대한 탈옥 공격은 연방 기관에 심각한 위험을 초래합니다. 국가 안보와 관련된 위험에는 데이터 유출, 개인정보 보호 침해, 허위 정보 확산, 자동화 시스템 조작, 그리고 의사 결정 프로세스 침해 등이 있습니다.
탈옥된 LLM이 대피 절차에 대한 허위 정보를 메시지에 입력하여 혼란을 야기하고 생명을 위협하는 국가 비상 상황을 상상해 보세요. 또는 공격자가 탈옥된 LLM을 사용하여 감시 제어 및 데이터 수집 시스템에 악성 명령을 주입하여 대도시에 정전을 유발하는 상황을 상상해 보세요.
탈옥된 LLM은 윤리적, 법적 문제를 야기할 수도 있습니다. 손상된 모델은 불법적인 콘텐츠를 생성하여 기관이 규제 처벌을 받을 수 있습니다. 또한 탈옥된 LLM이 차별적이거나 불쾌감을 주는 콘텐츠를 생성하여 공식 보고서에 포함되면 해당 기관은 평판이 손상되고 소송에 직면할 수 있습니다.
공격 유형
최근의 발전으로 입력 텍스트의 일부를 수정하여 더욱 강력한 탈옥 프롬프트가 가능해졌습니다. 보안 전문가들은 이 과정을 “섭동(perturbation)”이라고 부릅니다. 생성 AI 외에도 연구자들은 이러한 변화가 감정 분석 및 유해성 탐지와 같은 텍스트 분류 문제에 어떤 영향을 미치는지 연구해 왔습니다. 유해한 입력 및 출력 탐지는 매우 중요하므로, 생성 탈옥 프롬프트와 함께 사용되는 적대적 분류 공격을 고려하는 것이 중요합니다. 섭동 기반 공격의 예는 다음과 같습니다.
- 문자 수준 교란(CLP): 공격자는 프롬프트 문자를 무작위로 교체, 삽입 또는 삭제하여 중요 단어를 표적으로 삼아 매핑을 변경합니다. 이렇게 하면 모델이 유해한 프롬프트를 감지하는 데 사용하는 정보가 제거됩니다. CLP는 오타로 오인될 수도 있고, 사실상 눈에 띄지 않을 수도 있습니다(예: 동형이의어).
- 단어 수준의 교란(WLP): 공격자는 중요한 단어를 동의어나 어휘에 없는 단어로 대체하여 모델의 동작을 크게 변경합니다.
- 문장 수준 교란(SLP): 공격자는 프롬프트의 원래 의미는 유지하되 모델을 혼란스럽게 하기 위해 프롬프트를 바꿔 표현하거나 변경합니다. 관련 없는 문장을 추가하거나 한 언어에서 다른 언어로, 그리고 그 반대로 “왕복” 번역을 사용하는 것이 일반적인 방법입니다.
- 탐욕적 좌표 기울기(GCG) 공격: GCG 공격은 모델의 안전 기능을 우회하는 데 도움이 되는 접미사(겉보기에 무작위적인 문자와 단어의 문자열)를 생성하여 유해한 프롬프트가 타겟으로 하는 긍정적 응답을 생성할 가능성을 극대화합니다.
탈옥에 대한 방어책
탈옥을 평가하는 것은 매우 어렵고, 어떤 시스템에서든 오류(거짓 양성 및 거짓 음성)는 발생할 수 있습니다. 보조 모델 사용과 같은 대안적인 방법은 문자열 매칭에 비해 거짓 양성 및 거짓 음성률을 낮출 수 있지만, 모델이 프롬프트를 이해하지 못하거나 부분적 거부/준수를 반환하는 샘플을 분류하는 것에 대한 의문은 여전히 남아 있습니다. “부분 거부”와 “부분적 준수”라는 용어조차도 연구자들 사이에서 출력이 유해해지는 시점에 대한 의견 차이가 있을 수 있기 때문에 논란의 여지가 있습니다.
탈옥 공격에 대한 강력한 방어 체계를 구축하는 것 또한 다양한 모델과 공격 유형으로 인해 어려운 것으로 나타났습니다. 현재 많은 방어 체계가 특정 유형의 탈옥을 표적으로 삼고 있으며, 공격과 유사한 교란 전략을 사용하는 경우가 많습니다. 일부 방어 체계는 탈옥 프롬프트의 영향을 줄이기 위해 WLP(Walk-Loop)와 SLP(Single-Loop)를 사용합니다. 또 다른 접근법은 CLP를 사용하여 적대적 접미사의 문자를 무작위로 변경함으로써 GCG 접미사의 영향을 최소화합니다.
그러나 이 방법은 원래 프롬프트와 접미사를 자동으로 구분하는 데 어려움을 겪습니다. 예를 들어 SmoothLLM 알고리즘은 접미사만 분리하는 대신 접미사를 포함한 전체 입력의 일정 비율을 교란합니다. 탈옥 프롬프트에는 효과적이지만, 이 방법은 원래 프롬프트를 충분히 변경하여 양성 프롬프트의 이해 또는 가독성 문제를 유발할 수 있습니다.
대안을 살펴보다
부즈 앨런은 적대적 접미사를 포함한 일부 탈옥 공격을 차단하면서 원래 프롬프트의 의미를 보존하는 새로운 접근법을 모색하고 있습니다. 이를 위해 프롬프트에서 의미가 덜한 문자(구두점 포함, 공백 제외)를 제거합니다.
이 방법이 효과적인 이유는 무엇일까요? 탈옥 프롬프트에는 키릴 문자, 이모티콘, 보이지 않는 문자, ASCII 코드, 코드 구문, 그리고 기타 흔하지 않은 문자가 포함되는 경우가 많다는 점을 고려하세요. 이러한 문자들을 제거함으로써 이 방법은 공격의 효과를 감소시킵니다. 특히, 무작위 문자와 문자열로 구성된 GCG 접미사는 이러한 문자들을 제거하면 효과가 떨어집니다.
SmoothLLM과 달리, 이 방식은 원래 프롬프트를 대부분 그대로 유지하고 구두점만 제거하므로 LLM의 이해 및 적절한 응답 능력을 저해하지 않습니다. 이러한 기능은 LLM을 미션 애플리케이션에 사용하는 데 차질이 발생하는 것을 방지하는 데 도움이 됩니다.
탈옥이 어떻게 변화하고 있는가
단기적으로 LLM에 대한 탈옥 공격은 더욱 정교해질 것이며, 공격자는 토큰 조작 및 적대적 프롬프트 엔지니어링을 통해 보안 메커니즘을 우회할 가능성이 있습니다. 적대적 입력을 생성하는 자동화된 도구가 급증하여 경험이 부족한 공격자도 효과적인 탈옥을 구축할 수 있습니다. 또한 LLM 아키텍처 또는 데이터 세트 내의 특정 취약점을 악용하는 표적 공격 또한 증가할 수 있습니다.
장기적으로는 머신러닝을 활용하여 실시간으로 공격을 정교화하는 과정에서 마주치는 방어 체계에 대응하여 적응형 공격이 더욱 증가할 수 있습니다. 딥페이크 및 소셜 엔지니어링과 같은 기술이 발전함에 따라, 성공적인 탈옥 유도는 더욱 유해한 결과를 초래할 수 있습니다. 또한, LLM이 중요 시스템에 필수적이 됨에 따라 규제 환경이 변화하여 이러한 변화에 기반한 새로운 형태의 공격이 발생할 가능성이 있습니다.
방어력 통합, 공격자 물리치기
탈옥 공격의 진화는 LLM 및 지원 시스템의 무결성을 보호하기 위한 혁신적인 보안 조치의 필요성을 강조합니다. 개별적인 도구만으로 특정 취약점을 완화할 수는 있지만, 다면적인 위협을 반드시 해결하는 것은 아닙니다. 따라서 기관은 포괄적이고 통합된 보안 전략을 채택해야 합니다.
예를 들어, 다중 인증(MFA)과 같은 접근 제어를 구현하면 권한이 있는 직원만 LLM과 상호 작용하도록 할 수 있습니다. 암호화 기술은 액세스 토큰과 자격 증명을 더욱 안전하게 보호할 수 있습니다. 머신 러닝을 사용하는 이상 탐지 시스템은 LLM 상호 작용을 모니터링하고 탈옥 패턴을 실시간으로 식별할 수 있습니다. 또한 차등 개인정보 보호 기술은 데이터 출력에 통제된 노이즈를 추가하여 응답에 영향을 주지 않고 민감한 정보를 보호할 수 있습니다.
계층적 접근 방식은 하나의 방어 메커니즘이 실패하더라도 다른 방어 메커니즘이 시스템을 보호하기 위해 유지되도록 보장합니다. 개별적인 방어 체계를 넘어 통합 전략으로 전환하면 기관들이 강력한 탈옥 공격을 포함한 변화하는 사이버 위협으로부터 LLM을 더욱 효과적으로 보호하는 동시에, 이러한 모델을 중요한 임무의 일부로 계속 활용할 수 있습니다.
How to Protect LLMs from Jailbreaking Attacks
By Noah Fleischmann, Amy Wagoner, Ph.D., and Andre Nguyen, Ph.D.

Booz Allen examines how to strengthen model integrity
Federal agencies are increasingly integrating large language models (LLMs) like Llama-2 and ChatGPT into their operations to streamline tasks and answer questions. Engineers design these models to be “helpful and harmless” and refuse dangerous requests. Techniques like fine-tuning, reinforcement learning with human feedback, and direct preference optimization can further enhance model safety. But despite these measures, a critical LLM vulnerability continues to put AI systems at risk: jailbreak prompts.
Jailbreak prompts are specific inputs designed to trick LLMs into doing things they shouldn’t. These cleverly designed but malicious prompts can bypass even the most robust security measures, posing significant risks to federal operations.
To help address this challenge, Booz Allen is exploring new defenses against jailbreaking. These approaches can provide agencies with a significant mission advantage: they protect the LLM without hindering its ability to respond to benign prompts so that it can continue functioning as a driver of increased enterprise productivity.
How Jailbreaking Works
Adversaries craft jailbreak prompts to manipulate LLMs into revealing sensitive information, such as personally identifiable information, or generating harmful content, such as instructions for illegal activities (e.g., building a bomb, writing a phishing e-mail) or hate speech. Attackers employ a variety of creative techniques, including:
- Role Play: Asking the AI to play a specific role or persona to bypass existing guardrails for divulging sensitive or protected information.
- Attention Shifting: Distracting the AI to bypass its safety protocols.
- Privilege Escalation: Gaining higher-level access within the AI’s system.
- Prefix Injection: Adding specific phrases to manipulate the AI’s responses.
- Refusal Suppression: Tricking the AI into ignoring its refusal protocols.
- Word Games and Obfuscation: Using complex language to confuse the AI.
- Multilingual Input and Ciphers: Using different languages or coded messages to bypass security.
How effective are these techniques? Research shows jailbreak prompts consistently achieve high attack success rates across various LLMs, including Vicuna, ChatGLM3, GPT-3.5, and PaLM2, underscoring their robustness and transferability despite safety measures. In addition, the automated tree of attacks with pruning (TAP) technique can provide prompts that successfully jailbreak mature LLMs for over 80% of prompts with just a few queries.
Why does jailbreaking work so well? It has to do with conflicting goals within LLMs. On the one hand, the models aim to be helpful by following instructions, but on the other, they need to adhere to safety guidelines to avoid causing harm. In other cases, it may be due to mismatched generalization. That is, the quantity of safety training data cannot fully represent the body of training data, which causes some attack scenarios to be missed. Today, we see a cycle where new jailbreak attacks emerge, prompting the development of new defenses in a never-ending game of cat and mouse.
Risk Scenarios for Government
Jailbreaking attacks on LLMs pose significant risks to federal agencies. Risks with relevance for national security include data breaches, privacy violations, spread of misinformation, manipulation of automated systems, and compromised decision-making processes.
Imagine a national emergency where a jailbroken LLM responds to prompts with false information about evacuation procedures, causing chaos and endangering lives. Or an attacker uses a jailbroken LLM to trigger a power outage in a major city by injecting malicious commands into a supervisory control and data acquisition system.
Jailbroken LLMs may also bring ethical and legal challenges. Compromised models could generate illegal content, exposing agencies to regulatory penalties. And if a jailbroken LLM produces discriminatory or offensive content that finds its way into an official report, the agency could suffer reputational damage and face lawsuits.
Attack Types
Recent advances have enabled more powerful jailbreak prompts by modifying parts of the input text. Security practitioners call this process “perturbation.” Outside of generative AI, researchers have studied how these changes affect text classification problems, like sentiment analysis and toxicity detection. Since detecting harmful inputs and outputs is crucial, it’s important to consider adversarial classification attacks used alongside generative jailbreak prompts. Examples of perturbation-based attacks include:
- Character-level perturbations (CLPs): Attackers randomly swap, insert, or delete prompt characters, targeting important words to change their mapping. This removes information the model uses to detect harmful prompts. CLPs may be mistaken for typographical errors or may be virtually invisible (e.g., homoglyphs).
- Word-level perturbations (WLPs): Attackers substitute important words with synonyms or out-of-vocabulary words to significantly change the model’s behavior.
- Sentence-level perturbations (SLPs): Attackers rephrase or change the prompt to keep its original meaning but confuse the model. Adding irrelevant sentences or using “roundtrip” translations from one language to another and back are common methods.
- Greedy coordinate gradient (GCG) attacks: GCG attacks maximize the chances that a harmful prompt will produce a targeted affirmative response through the creation of suffixes—strings of seemingly random characters and words—that help bypass the model’s safety features.
Defenses Against Jailbreaking
Evaluating jailbreaks is very difficult, and mistakes (false positives and false negatives) will happen with any system. While alternative methods, such as using auxiliary models, may decrease the false positive and false negative rate compared to string matching, questions still arise about categorizing samples where the model does not understand the prompt or returns a partial refusal/compliance. Even the terms “partial refusal” and “partial compliance” can be controversial because researchers might disagree on when an output becomes harmful.
Developing a strong defense against jailbreak attacks has also proven challenging due to the variety of models and attack types. Many current defenses target specific types of jailbreaks and often use similar perturbation strategies as the attacks. Some defenses use WLPs and SLPs to reduce the impact of jailbreak prompts. Another approach uses CLPs to minimize the effect of GCG suffixes by randomly changing characters in the adversarial suffix.
However, this method struggles to automatically distinguish between the original prompt and the suffix. The SmoothLLM algorithm, for example, perturbs a percentage of the entire input, including the suffix, rather than isolating the suffix alone. While effective against jailbreak prompts, this approach can alter the original prompt enough to cause comprehension or readability issues for benign prompts.
Looking at Alternatives
Booz Allen is exploring new approaches that preserve the original prompt’s meaning while thwarting some jailbreak attacks, including adversarial suffixes. They do this by removing less meaningful characters (including punctuation, but not spaces) from the prompt.
Why is this effective? Consider that jailbreak prompts often include Cyrillic characters, emojis, invisible characters, ASCII art, code syntax, and other uncommon characters. By eliminating these, this approach reduces the effectiveness of the attack. Specifically, GCG suffixes, which consist of random characters and strings, become less effective when these characters are removed.
Unlike SmoothLLM, this approach leaves the original prompt mostly intact, removing only punctuation, which does not hinder the LLM’s ability to comprehend and respond appropriately. This capability helps prevent disruptions in the use of LLMs for mission applications.
How Jailbreaks Are Changing
In the near term, jailbreaking attacks on LLMs will become more sophisticated, with adversaries potentially bypassing safety mechanisms through token manipulation and adversarial prompt engineering. Automated tools for generating adversarial inputs may proliferate, allowing inexperienced attackers to craft effective jailbreaks. And targeted attacks exploiting specific vulnerabilities within LLM architectures or datasets may also increase.
Over the long term, adaptive attacks could further increase in response to encountered defenses, with machine learning used to refine attacks in real time. With improving technologies like deepfakes and social engineering, successful jailbreak prompts might lead to more harmful outputs. In addition, as LLMs become integral to critical systems, the regulatory landscape could shift, potentially giving rise to new forms of attacks based on these changes.
Integrating Defenses, Defeating Attackers
The evolution in jailbreak attacks underscores the need for innovative security measures to safeguard the integrity of LLMs and supported systems. While isolated tools can mitigate specific vulnerabilities, they don’t necessarily address multifaceted threats. As a result, agencies should adopt a comprehensive, integrated security strategy.
For example, implementing access controls like multifactor authentication can help ensure that only authorized personnel interact with LLMs. Cryptographic techniques can further secure access tokens and credentials. Anomaly detection systems that use machine learning can monitor LLM interactions and identify jailbreak patterns in real time. And differential privacy techniques can add controlled noise to data outputs, protecting sensitive information without affecting responses.
A layered approach ensures that, even if one defense mechanism fails, others remain in place to protect the system. Moving beyond isolated defenses to an integrated strategy can help agencies more effectively safeguard LLMs against shifting cyber threats, including potent jailbreaking attacks, while continuing to harness these models as part of critical missions.
[출처] https://www.boozallen.com/insights/ai-research/how-to-protect-llms-from-jailbreaking-attacks.html
![]()




