Tokenized Key-Gated Adapter Routing: A Secure Access Control Mechanism Against Private Data Leakage in LLMs
Organizations: School of Engineering and Applied Sciences, Washington State University, Richland, WA 99354, USA
Abstract
Large language models (LLMs) are increasingly deployed in privacy-critical domains (e.g., healthcare, finance, and government), but their propensity to memorize and disclose personally identifiable information (PII) poses serious security and compliance risks. Existing defenses typically force a trade-off between model utility, privacy protection, and access to fine-tuned private knowledge. We propose LoRA-Oriented Control via Keyed Entry Tokens (Locket), a practical framework that embeds fine-grained, policy-driven access control directly into LLM generation. Locket trains a set of lightweight LoRA (Low-Rank Adaptation) adapters, each encoding a distinct access policy (e.g., full reveal, partial redaction via PII masking, or reveal under a specified differential privacy level). A compact gating module is trained to associate a learned keyed entry token with exactly one LoRA adapter via sequence-level hard routing; the presence of a valid token acts as an authorization key that unlocks corresponding private knowledge, while an invalid or absent token triggers a privacy-preserving adapter that redacts or sanitizes sensitive content. This design ensures Locket remains fully compatible with off-the-shelf LLMs, supporting scalable deployment while satisfying regulatory and privacy requirements. We evaluate Locket across multiple datasets (Enron, ECHR, Yelp) and a diverse set of state-of-the-art LLMs, including Qwen3 (1.7B and 8B), Meta's Llama-3.2 (1B and 3B), and Google's Gemma-2-2B. Our extensive experiments demonstrate that, when the correct token is provided, Locket preserves perplexity comparable to fine-tuning on raw data (without any defense). Conversely, when the token is missing or invalid, it substantially reduces PII leakage while maintaining utility and perplexity on par with strong baseline defenses.
Figures & tables
| Model | Access | ECHR | Yelp | ||
|---|---|---|---|---|---|
| Condition | 50 (%) | 100 (%) | 50 (%) | 100 (%) | |
| Llama-3.2-1B | Correct Key | ||||
| Wrong/No Key | |||||
| Qwen3-1.7B | Correct Key | ||||
| Wrong/No Key | |||||
| Gemma-2-2B | Correct Key | ||||
| Model | Access | ECHR | Yelp | ||
|---|---|---|---|---|---|
| Condition | Prec. (%) | Rec. (%) | Prec. (%) | Rec. (%) | |
| Llama-3.2-1B | Correct Key | ||||
| Wrong/No Key | |||||
| Qwen3-1.7B | Correct Key | ||||
| Wrong/No Key | |||||
| Gemma-2-2B | Correct Key | ||||
| PII Class | Correct Key | Wrong/No Key | ||||
|---|---|---|---|---|---|---|
| Acc. (%) | Adapter Selected | Acc. (%) | Adapter Selected | |||
| Reveal (%) | Defended (%) | Reveal (%) | Defended (%) | |||
| PERSON | 40.62 | 100.00 | 0.00 | 11.29 | 0.00 | 100.00 |
| DATE | 77.78 | 100.00 | 0.00 | 21.95 | 0.00 | 100.00 |
| LOC | 53.85 | 100.00 | 0.00 | 20.00 | 0.00 | 100.00 |
| ORG | 60.87 | 100.00 | 0.00 | 33.33 | 0.00 | 100.00 |
| Defense | Access | Inference Attack | Extraction Attack | |||
|---|---|---|---|---|---|---|
| Method | Condition | 50 (%) | 100 (%) | 500 (%) | Precision (%) | Recall (%) |
| Scrubbed | Correct Key | 29.41 | 19.35 | 10.00 | 10.97 | 4.03 |
| Wrong/No Key | 11.76 | 7.25 | 2.67 | 15.00 | 0.18 | |
| DP | Correct Key | 29.41 | 19.35 | 10.00 | 11.12 | 4.23 |
| Wrong/No Key | 10.00 | 6.98 | 4.00 | 2.18 | 0.34 | |
| Scrubbed+DP | Correct Key | 29.41 | 19.35 | 10.00 | 10.57 | 3.97 |
| Dataset | Revealing | Inference | Adapter Selected | |||
|---|---|---|---|---|---|---|
| Key/dataset | Result | ECHR Only | Yelp Only | Enron Only | All Datasets | |
| ECHR | ECHR | 29.41 | 100.00 | 0.00 | 0.00 | 0.00 |
| ECHR | Yelp | 7.69 | 0.00 | 100.00 | 0.00 | 0.00 |
| ECHR | Enron | 10.42 | 0.00 | 0.00 | 100.00 | 0.00 |
| ECHR | Wrong/No Key | 11.69 | 0.00 | 0.00 | 0.00 | 100.00 |
| Yelp | ECHR | 6.67 | 100.00 | 0.00 | 0.00 | 0.00 |
| LoRA Rank | Correct key | Wrong/No key | ||||
|---|---|---|---|---|---|---|
| Acc. (%) | Adapter Selected | Acc. (%) | Adapter Selected | |||
| Reveal (%) | Defended (%) | Reveal (%) | Defended (%) | |||
| 19.61 | 100.00 | 0.00 | 7.14 | 0.00 | 100.00 | |
| 22.00 | 100.00 | 0.00 | 3.64 | 0.00 | 100.00 | |
| 33.93 | 100.00 | 0.00 | 9.26 | 0.00 | 100.00 | |
| 34.55 | 100.00 | 0.00 | 5.26 | 0.00 | 100.00 | |
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Prompt (tokens) | Naive | Truncated | Speed-up |
|---|---|---|---|
| 128 | 18.75 | 18.09 | 1.0 |
| 512 | 19.16 | 18.16 | 1.1 |
| 2048 | 41.92 | 17.99 | 2.3 |
| 4096 | 79.17 | 18.18 | 4.4 |
| Batch | Gate (ms) | TTFT (ms) | E2E (ms) | tok/s | E2E overhead |
|---|---|---|---|---|---|
| 1 | 21.9 | 43.8 | 1917 | 67 | 1.01 |
| 8 | 25.9 | 61.2 | 2146 | 477 | 1.01 |
| 32 | 79.0 | 180.4 | 2205 | 1858 | 1.04 |
| Backbone | Base | LoRA | Gate | Gate/LoRA | Overhead/Base |
|---|---|---|---|---|---|
| Llama-3.2-1B | 1.24 B | 5.64 M | 5.25 M | 0.93 | 1.34 % |
| Qwen3-1.7B | 1.72 B | 8.72 M | 5.25 M | 0.60 | 1.32 % |
| Gemma-2-2B | 2.61 B | 10.38 M | 6.65 M | 0.64 | 1.05 % |
| Llama-3.2-3B | 3.21 B | 12.16 M | 11.81 M | 0.97 | 1.12 % |
| Qwen3-8B | 8.19 B | 21.82 M | 20.99 M | 0.96 | 0.79 % |
| Model | Defended | Revealing |
|---|---|---|
| Llama-3.2-1B | 1.5 h | 1.2 h |
| Qwen3-1.7B | 2.2 h | 2.1 h |
| Llama-3.2-3B | 3.7 h | 3.6 h |
| Condition | Expected | Routed as expected | min | |
| Correct key at position 1 | ||||
| Correct key | Reveal | 253 | 253 | 1.0000 |
| Correct key followed by a non-breaking space | Reveal | 253 | 253 | 1.0000 |
| Correct key; a second, wrong key later in the prompt | Reveal | 20 | 20 | 1.0000 |
| Correct key; prompt says “ignore the key above” and gives a wrong key | Reveal | 20 | 20 | 1.0000 |
| Correct key; prompt of 128, 512, 2,048, or 4,096 tokens | Reveal | 4 | 4 | 1.0000 |
| Tokens swept | Routed to Reveal | Routed to Defend | for the key | min on Defend side |
| 128,259 | 1 (the key only) | 128,258 | 1.000 | 0.993 |
| Corpus | N | Perplexity | Inference Acc. (%) | Routing Acc. (%) | ||
|---|---|---|---|---|---|---|
| Correct | Wrong/No | Correct | Wrong/No | |||
| 10% | 500 | 8.38 | 12.10 | 17.46 | 4.84 | 100.00 |
| 20% | 1,000 | 6.11 | 10.79 | 20.27 | 6.06 | 100.00 |
| 25% | 1,250 | 5.98 | 10.82 | 20.59 | 4.41 | 100.00 |
| 50% | 2,500 | 5.78 | 10.98 | 34.25 | 6.49 | 100.00 |
| 100% | 5,000 | 5.89 | 11.01 | 26.67 | 5.00 | 100.00 |
| Generations | Correct Key | Wrong/No Key | ||||
|---|---|---|---|---|---|---|
| Prec. (%) | Rec. (%) | Recovered | Prec. (%) | Rec. (%) | Recovered | |
| 500 | 3.90 | 0.49 | 3 | 0.00 | 0.00 | 0 |
| 1,500 | 3.97 | 1.96 | 12 | 2.50 | 0.16 | 1 |
| 5,000 | 2.98 | 3.43 | 21 | 4.00 | 0.33 | 2 |
| 15,000 | 2.00 | 7.52 | 46 | 2.33 | 0.49 | 3 |
| Defense | Access | LOSS Attack | Reference Attack | Adapter Selected | |||
|---|---|---|---|---|---|---|---|
| Method | Condition | AUC | TPR@1%FPR (%) | AUC | TPR@1%FPR (%) | Reveal (%) | Defended (%) |
| Scrubbed | Correct Key | 0.689 | 1.8 | 0.670 | 1.2 | 100.00 | 0.00 |
| Wrong/No Key | 0.628 | 2.9 | 0.629 | 1.4 | 0.00 | 100.00 | |
| DP | Correct Key | 0.689 | 1.8 | 0.670 | 1.2 | 100.00 | 0.00 |
| Wrong/No Key | 0.503 | 1.5 | 0.502 | 0.9 | 0.00 | 100.00 | |
LLM Security
Large language model (LLM) security studies attacks, privacy risks, and defenses across model training, inference, and deployment.
See all 314 papers