Sanitize Your Responses: Mitigating Privacy Leakage in Large Language Models

Wenjie Fu, Huandong Wang, Junyao Gao, Guoan Wan, Tao Jiang · 2025

Read Sanitize Your Responses: Mitigating Privacy Leakage in Large Language Models by Wenjie Fu, Huandong Wang, Junyao Gao, Guoan Wan, Tao Jiang (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2509-24488.txt.

Introduction

Leaky or harmful replies can slip out of a language model mid-stream, and filters that check after the fact add delay and clash with live generation. Wenjie Fu and 4 co-authors built Self-Sanitize, a mitigation frame modeled on human self-monitoring and self-repair in conversation. A light monitor watches the model's high-level intentions at the token level through representation engineering.

A repair module then corrects harmful content in place, with no separate review dialogue. The team stresses privacy leakage, a scenario past work often slighted. Across four models and three leakage scenarios, Self-Sanitize mitigated better than rivals with minimal overhead and no loss of utility.

Catalog record

CREATORWenjie Fu, Huandong Wang, Junyao Gao, Guoan Wan, Tao Jiang
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE82 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2509-24488

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Sanitize Your Responses: Mitigating Privacy Leakage in Large Language Models Wenjie Fu, Huandong Wang, Junyao Gao, Guoan Wan, Tao Jiang Abstract As Large Language Models (LLMs) achieve remarkable success across a wide range of applications, such as chatbots and code copilots, concerns surrounding the generation of harmful content have come increasingly into focus. Despite significant advances in aligning LLMs with safety and ethical standards, adversarial prompts can still be crafted to elicit undesirable responses. Existing mitigation strategies are predominantly based on post-hoc filtering, which introduces substantial latency or computational overhead, and is incompatible with token-level streaming generation. In this work, we introduce Self-Sanitize, a novel LLM-driven mitigation framework inspired by cognitive psychology, which emulates human self-monitor and self-repair behaviors during conversations. Self-Sanitize comprises a lightweight Self-Monitor module that continuously inspects high-level intentions within the LLM at the token level via representation engineering, and a Self-Repair module that performs in-place correction of harmful content without initiating separate review dialogues. This design allows for real-time streaming monitoring and seamless repair, with negligible impact on latency and resource utilization. Given that privacy-invasive content has often been insufficiently focused in previous studies, we perform extensive experiments on four LLMs across three privacy leakage scenarios. The results demonstrate that Self-Sanitize achieves superior mitigation performance with minimal overhead and without degrading the utility of LLMs, offering a practical and robust solution for safer LLM deployments. Our code is available at the following link 1 1 1 https://github.com/wjfu99/LLM˙Self˙Sanitize 1 Introduction Large language models (LLMs) have been witnessed to have significant potential across a wide range of domains, including but not limited to chatbot assistance ( Kim et al. 2023 ) , code generation ( Ross et al. 2023 ) , and information retrieval ( Zhu et al. 2024b ) . Recent remarkable advancements in human feedback alignment have further enhanced the helpfulness of LLMs, enabling them to better understand user intentions and fulfill their requests ( Ouyang et al. 2022 ) . Despite these advancements and potentials, LLMs continue to face substantial challenges concerning safety and ethics, as they may fulfill not only benign but also harmful requests ( Weidinger et al. 2021 ) . When prompted with such harmful requests, LLMs are capable of generating toxic content ( Deshpande et al. 2023 ) , including bias, racism, unfairness, violence, and privacy. Although safety alignment techniques have been introduced to improve the ethical behavior of LLMs by encouraging them to reject harmful requests ( Dai et al. 2024 ) , adversarial attacks (e.g., jailbreaks and prompt injection) can still craft circumlocutory prompts to bypass these safety restrictions and force LLMs to produce undesirable or prohibited content ( Liu et al. 2024b ; Guo et al. 2024 ) . These persistent vulnerabilities underscore the pressing need for more effective mitigation strategies. Figure 1: The concepts of self-monitor and self-repair. The most straightforward method for harmful content mitigation is maintaining a content filtering system that works alongside LLMs to reject harmful user requests and LLM responses ( Azure 2025 ) . Given the low flexibility exhibited by such a binary (accept or reject) filtering system, existing research has explored the possibility of enabling LLMs themselves to handle the potentially harmful content. Pioneering studies collect a safety instruction-following dataset for fine-tuning (FT) LLMs to reject harmful requests ( Zong et al. 2024 ; Agarwal et al. 2024 ) . Subsequent works adopt more advanced fine-tuning techniques, such as reinforcement learning from human feedback (RLHF) ( Ouyang et al. 2022 ; Yuan et al. 2023 ) , to further align LLMs with safety intention ( Dai et al. 2024 ; Ji et al. 2024 ) . Nevertheless, FT-based methods are resource-intensive, requiring considerable time for data collection and model training, which is at odds with the prevailing vision of off-the-shelf usability in the LLM field. Consequently, recent instruction-based methods exploit the in-context learning (ICL) ability of LLMs to discourage harmful behavior by injecting safety instructions into system or user prompts ( Xie et al. 2023 ; Varshney et al. 2024 ) . Current advancements in LLM-based mitigation methods have further delved into the reflective and self-correcting capabilities of LLMs to detect and address subtler harmful content ( Wang et al. 2024 ; Phute et al. 2024 ; Brown et al. 2024 ) . LLM-based methods initiate a backend implicit dialogue alongside the primary conversation, in which the LLM is prompted to review both the prompt and its response for potentially harmful content, and is further instructed to rectify or erase such content if detected. Overall, these methods have achieved remarkable success in ensuring LLMs are harmless and safe. However, several persistent challenges continue to hinder the practical deployment of prior mitigation methods in production environments. Firstly, previous detection and mitigation methods typically fall into the post-processing paradigm, which will not execute until the LLM response is completely generated ( Azure 2025 ; Phute et al. 2024 ) . This intuitively seems promising and ensures that the entire response output to the user is thoroughly checked and amended. Nevertheless, this post-processing approach introduces noticeable latency on the user side, which consists of the time taken to generate the complete response and the time required for the LLM to handle harmful content ( Wang et al. 2024 ) . Moreover, streaming output, which allows tokens to be delivered to users in real time as they are generated, has become increasingly prevalent in LLM applications to minimize user-perceived delays ( Xiao et al. 2024 ) . Post-processing methods are inherently incompatible with streaming output, thereby further restricting their applicability in real-world scenarios ( Li et al. 2025 ) . Although some studies have attempted to mitigate post-processing latency by maintaining a shadow LLM to review user prompts in parallel ( Wang et al. 2024 ; Xu et al. 2024 ) , these approaches still fail to break away from the manner of drafting out an additional review or mitigation dialogue. Such strategies impose significant memory and computational overhead, but also presents challenges in extracting the refined response. Additionally, most existing research has primarily focused on filtering overtly toxic or offensive content, with considerably less attention devoted to the detection and prevention of privacy-invasive information disclosure ( Staab et al. 2023 ) . In this work, we propose a novel LLM-based method for harmful content mitigation, termed Self-Sanitize, to address the aforementioned challenges. As shown in Figure 1 , Self-Sanitize is inspired by the self-monitor and self-repair concepts from cognitive psychology ( Postma 2000 ) , enabling LLMs to mimic human behavior by continuously monitoring what they are saying, promptly interrupting and repairing errors as they occur ( Levelt 1983 ) . First, we propose a lightweight Self-Monitor module that leverages recent advances in representation engineering ( Zou et al. 2023 ; Zou et al. 2024 ; Snyder, Moisescu, and Zafar 2024 ) to track the higher-level awareness of LLMs within the representation space. Specifically, we maintain a tiny classifier that continuously monitors the intermediate representations yielded by the LLM as each token is generated. Unlike prior approaches that monitor in the textual space, our method imposes negligible computational overhead, thus supporting parallel operation with LLM inference and enabling token-level streaming monitoring. Second, drawing inspiration

Read the complete text