Why AI Coding Assistants Leak Your Email in HTTP Requests

    AI coding assistants can leak your email address by embedding it in the User-Agent header of outbound HTTP requests made during web retrieval. This article examines a real bug report in which a tool wrote the user's email into every request header, traces how a small optimization amplified the leak through two shared code paths, and analyzes the privacy and security risks for developers, from targeted spam and credential stuffing to identity profiling and exposure in training data. It then lays out governance practices for tool developers, individual users, and enterprise teams, including data minimization, purpose isolation, secure defaults, and a unified outbound gateway illustrated with a Go example. The core takeaway: secure defaults and explicit capability boundaries should be the foundation of every AI coding tool.

    Introduction: The Requests You Never Watch Are the Ones Made on Your Behalf

    When you ask an AI coding assistant to look up a document or fetch a webpage, it sends a request to the target site from your machine or from the cloud. Have you ever looked at what those requests actually contain?

    Most people haven’t. We outsource “going online” to tools but rarely ask: what identity did it report on my behalf, and what did it take away?

    A recent discussion started with one developer’s bug report. He suspected that the AI coding assistant he used every day was leaving his email address on websites. The debate this report sparked was worth far more than the bug itself: AI coding tools are becoming a new middle layer between users and the internet. The middle layer decides what information flows out and under what identity. Nobody has scrutinized these defaults, yet they directly affect every user’s privacy boundary.

    1. Recap: A Bug Report Written Like a Breakup Letter

    1.1 Starting from Dozens of Scam Emails

    A developer filed a bug early one morning. He said he received dozens of scam emails every day and pinned them on the AI coding assistant he used daily. In his description, the tool browsed the web to look up materials on his behalf and, without asking a single question, wrote his email into the request headers and handed it to one unrelated website after another.

    His demand wasn’t “add a toggle” but to remove the behavior entirely. He also said he was migrating his work to other tools, because he no longer expected the vendor to protect his privacy. A bug report had turned into a breakup letter.

    Four minutes later, someone forwarded the bug to a popular technical community forum. The post title was blunt, and within two days it had gained over 1,500 upvotes and 500+ comments.

    The comments soon filled with echoes:

    • Some said their long-silent old inboxes were suddenly flooded with strange spam, as if they’d been signed up to a thousand mailing lists overnight.
    • Some said it explained the odd emails recently aimed at a specific project of theirs.
    • Someone half-jokingly asked whether the emails constantly asking about fundraising came from the same place.

    1.2 What’s Fact and What’s Inference

    Two things need to be separated here.

    First, did this tool actually attract the spam? That is just an inference the developer made from the timeline, with no direct evidence. Once an email enters an external database, harassment can be delayed by weeks or even months; a coincidence in timing proves nothing about causation.

    Second, the email was indeed written into the request headers. The vendor itself admitted this. In an earlier round of user feedback, the assistant even told a user that it knew the email shouldn’t be sent to unrelated services, yet sent it anyway.

    In other words, even if the spam has nothing to do with this leak, the bug still stands. The tool delivered the user’s personal information to a recipient the user never expected, and what the recipient does with it is something the user can neither know nor control.

    2. Mechanism: How the Email Ended Up in the Request Header

    2.1 User-Agent: The “Self-Introduction” in a Network Request

    Every time a program visits a website, the request carries a line of self-introduction called the User-Agent. A browser writes which brand and version it is; a script writes which language and library sent it; a command-line tool writes its name and version.

    Websites read this line to figure out who’s calling: adjust how the page renders, decide whether to throttle, and judge whether the visitor is a search engine crawler. Technically, the User-Agent is just a free-text field, and anything in it may be logged verbatim by the server.

    Scripts and bots that developers write often follow some sites’ scraping etiquette by placing their purpose and a contact email in parentheses, so administrators can find a responsible person if the scraping behaves abnormally. It’s a “polite” convention. For example:

    1. User-Agent: my-fetcher/1.0 (research; +contact: developer@example.org)

    The problem is that this “politeness” hands over contact details with every handshake. And it isn’t one website; it’s every site encountered during retrieval.

    2.2 How a Local Optimization Got Amplified at Two Points

    According to the vendor’s engineer, explaining later on HN, the cause was a small nuisance. When programmers write code, comments like @author Name at the top of a file mark who wrote the code. Some users reported that the assistant would just invent a name in these spots, because it didn’t know who owned the account.

    Before doing its work, the assistant first reads a background note, called the “context” in jargon. The team’s fix was straightforward: write the login account’s email into this context. The result then spread along two paths:

    1. Account login path: when logging in with a personal account, the email is injected into the context to correct small issues like author information.
    2. Enterprise email mapping path: for members logging in with a corporate email, the context contains a sub-address derived from the main address, such as name+department@company.com. This may be intended to keep different members apart, but “separation” presupposes independence, and they all roll up under the same main address.

    These two paths then shared the same outbound request code. This is usually natural engineering reuse; the program already has global information like “who the current user is,” and constructing a header just grabs it in passing. Once written in, every external request’s User-Agent carries it, for example:

    1. User-Agent: claude-cli/2.1.318 (external, cli) → User-Agent: claude-cli/2.1.318 (external, cli; userEmail: name+team@company.com)

    Note the plus-suffix: the site receiving the request sees not one person’s address but an entire organization’s address plus a department tag.

    2.3 It Should Have Been Caught Earlier

    The vendor’s fix plan was to “remove the field in the next version.” In privacy engineering, this is after-the-fact damage control; the more important question is: why did this problem reach users at all?

    A piece of information, from creation to being sent out, passes through at least three nodes:

    1. Source: the email in the context.
    2. Aggregation: a global “current user” state inside the program.
    3. Exit: a unified wrapper for every outbound request.

    Each node had a chance to stop it: don’t write the email into the context, don’t let global user information automatically enter the headers, filter sensitive fields at the exit. Yet none did, because each step looked reasonable on its own: injecting the email was to fix a few comment lines, the global state was to pass fewer parameters, and the unified wrapper was to avoid duplicate code. Small conveniences stacked up layer by layer into a result the user never anticipated and can’t retract.

    3. Risk Analysis: What One Email Can Attract

    Back to the user’s original complaint: is one email worth all this fuss? It is. For a developer, an email is far more than an inbox address.

    3.1 “Precision” in Harassment

    Ordinary spam relies on mass sending and guessing; a leaked email is a verified live address. An attacker may also follow the email to your public code repositories, commit history, and current projects, and craft targeted “collaboration invitations,” “vulnerability reports,” or “interview notices,” or impersonate recruiters or investors. The more specific the email, the higher the chance that the target clicks a link or opens an attachment.

    3.2 The “Domino Effect” on Account Security

    In many systems, the email is the account itself and the credential for password recovery. Once combined with passwords leaked from other channels, it becomes raw material for credential stuffing. Leaked corporate sub-addresses also expose an employee’s organization and department, making social-engineering attacks that impersonate “IT support” easier to pull off.

    3.3 The Developer’s “Identity Puzzle”

    An email prefix is often the username, and a corporate email’s domain directly reveals which company you’re at. Combined with information gathered from other channels, it can assemble a fairly complete profile: where you work, which project you own, which technical directions you follow.

    3.4 Secondary Harm Flowing Back into Training Data

    If some large model used the same “politeness,” your email may be repeated verbatim when it answers questions like “add a contact email to the User-Agent,” and then pasted back by you into another conversation window. One user pasted such a snippet in a chat with the assistant and discovered their own email sitting inside it.

    Conversely, even if the tool switches to a fixed fictional address, that address is still a fixed identifier, enough to link the same user’s visits across different sites. So “whether to send” and “what to send” must be answered separately: never send what shouldn’t be sent, and make even what should be sent as free of identifiable information as possible.

    4. Governance: Make “No Outbound by Default” the Foundation of the Product

    4.1 Tool Developers: From “Can Be Turned Off” to “Absent by Default”

    The affected user demanded the behavior be removed entirely, saying “a toggle won’t do either.” This stance isn’t extreme in security circles; it corresponds to the “secure defaults” principle: any outbound transmission of personal information should be the result of an explicit user choice, not a default the user has to actively turn off.

    In engineering practice, you can start from four levels:

    • Data minimization: first ask, “does this request really need this information?” Looking up a public document needs neither your email nor your login state. Public retrieval should ideally go through an anonymous exit carrying no user-linked information.
    • Purpose isolation: draw separate boundaries for the same information in different scenarios. The email in the context serves only “generating correct author information”; the outbound User-Agent belongs only to the tool itself, hardcoded to an identifier with no personal information, such as my-agent/1.0 (+docs-url), where docs-url points to the tool’s own public documentation page. The two must never share the same field.
    • Defaults and fallback: without explicit authorization, don’t transmit any identity information. If a user needs a custom User-Agent, they must configure it manually and see a clear prompt. When compatibility with a particular site requires some identity, use a non-personal alternative first.
    • Observability and verifiability: every outbound request should be viewable, loggable, and exportable by the user, with sensitive fields passing through a unified filtering rule before being sent. Also maintain an inventory of personal information: what personal data exists in the system, which modules read it, and where it may flow. Had this email appeared on such an inventory, it would have been noticed during code review.

    4.2 Individual Users: Three Steps to See What It’s Actually Sending

    As a user, you don’t have to wait for the vendor to fix it; you can verify it yourself today:

    1. Check the docs: search the tool’s settings or documentation for keywords like “User-Agent,” “network,” “proxy,” and “web retrieval,” and see whether related configuration exists and what its defaults are.
    2. Capture the request: have the tool do one web retrieval while you observe its requests with a packet-capture tool or a local proxy. Focus on the following, not just the User-Agent:
    1. GET /docs/getting-started HTTP/1.1
    2. Host: docs.example.org
    3. User-Agent: <look here: any email, username, or machine name?>
    4. Referer: <look here: does it carry the previous search term or internal link?>
    5. Cookie: <look here: does it bring the account login state to an external site?>
    6. Accept-Language: <region, language preference>

    You can also add a “loopback-only” rule in your system’s DNS configuration, forcing specific domains back to the local machine to block such outbound traffic immediately, then undo it after verification.

    1. Keep evidence: screenshot or export the request logs. Once you confirm a problem exists, attach the version number and file feedback; this is far more effective than “I feel I’ve been leaked.”

    4.3 Enterprise Teams: Bring AI Coding Assistants into Data Export Control

    For individuals, this is a privacy accident; for enterprises, it is a blind spot in data governance. Many companies have export audits for employee browsers, email, and code repositories, but not for emerging AI coding tools. You can close the gap in four steps:

    1. Inventory first, then control: tally which AI coding tools the team uses, where they run, whether they go online, and which account they log in with. The account system matters especially: a personal account means a personal email enters the context, and a corporate account’s sub-address binds employees to their departments.
    2. Consolidate the exit: access the external network through a unified proxy gateway, forcibly rewrite the User-Agent at the exit, strip the Referer and Cookie, and set a domain whitelist that allows only the sites retrieval genuinely needs.
    3. Intercept sensitive information: identify patterns such as emails, phone numbers, and keys in outbound content; block or replace them on a hit, and log each event to an audit trail.
    4. Include it in procurement evaluation: add “no identity outbound by default,” “auditable outbound logs,” “data not used for training,” and “enterprise-grade data isolation” to the selection checklist.

    Cloud platforms can provide a number of general capabilities at this layer:

    • Use an API gateway to centrally control model-call exits;
    • Use a logging service to fully retain call and audit records;
    • Use monitoring and alerting to catch anomalous behavior in time;
    • Use sensitive-data identification and masking to block personal information leaks.

    Baidu AI Cloud, for example, offers model services through its Qianfan large model platform and emphasizes data security, stating that models are not used for training; specific capabilities and configurations are subject to the official documentation. Whichever cloud platform you choose, the core principle is one: controllable exits, queryable behavior, and data usable without being visible.

    4.4 Code Example: Unified Outbound Request Handling

    Below is illustrative code written with the standard library of a mainstream statically typed language. The approach can be applied to any language: all outbound requests pass through a single exit, which uniformly overwrites identity-related fields and restricts target domains by whitelist.

    1. package outbound
    2. import (
    3. "net/http"
    4. "strings"
    5. )
    6. // Tool-level fixed identifier: contains no personal information, can point to the tool's own public documentation page if needed
    7. const userAgent = "my-agent/1.0 (+docs-url)"
    8. // Custom headers that may carry personal information
    9. var identityHeaders = []string{"X-User-Email", "X-User-Name", "X-User-Id"}
    10. // Sensitive headers to be uniformly overwritten or stripped
    11. var scrubHeaders = []string{"Referer", "Cookie", "Authorization", "X-Forwarded-For"}
    12. var allowedHosts = map[string]bool{
    13. "docs.example.org": true, // replace with trusted documentation sites in real use
    14. }
    15. type guard struct {
    16. base http.RoundTripper
    17. }
    18. func (g *guard) RoundTrip(req *http.Request) (*http.Response, error) {
    19. if !allowedHosts[strings.ToLower(req.URL.Hostname())] {
    20. return nil, http.ErrUseLastResponse // reject targets outside the whitelist outright
    21. }
    22. for _, h := range scrubHeaders {
    23. req.Header.Del(h)
    24. }
    25. for _, h := range identityHeaders {
    26. req.Header.Del(h)
    27. }
    28. req.Header.Set("User-Agent", userAgent)
    29. return g.base.RoundTrip(req)
    30. }
    31. // NewClient returns a managed HTTP client; business code can only use it to access external sites
    32. func NewClient() *http.Client {
    33. return &http.Client{
    34. Transport: &guard{base: http.DefaultTransport},
    35. CheckRedirect: func(req *http.Request, via []*http.Request) error {
    36. return http.ErrUseLastResponse // don't auto-follow redirects, to avoid bypassing the whitelist via redirects
    37. },
    38. }
    39. }

    This code has three key points:

    1. Intercept before rewriting: domains outside the whitelist can’t even reach the request stage, preventing the tool from being lured into visiting arbitrary sites.
    2. Delete all identity fields first, then add: the User-Agent is fixed to a tool-level identifier, and custom headers like X-User-* are stripped entirely. Many chaining errors come from “global user information being casually attached to the request.”
    3. Don’t auto-follow redirects: otherwise a whitelisted site could, via a redirect, send the request to an address outside the whitelist, weakening the whitelist’s effect.

    5. Extension: The Overlooked Browsing History

    The email leak exposes only part of the exit problem. When the assistant does a web retrieval, it also sends your query content along: the title of an internal document, the name of an unreleased interface, a term only your company uses. This content settles in the logs of the retrieval provider and search engines, forming another channel of data outflow. The day someone types a highly specific internal project name into a search box, it’s worth pausing to think: did some assistant just send out that keyword on your behalf?

    Conclusion: Politeness Needs Boundaries, and Defaults Are an Attitude

    Back to the angry developer: what he wanted wasn’t a toggle, but to stop handing his email to strangers by default. In privacy engineering, this is a simple but crucial judgment: secure defaults aren’t a nice-to-have feature but the product’s basic attitude.

    How this plays out ultimately depends on whether the vendor’s fix is thorough. Whether the next version actually removes the field, whether the email is also cleared from the context, and whether the enterprise account’s mapped address also stops being sent out; all of this can be verified by capturing packets once more after the fix ships.

    For developers, the lesson can be distilled into three sentences:

    1. Classify personal information: which fields may enter the context, which may enter a request, and which must never leave the machine should each be defined separately, rather than pulled through with the same “current user” object.
    2. Make capability boundaries explicit: what a tool can read, where it can send, and under what identity should all be written in the open, and should default to the minimal set.
    3. Build a habit of verification: don’t hand “going online” entirely to the tool. Capture packets once in a while and see what it’s saying on your behalf.

    AI coding assistants are taking over more and more of our “hands and feet,” and what users need to see clearly is exactly where those hands and feet are reaching.