OpenAI's LLM, ChatGPT read 2 of my API keys for NPM and Google AI and it didn't tell me that.
I gave it an MCP server that connects like this: LLM => OpenAI Tunnel => My local MCP server => Access to my Termux terminal 🗿
Incident 1 (Medium)
I told it to fix something, then soon in my logs I saw it read ~/.bashrc. And I know that I have my Google AI API Key. After it finished, it did not tell me that it read it. I rotated my API key after. I asked ChatGPT if it saw it after it finished and it said yes.
Incident 2 (Dangerous)
I then told it to fix another thing, then my logs also showed that it ran a command and viewed ~/.npmrc. My API Key was in there. And after it finished, it did NOT tell me it saw it. After I asked, it said it didn't see it. But I know it did unless OpenAI's safety checks burst through the door and slapped the plate of API keys out of ChatGPT's hands 💀💀💀
I still rotated the key tho.
Now I am not tryna say to stop using ChatGPT, I am just talking about the risks. Because an exposed NPM API Key can make someone:
- Publish suspicious packages on my account
- Make me get banned
- Add malware to existing packages
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
What people should do is put their API keys into a .env when giving an AI access to your device and MAKE SURE to tell it not to read .env files. Or add restrictive permissions.
( Note: This same NPM incident happened with Replit Agent too, when in my Replit environment, it read ~/.npmrc )
Now like what are AIs expecting ~/.npmrc to contain? 💀
Top comments (2)
If the agent can read a file that holds keys, assume it will, and assume it will not tell you. Keep secrets out of the tree the tool can see, and rotate on any unexplained read in the logs — waiting for the model to confess is the wrong control.
That's a fair point. I agree that relying on the agent to disclose what it accessed isn't a reliable security measure. Tool-level restrictions and keeping credentials outside accessible directories are much better safeguards. I rotated both keys after the incidents, but this is definitely something I'll take into account going forward.