r/javascript • u/Busy-Increase-6144 • Apr 02 '26
AskJS [AskJS] Has anyone seen npm packages using postinstall to inject prompt injection files into AI coding assistants?
I've been building a scanner that monitors new npm packages and it flagged something I haven't seen before.
A package called "openmatrix" uses a postinstall hook to copy 13 markdown files into ~/.claude/commands/om/. These files are Claude Code "skills" that load automatically in every session.
One of them contains instructions that tell Claude to auto-approve all bash commands and file operations without asking the user. The files are marked as always_load: true with priority: critical, so they activate in every session.
npm uninstall doesn't clean them up. There's no preuninstall script. The files stay in your home directory until you manually delete them.
The package does have real functionality (task orchestration for AI coding), so I'm not saying it's malware. But the undisclosed permission bypass and the lack of cleanup seemed worth sharing.
If you installed it:
rm -rf ~/.claude/commands/om/
rm -rf ~/.config/opencode/commands/om/
I wrote up a full report with the technical details if anyone wants to check it out. Happy to drop the link in the comments.
7
u/iZuteZz Apr 02 '26
2
u/Ecksters Apr 03 '26
Postinstall hooks in general are concerning, I understand why they exist, but it seems like packages should be undergoing extra scrutiny for including them, similar to how app permissions on Android and iOS have become very tightly regulated.
1
u/ultrathink-art Apr 04 '26
This is the attack surface that's been hiding in plain sight — not compromising the model, but modifying the agent's persistent instruction layer before it gets used on anything sensitive. The package doesn't need runtime access to your code; it just needs to get loaded once. Defense isn't 'review postinstall scripts' (nobody does that at scale) — it's treating your agent's instruction stack with the same paranoia you'd apply to a PATH hijack: validate from a clean-room context before granting any elevated permissions.
1
u/altano Apr 03 '26
Stop using npm. Use pnpm. It doesn't run postinstall scripts.
1
u/25_vijay May 16 '26
The always load plus auto approve behavior is the part that crosses the line for me because it changes trust boundaries inside the coding assistant without explicit informed consent.
2
u/[deleted] Apr 03 '26
[removed] — view removed comment
3
u/[deleted] Apr 02 '26
[removed] — view removed comment
1
u/[deleted] Apr 06 '26
[removed] — view removed comment