<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Singularity]]></title><description><![CDATA[Singularity]]></description><link>https://blog.sevnlabs.space</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1761613779156/c93b4e9b-28e3-4928-934c-4d54d263ffa2.png</url><title>Singularity</title><link>https://blog.sevnlabs.space</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 04:06:27 GMT</lastBuildDate><atom:link href="https://blog.sevnlabs.space/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[When Encryption Isn’t Enough: Token-Length Side Channel Attacks For AI Assistants]]></title><description><![CDATA[You’ve probably seen clips of the long-running TV show, Wheel of Fortune at least once on social media. (Just like the famous meme above. Can you guess the song?) Contestants stare at a board full of blank spaces, waiting for a lucky spin to reveal a...]]></description><link>https://blog.sevnlabs.space/when-encryption-isnt-enough</link><guid isPermaLink="true">https://blog.sevnlabs.space/when-encryption-isnt-enough</guid><category><![CDATA[Security]]></category><category><![CDATA[llm]]></category><category><![CDATA[vulnerability]]></category><category><![CDATA[encryption]]></category><category><![CDATA[Side channel attacks]]></category><dc:creator><![CDATA[Singularity]]></dc:creator><pubDate>Tue, 28 Oct 2025 03:28:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/SYofhg_IX3A/upload/f215370e7d040ee4b0c413fdd0ae06b0.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><img src="https://i.imgur.com/g9xAAE7.jpeg" alt="“Wheel of Fortune — an instant cultural puzzle. Can you guess the phrase?”" /></p>
<p>You’ve probably seen clips of the long-running TV show, <em>Wheel of Fortune</em> at least once on social media. <em>(Just like the famous meme above. Can you guess the song?)</em> Contestants stare at a board full of blank spaces, waiting for a lucky spin to reveal a single letter. At first, it looks simple. Once a few letters appear, the answer often clicks into place. <strong>But when there are no letters at all, only the number of words and how long each one is, guessing the full phrase becomes almost impossible</strong>. Unless it’s something everyone knows, like a famous song lyric, you’re basically guessing in the dark due to the <strong>infinite redundancy of the human language</strong>.</p>
<p>Now imagine AI trying to solve that kind of puzzle. And not as a game, but <strong>as a way to uncover parts of encrypted conversations between you and an AI assistant</strong> like ChatGPT, Gemini, or Claude. That probably sounds far-fetched, but a group of researchers recently showed that it can be done. In a paper published at the USENIX Security conference, one team demonstrated that i<strong>t’s possible to look at encrypted data (no text, no keys) and still infer what the conversation was about, just by examining the size of the packets being sent</strong>.</p>
<p>In this post, I’ll explain what the researchers found, why and how the attack works, and what this means for anyone who is either a developer actively engaging in the development of AI models, or a daily AI user, especially in an rapid era where LLMs are being part of our everyday lives.</p>
<h2 id="heading-encryption-hides-words-not-their-shape"><strong>Encryption hides words, not their shape</strong></h2>
<p>When you chat with an AI assistant, your messages are <strong>indeed encrypted using strong cryptographic algorithms</strong>. That means no one watching the network can see the actual words you're sending or receiving. On the surface, this sounds completely secure. But encryption doesn't hide everything. Some clues still slip through, things like the timing of each message, or the size of the data being sent back and forth.</p>
<p>The most important thing to remember is that most AI Models do not reply in full answers at once. Rather, it creates the context <strong>piece by piece, token by token</strong>. A token refers to a small chunk of text, usually a few characters. When the model sends a new token, an encrypted packet arrives in your browser or app. Even though <strong>we can’t see what those packets contain, we can see how big they are</strong>.</p>
<p>When you arrange the packet sizes, it shows <strong>a pattern or a sequence of numbers which shows the length of every token in the AI’s response</strong>. It's like seeing the masked version of a sentence without any of the words filled in, just like the TV show game mentioned earlier.</p>
<p>That’s the insight the researchers built on. They figured out that <strong>these "token-length" patterns mirror the actual wording of the document</strong>. After research and trial, they figured out it is possible to reverse engineer parts of what they’re saying, even if the messages are encrypted, <strong>without actually decrypting the original message with the correct key</strong>. And to make this easier, instead of playing their own game of Wheel of Fortune, they created an AI model that is specifically trained to do the job for you.</p>
<h2 id="heading-the-attack-pipeline"><strong>The attack pipeline</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1761620762311/777d9286-d65a-46a0-8e07-b99a1e181610.png" alt class="image--center mx-auto" /></p>
<p>Here’s how the researchers broke down their method:</p>
<ol>
<li><p><strong>Capture the traffic</strong></p>
<p> Researchers captured encrypted data from AI helpers, like ChatGPT and Copilot. The packets’ sizes and order were visible, but their contents were not.</p>
</li>
<li><p><strong>Find message boundaries</strong></p>
<p> They identified where each response began and ended. Since most AI models stream their answers in small chunks, each chunk corresponded roughly to a piece of generated text.</p>
</li>
<li><p><strong>Extract token lengths</strong></p>
<p> They measured how much the packet size changed each time. The difference showed how many characters were in each new token. Together, these differences formed a numeric sequence shaped like the AI's sentence rhythm.</p>
</li>
<li><p><strong>Split into segments</strong></p>
<p> They broke that sentence down into smaller sentences. The pattern has short spikes that correspond to punctuation marks for instance.</p>
</li>
<li><p><strong>Reconstruct the text</strong></p>
<p> In the end, the final length sequence was fed into a model that tried to translate the length sequence into natural language. The model made many possible sentences and picked its best fitting one.</p>
</li>
</ol>
<h2 id="heading-how-it-works"><strong>How it works</strong></h2>
<p><em>So how does the trained AI model actually guess what the AI assistant said?</em></p>
<p>The researchers built their <strong>own AI (LLM)</strong> and trained it to read these token-length patterns as if they were a new language.  Each token length became a special symbol. For instance, “_5” for a five-character token, and “_2” for a two-character one. The model learned to associate sequences with likely words and phrases through internalized statistics of how language behaves.</p>
<p>Two transformer models were trained based on T5 architecture from Google.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1761621853397/57f12a55-93d0-460a-b5e7-96333ef6b3d5.png" alt class="image--center mx-auto" /></p>
<p>The initial model, <strong>LLM-A</strong>, targeted the opening line because first sentences often characterize a specific topic.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1761621871160/1b9c0c10-053e-4871-8506-b9e88c57ab7f.png" alt class="image--center mx-auto" /></p>
<p>The second model <strong>LLM-B</strong> guessed the next sentences below, using the context provided, making sure the following sentences are coherent and natural.</p>
<p>To train them, the researchers used the UltraChat dataset, which contains 1.5 million GPT-4 Turbo conversations. Every response from the assistant was <strong>tokenized</strong> and every token was replaced with its character length to make <strong>training pairs of a numeric pattern and original text</strong>. The models were self-supervised with noise addition with the idea to mimic real network artifacts like batching tokens and streaming preambles. They learned how AI assistants “sound” through tone, phrasing, and structure. Eventually, they were able to translate vague numeric patterns into very useful guesses about what the assistant actually said.</p>
<h2 id="heading-boosting-the-accuracy"><strong>Boosting the Accuracy</strong></h2>
<p>To boost the accuracy of the model’s predictions, the research team focused on an important, but rather classic idea.</p>
<p>Language isn’t random. Assistants make use of familiar wording, predictable sentence structures, and repeating templates. Due to this predictability, only a limited number of sentences are likely to fit any specific length pattern.e.</p>
<p>For example, ChatGPT often starts with <em>“Certainly!”</em> or <em>“Here’s how…”</em>. When the model identifies a similar pattern of tokens, <strong>it could make a confident guess</strong> that those words were there.</p>
<p><img src="https://www.indiewire.com/wp-content/uploads/2015/02/the-imitation-game-1.jpeg?w=600&amp;h=337&amp;crop=1" alt="How They Did It: Breaking the Enigma Code in 'The Imitation Game' (Video)" class="image--center mx-auto" /></p>
<p>As I read this, it reminded me of the famous story of <strong>Alan Turing</strong> and the team at Bletchley Park trying to decrypt Germany’s ‘unbreakable’ code system, <strong>Enigma</strong>. The key to breaking the code wasn't brute force (which was technically impossible), but rather <strong>noticing certain patterns or relying on common or familiar phrases</strong>. One such phrase was weather reports or the everyday “Heil Hitler,” a phrase that made an appearance in many communications.</p>
<p>What the researchers did here isn’t far off in spirit. The tools differ, but the logic is the same: language always leaves its mark, even in code.</p>
<h2 id="heading-how-accurate-is-it"><strong>How accurate is it?</strong></h2>
<p><em>The paper reports strong empirical performance.</em></p>
<ol>
<li><p>The cosine similarity (φ) of first sentences to actual topic is more than 0.5 for ≈ 52.7 % of first sentences.</p>
</li>
<li><p>Near-exact phrasing was achieved for nearly a quarter of the output (higher φ).</p>
</li>
<li><p>Full-response inference works about 38% of the time on traffic from the ChatGPT-4 browser and about 17% of the time on traffic from API streams where the tokens are paired.</p>
</li>
<li><p>Training on general text instead of assistant outputs dropped performance to <strong>~5 %</strong>, confirming the benefit of targeted tuning.</p>
</li>
<li><p>A model trained on GPT-4 data also performed well on Microsoft Copilot traffic, suggesting stylistic similarity.</p>
</li>
</ol>
<p>These numbers show that, while not perfect, the attack reliably reveals topics and often recovers phraseology which <strong>sufficient enough to constitute meaningful privacy exposure</strong>.</p>
<h2 id="heading-can-it-be-fixed"><strong>Can it be fixed?</strong></h2>
<p>The short answer is <strong>yes</strong>, but <strong>at a cost</strong>.</p>
<p>The researchers suggest three main defenses:</p>
<ol>
<li><p><strong>Add random padding.</strong> Adjust the size of every packet in a subtle manner to hide the real token length.</p>
</li>
<li><p><strong>Batch tokens.</strong> Instead of streaming tokens one by one, send them in batches.</p>
</li>
<li><p><strong>Send the full response.</strong> Do not send anything until the entire output is generated.</p>
</li>
</ol>
<p>The three measures will make the attacks harder, but they will also slow down the experience or will be more bandwidth heavy. It’s a <strong>trade-off between performance and privacy</strong>.</p>
<p>Also, <strong>major LLM providers have already responded</strong>. The writers and researchers of the paper responsibly disclosed their findings and within weeks the companies including the big ones rolled out patches to address this vulnerability. In other words, the attack demonstrated in this paper is <strong>no longer available in recent versions of these LLMs</strong>.</p>
<h2 id="heading-what-this-tells-us"><strong>What this tells us</strong></h2>
<p>What’s fascinating here is <strong>encryption alone doesn’t guarantee privacy</strong>. What's fascinating and a little unsettling at the same time is that even with all the complex encryption and security layers in place, data can still slip out through <strong>something as small and unexpected</strong> as packet length. It's impressive, almost absurd, that a system designed to be airtight can leak information from such an ordinary detail. It makes you realize how fragile "security" can be when the weakest point isn't the algorithm itself, but the <strong>invisible side effects</strong> of how we make technology smooth and human-friendly.</p>
<p>It also shows <strong>how powerful artificial intelligence is</strong>. The technology that we built to understand and generate language can be turned around to expose hidden patterns that we would miss otherwise. It’s a striking example of how AI is starting to work beyond human intuition. It also shows how adaptable this technology is. In this case, AI was used to read what humans couldn't. It's a reminder that AI isn't just expanding into new fields, but also reaching into areas beyond human perception, uncovering signals and structures we would never notice on our own.</p>
<p><em><s>BTW, I’m also curious whether if we could build a Wheel of Fortune LLM using this idea and see if it can beat the TV show.</s></em></p>
<p><img src="https://i0.wp.com/savantlabs.io/wp-content/uploads/2025/05/What-prevents-LLMs-from-prevailing-in-business-analytics.webp?fit=2688%2C1536&amp;ssl=1" alt="Why LLMs Haven't Transformed Business Analytics — Yet" /></p>
<h2 id="heading-references"><strong>References</strong></h2>
<p>Weiss, R., Ayzenshteyn, D., Amit, G., &amp; Mirsky, Y. (2024). <em>What Was Your Prompt? A Remote Keylogging Attack on AI Assistants.</em> Proceedings of the 33rd USENIX Security Symposium.</p>
<p><a target="_blank" href="https://www.usenix.org/conference/usenixsecurity24/presentation/weiss">https://www.usenix.org/conference/usenixsecurity24/presentation/weiss</a></p>
]]></content:encoded></item></channel></rss>