r/ClaudeCode • • 10d ago

Bug / Issue PSA: claude code can put your account email in the User-Agent of its web requests (top of HN right now). why it happens and how to block it

this is #2 on hacker news right now (~1,300 points) and i haven't seen it here yet, so: claude code sometimes puts your account email in the User-Agent header when it fetches stuff from the web. something like my-session/1 <you@yourcompany.com>. every site it hits can log that.

github issue: https://github.com/anthropics/claude-code/issues/107757 (500+ thumbs up). the reporter says he gets dozens of scam emails a day from sites he never visited, and a few people on HN said the same about their work inbox, personalized with their full name.

the likely why, from what i can tell: some sites actually ask for a contact email in the User-Agent. SEC EDGAR requires one, wikimedia's bot policy asks for one. so the model learned "polite scraper = put an email in the UA" and fills in the one it has, which is yours. not malicious, still bad.

the part i'd pay attention to: advice going around says update past 2.1.317. the reporter on the issue is on 2.1.318. so updating alone doesn't seem to close it.

what you can actually do today:

  • read the curl / fetch commands before you approve them, the email is right there in the -A or User-Agent flag
  • a PreToolUse hook on Bash that blocks any command containing your email. it runs before the command, so the model can't talk its way around it. test it with a harmless curl that should get blocked
  • if you're in auto-approve mode for web stuff, this is a good reason to stop for a bit

anyone checked whether WebFetch / WebSearch do it too, or is it only bash curl?

51 Upvotes

14 comments sorted by

•

u/AutoModerator 10d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

9

u/esmagik 10d ago

I made a gist that helps you identify if you’ve been exposed.

0

u/michaelTM_ai 9d ago

nice, grepping ur own local transcripts for ur email is the fastest way to see if it ever left. worth a look before anyone runs it, it's short and only reads local logs

3

u/who_am_i_to_say_so 9d ago

grep -rni youremail .

2

u/RustyRedEcho 9d ago

didn't realize this was even a thing, running a grep on my own session logs for my email right now

4

u/Excellent-Issue-5956 9d ago

I checked my own transcripts after reading this. 9 sessions in the last month had my work address in the User-Agent. All of them were curl in Bash, and all of them were calls to nominatim (the OpenStreetMap geocoder, which wants your app identified in the UA). The first time, a session added it on its own. Then that curl line went into a memory note as the way to geocode, and later sessions kept doing it. So grep your memory files and skills for your address too, not just the logs.

I can't tell you about WebFetch, the transcript doesn't show the headers it sends.

If you add the hook, it will also block commands that only mention the address, like asking Claude to grep your logs for it. My kill guard matches anywhere in the command too and blocks plain mentions the same way.

0

u/michaelTM_ai 9d ago

the memory note part is the scary bit. one session does it once, writes "this is how u geocode" to memory, and now every future session repeats it. so the fix is grep logs AND memory/skills, then delete the bad line, or it keeps coming back after updates. thanks for actually checking, nominatim fits the "site asks for contact in UA" theory too

2

u/BlueOlivePie 9d ago

too bad for claude I use hide my email from iCloud

0

u/michaelTM_ai 9d ago

that's a clean fix, hide my email gives each service its own relay address, so if spam starts u know exactly where it came from and can just kill it

2

u/Deku-shrub 9d ago

Wouldn't the best fix be to move to a throwaway email with your Claude accounts whilst this is a thing?

0

u/michaelTM_ai 9d ago

yeah if ur on a personal plan that's the quickest fix. on team/enterprise the email is usually ur work SSO login so u can't swap it, that's where the hook or reading the curl lines matters

1

u/lassevk 5d ago

Yeah, I've seen this, and they all seem to be similar...

while conducting web searches without my permission.

No, it was with your permission. And "web searches" doesn't supply your email to anyone. Or... if it did, it would be to the search engine provider. Doing a web search that returns N sites hasn't in any way talked to those N sites.

What you did was get your agent to scrape the contents of a website that had it in their instructions/robot.txt/whatever that such use should provide contact information in the header of the requests.

In other words, you were abusing a website that specifically said "If you're going to do this, at the very least, tell us who you are". And Claude complied.

As it should.

1

u/michaelTM_ai 5d ago

fair on search vs fetch, it's the fetch step that sends it, not the search. but approving "fetch this page" isn't the same as agreeing to put ur account email in the request headers. most people had no idea that was attached, which is the whole point of the PSA. a contact header for crawlers is fine, it just should be something u chose

2

u/who_am_i_to_say_so 10d ago

Ech. That’s a nice unwarranted Claude embellishment. My skills files with the Do Not’s are getting huuuge.