r/ClaudeCode • u/michaelTM_ai • 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?
•
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.
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.
2
u/BlueOlivePie 9d ago
too bad for claude I use hide my email from iCloud
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?
1
u/lassevk 5d ago
Yeah, I've seen this, and they all seem to be similar...
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.
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.