lilith-skill 0.0.0-stage โ 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +132 -2
- package/THIRD_PARTY_NOTICES.md +79 -0
- package/bin/lilith.mjs +147 -0
- package/package.json +43 -4
- package/skills/lilith/SKILL.md +61 -0
- package/skills/lilith/agents/openai.yaml +4 -0
- package/skills/lilith/checks/firebase_check.md +45 -0
- package/skills/lilith/checks/supabase_check.sql +211 -0
- package/skills/lilith/guides/cleanup-code.md +56 -0
- package/skills/lilith/guides/cleanup-ui.md +54 -0
- package/skills/lilith/guides/fixes/S1.md +6 -0
- package/skills/lilith/guides/fixes/S10.md +3 -0
- package/skills/lilith/guides/fixes/S11.md +3 -0
- package/skills/lilith/guides/fixes/S12.md +3 -0
- package/skills/lilith/guides/fixes/S13.md +3 -0
- package/skills/lilith/guides/fixes/S14.md +9 -0
- package/skills/lilith/guides/fixes/S2.md +15 -0
- package/skills/lilith/guides/fixes/S3.md +25 -0
- package/skills/lilith/guides/fixes/S4.md +11 -0
- package/skills/lilith/guides/fixes/S5.md +3 -0
- package/skills/lilith/guides/fixes/S6.md +7 -0
- package/skills/lilith/guides/fixes/S7.md +16 -0
- package/skills/lilith/guides/fixes/S8.md +11 -0
- package/skills/lilith/guides/fixes/S9.md +3 -0
- package/skills/lilith/guides/fixing.md +9 -0
- package/skills/lilith/guides/security-core.md +66 -0
- package/skills/lilith/guides/server.md +73 -0
- package/skills/lilith/guides/stacks/ai.md +14 -0
- package/skills/lilith/guides/stacks/firebase.md +13 -0
- package/skills/lilith/guides/stacks/stripe.md +13 -0
- package/skills/lilith/guides/stacks/supabase.md +31 -0
- package/skills/lilith/guides/ui/charts.md +10 -0
- package/skills/lilith/guides/ui/examples.md +30 -0
- package/skills/lilith/guides/ui/surface.md +11 -0
- package/skills/lilith/scripts/count_tells.py +384 -0
- package/skills/lilith/scripts/lilith_scan.py +750 -0
- package/skills/lilith/templates/report.md +64 -0
- package/src/agents.mjs +54 -0
- package/src/install.mjs +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 YOUR NAME
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,133 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ๐ก๏ธ Lilith: security check for vibecoded apps
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**AI app builders often ship apps with the database open to everyone and secret keys visible to every visitor. Lilith finds those holes before launch and explains them in plain words.**
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx lilith-skill
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Then open your project and tell your AI `/lilith`. You get one report:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Live database: checked (Supabase query results pasted)
|
|
13
|
+
๐ด Critical 1 ๐ High 1 ๐ก Medium 2 โช Cleanup 9
|
|
14
|
+
|
|
15
|
+
๐ด 1. Your OpenAI key is visible to every visitor (S2)
|
|
16
|
+
What: NEXT_PUBLIC_OPENAI_KEY in src/lib/ai.ts:4 is sent to the browser.
|
|
17
|
+
Why it matters: anyone can copy it and spend your OpenAI budget.
|
|
18
|
+
Fix: move the call to a server route (I can do this), then replace the key
|
|
19
|
+
in the OpenAI dashboard (only you can do this).
|
|
20
|
+
|
|
21
|
+
Want me to fix the ๐ด ones now?
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**No terminal? Using Lovable, Bolt or v0?** Paste the prompt from [PROMPT.md](PROMPT.md) into your project chat.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Why this exists
|
|
29
|
+
|
|
30
|
+
- **CVE-2025-48757** (CVSS 9.3, critical): insufficient Row Level Security in apps generated by Lovable "allows remote unauthenticated attackers to read or write to arbitrary database tables of generated sites" ([NVD](https://nvd.nist.gov/vuln/detail/CVE-2025-48757)). Lovable disputes the CVE, saying each customer is responsible for protecting their app's data.
|
|
31
|
+
- The researcher's scan "identified 303 endpoints across 170 projects (approximately 10.3% of the 1645 analyzed) with inadequate RLS settings" ([Matt Palmer, May 29, 2025](https://mattpalmer.io/posts/statement-on-CVE-2025-48757/)).
|
|
32
|
+
- UpGuard "found 16,326 Supabase databases exposing readable tables" out of about 300,000 domains using Supabase, and 55.8% of them held personal information. Its explanation: "Tables created programmatically through the API, which is how coding agents interact with Supabase, do not enable RLS by default" ([UpGuard, September 23, 2026](https://www.upguard.com/blog/everything-everywhere-systemic-data-exposure-in-supabase-apps)).
|
|
33
|
+
|
|
34
|
+
The code alone can't show whether your live database is open, so Lilith also gives you a read-only query to paste into the Supabase SQL Editor (or asks for your live Firebase rules).
|
|
35
|
+
|
|
36
|
+
## What you get
|
|
37
|
+
|
|
38
|
+
- ๐ **Security first.** Leaked API keys, open Supabase/Firebase databases, endpoints with no login check, fake payment webhooks, missing rate limits.
|
|
39
|
+
- ๐๏ธ **Live database check.** One read-only query for the Supabase SQL Editor: it reads settings, never your data.
|
|
40
|
+
- ๐ฃ๏ธ **For beginners.** Every issue: what's wrong, why it matters, how to fix. In your language.
|
|
41
|
+
- ๐งน **Then cleanup.** Leftover logs, fake data, dead buttons, AI-look UI, filler marketing copy.
|
|
42
|
+
- ๐ **Runs on your machine.** No account, no server, your code never leaves your computer.
|
|
43
|
+
|
|
44
|
+
## Install and use
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx lilith-skill
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This finds the coding agents on your computer (Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf) and puts the skill where each one looks. Run it again to update. Needs Node.js 18+; the quick scan also needs Python 3.8+ (optional: without it, the agent checks by reading).
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx lilith-skill --agent claude # only one agent
|
|
54
|
+
npx lilith-skill --project # into this project instead of your home folder
|
|
55
|
+
npx lilith-skill scan . # run the quick scan yourself
|
|
56
|
+
npx lilith-skill uninstall # remove it
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Other tools that support [Agent Skills](https://agentskills.io) work too: `npx skills add Sunnik21/lilith -g`.
|
|
60
|
+
|
|
61
|
+
Say `/lilith`, or in words:
|
|
62
|
+
|
|
63
|
+
- "Check my app before launch"
|
|
64
|
+
- "Is my app safe?"
|
|
65
|
+
- "Clean up the AI slop in my landing page"
|
|
66
|
+
- "Help me secure my VPS"
|
|
67
|
+
|
|
68
|
+
## What it checks
|
|
69
|
+
|
|
70
|
+
| | Check | Example |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| S1 | Secret keys in code or git | `sk_live_...` in a file, `.env` committed |
|
|
73
|
+
| S2 | Secrets sent to the browser | `NEXT_PUBLIC_OPENAI_KEY`, OpenAI called from React |
|
|
74
|
+
| S3 | Database open to everyone | Supabase RLS off, Firebase `allow read, write: if true` (plus the live database check) |
|
|
75
|
+
| S4 | Endpoints with no login check | `/api/notes` writes without checking the user |
|
|
76
|
+
| S5 | Seeing other users' data | change `/invoices/41` to `/42` |
|
|
77
|
+
| S6 | Trusting the browser | price or `isAdmin` taken from the request |
|
|
78
|
+
| S7 | Fake payments | Stripe webhook without signature check |
|
|
79
|
+
| S8 | No limits | AI endpoint anyone can call 100,000 times |
|
|
80
|
+
| S9 | Unsafe HTML | `dangerouslySetInnerHTML` with user text |
|
|
81
|
+
| S10 | File uploads | private files in a public bucket |
|
|
82
|
+
| S11 | AI features | secrets in the system prompt, AI tools with too much power |
|
|
83
|
+
| S12 | Debug doors | `/api/seed`, `admin@admin.com` / `admin123` |
|
|
84
|
+
| S13 | Old packages | critical `npm audit` results |
|
|
85
|
+
| S14 | CORS and headers | any site can call your API as the logged-in user |
|
|
86
|
+
| C1โC8 | Code cleanup | logs, fake data, dead buttons, giant files |
|
|
87
|
+
| U1โU20 | UI and copy | eyebrow labels, fake badges, gradients, "seamless", "elevate" |
|
|
88
|
+
| VPS | Own server | firewall, SSH keys, closed database ports |
|
|
89
|
+
|
|
90
|
+
Details and fixes: [skills/lilith/guides](skills/lilith/guides).
|
|
91
|
+
|
|
92
|
+
## How well does it work?
|
|
93
|
+
|
|
94
|
+
Measured on a small benchmark in [bench/](bench/): three apps written the way AI tools write them (Vite + React + Supabase, Next.js + Supabase + Stripe + OpenAI, Express + Prisma + JWT). Together they have **31 planted security bugs** and **17 decoys** (things that look bad but are fine, like the Supabase anon key or `console.error` in an error handler). Each app also has a fixed version.
|
|
95
|
+
|
|
96
|
+
**The full skill** (one run per app, claude-opus-5-5 via `claude -p`, 2026-11-20, [bench/RESULTS.md](bench/RESULTS.md)):
|
|
97
|
+
|
|
98
|
+
- Found **31 of 31** planted bugs, including the ones no regex can see (users reading each other's data, prices trusted from the browser, Pro unlocked from `?success=true`).
|
|
99
|
+
- Flagged **0 of 17** decoys.
|
|
100
|
+
- **3 false alarms**, all "outdated packages" (S13), partly caused by the benchmark's empty lockfiles.
|
|
101
|
+
- Severity matched ours on **24 of 31**; when it differed, it usually rated one level higher.
|
|
102
|
+
- One run per app. Results vary between runs and models, and 31 bugs in three small apps is not the real world.
|
|
103
|
+
|
|
104
|
+
**The quick scan alone** (`lilith_scan.py`, deterministic, runs in CI):
|
|
105
|
+
|
|
106
|
+
| | Before this benchmark | Now |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| Planted bugs found | 16/31 (52%) | 27/31 (87%) |
|
|
109
|
+
| Leads that were real bugs | 22/28 (79%) | 36/37 (97%) |
|
|
110
|
+
| Decoys flagged | 3/17 | 1/17 |
|
|
111
|
+
| Critical/high leads on the fixed apps | 3 | 0 |
|
|
112
|
+
|
|
113
|
+
The new scanner patterns were written after looking at these apps, so "Now" is optimistic for your project. The scanner still misses: update policies that let users change their own `is_admin` or `plan` column, public storage buckets created in SQL, premium unlocked in the browser, and secrets inside AI system prompts. It also flags credentialed CORS even when the app uses no cookies. Those need reading, which is why the scan is only step one.
|
|
114
|
+
|
|
115
|
+
Run it yourself: `python3 bench/run_scanner.py` (scanner) or `python3 bench/run_agent.py` (full skill, needs the `claude` CLI, about $1.50 per run).
|
|
116
|
+
|
|
117
|
+
## Honest limits
|
|
118
|
+
|
|
119
|
+
Lilith is a careful first check, not a professional penetration test. It reads your code; it can't see settings that live only in your dashboards (it will tell you what to check there). It never says "your app is secure", only what it checked. For an app handling payments, health or other sensitive data, get a human review too.
|
|
120
|
+
|
|
121
|
+
## Contribute
|
|
122
|
+
|
|
123
|
+
Each check is a short section in a Markdown file. Found a hole AI tools keep making? Add it:
|
|
124
|
+
|
|
125
|
+
1. Add a section to the right guide in `skills/lilith/guides/` with **Spot it / Why / Fix**.
|
|
126
|
+
2. If a regex can find it, add a pattern to `skills/lilith/scripts/lilith_scan.py` and a case to `tests/test_scan.py`.
|
|
127
|
+
3. Run `python3 tests/test_scan.py` and `python3 bench/run_scanner.py` (the scanner score must not drop).
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
132
|
+
|
|
133
|
+
Made by YOUR NAME ยท [your link]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Portions of this project are derived from MIT-licensed works. Their licenses follow.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Felipe Basurto
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
MIT License
|
|
33
|
+
|
|
34
|
+
Copyright (c) 2025-2026 Cloudflare, Inc.
|
|
35
|
+
|
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
37
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
38
|
+
in the Software without restriction, including without limitation the rights
|
|
39
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
40
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
41
|
+
furnished to do so, subject to the following conditions:
|
|
42
|
+
|
|
43
|
+
The above copyright notice and this permission notice shall be included in all
|
|
44
|
+
copies or substantial portions of the Software.
|
|
45
|
+
|
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
47
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
48
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
49
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
50
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
51
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
52
|
+
SOFTWARE.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
MIT License
|
|
59
|
+
|
|
60
|
+
Copyright (c) 2026 Tibobfd
|
|
61
|
+
|
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
63
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
64
|
+
in the Software without restriction, including without limitation the rights
|
|
65
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
66
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
67
|
+
furnished to do so, subject to the following conditions:
|
|
68
|
+
|
|
69
|
+
The above copyright notice and this permission notice shall be included in all
|
|
70
|
+
copies or substantial portions of the Software.
|
|
71
|
+
|
|
72
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
73
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
74
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
75
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
76
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
77
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
78
|
+
SOFTWARE.
|
|
79
|
+
```
|
package/bin/lilith.mjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Lilith installer: puts the skill where your coding agents find it.
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
9
|
+
|
|
10
|
+
import { agentTable } from "../src/agents.mjs";
|
|
11
|
+
import { installTo, planTargets, selectAgents, uninstallFrom, SKILL_NAME } from "../src/install.mjs";
|
|
12
|
+
|
|
13
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
14
|
+
const SKILL_DIR = join(ROOT, "skills", SKILL_NAME);
|
|
15
|
+
const SCANNER = join(SKILL_DIR, "scripts", "lilith_scan.py");
|
|
16
|
+
const AGENT_IDS = Object.keys(agentTable({}, "~"));
|
|
17
|
+
|
|
18
|
+
const HELP = `Lilith: security check for vibecoded apps
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
npx lilith-skill install for every agent found on this machine
|
|
22
|
+
npx lilith-skill install [opts] same, with options
|
|
23
|
+
npx lilith-skill uninstall remove it again
|
|
24
|
+
npx lilith-skill scan [path] run the quick scan (needs Python 3.8+)
|
|
25
|
+
npx lilith-skill agents list supported agents and where they look
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
-a, --agent <id> only this agent (repeatable): ${AGENT_IDS.join(", ")}
|
|
29
|
+
-p, --project install into the current project instead of your home folder
|
|
30
|
+
-f, --force replace a folder named "${SKILL_NAME}" that is not Lilith
|
|
31
|
+
-h, --help show this help
|
|
32
|
+
-v, --version show the version
|
|
33
|
+
|
|
34
|
+
Then open your project and tell your AI /${SKILL_NAME}.`;
|
|
35
|
+
|
|
36
|
+
const OPTIONS = {
|
|
37
|
+
agent: { type: "string", short: "a", multiple: true, default: [] },
|
|
38
|
+
project: { type: "boolean", short: "p", default: false },
|
|
39
|
+
force: { type: "boolean", short: "f", default: false },
|
|
40
|
+
help: { type: "boolean", short: "h", default: false },
|
|
41
|
+
version: { type: "boolean", short: "v", default: false },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function version() {
|
|
45
|
+
return JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")).version;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function splitAgents(values) {
|
|
49
|
+
return values.flatMap((v) => v.split(",")).map((v) => v.trim()).filter(Boolean);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function describe(result) {
|
|
53
|
+
const where = `${result.dir} (${result.agents.join(", ")})`;
|
|
54
|
+
const reason = result.reason ? `: ${result.reason}` : "";
|
|
55
|
+
return ` ${result.status.padEnd(9)} ${where}${reason}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function targetsFor(opts, ctx) {
|
|
59
|
+
const table = agentTable(ctx.env, ctx.home);
|
|
60
|
+
const ids = selectAgents(table, splitAgents(opts.agent));
|
|
61
|
+
if (ids.length === 0) {
|
|
62
|
+
ctx.out.error(
|
|
63
|
+
"No coding agent found in your home folder.\n" +
|
|
64
|
+
`Pick one: npx lilith-skill --agent claude (known: ${AGENT_IDS.join(", ")})`
|
|
65
|
+
);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return planTargets(table, ids, { project: opts.project, cwd: ctx.cwd });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function runInstall(opts, ctx) {
|
|
72
|
+
const targets = targetsFor(opts, ctx);
|
|
73
|
+
if (!targets) return 1;
|
|
74
|
+
const results = targets.map((t) => installTo(SKILL_DIR, t, { force: opts.force }));
|
|
75
|
+
ctx.out.log(`Lilith ${version()}`);
|
|
76
|
+
results.forEach((r) => ctx.out.log(describe(r)));
|
|
77
|
+
const ok = results.some((r) => r.status !== "skipped");
|
|
78
|
+
if (ok) ctx.out.log(`\nDone. Open your project and tell your AI /${SKILL_NAME}`);
|
|
79
|
+
return ok ? 0 : 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function runUninstall(opts, ctx) {
|
|
83
|
+
const targets = targetsFor(opts, ctx);
|
|
84
|
+
if (!targets) return 1;
|
|
85
|
+
targets.map(uninstallFrom).forEach((r) => ctx.out.log(describe(r)));
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function runAgents(ctx) {
|
|
90
|
+
const table = agentTable(ctx.env, ctx.home);
|
|
91
|
+
for (const [id, a] of Object.entries(table)) {
|
|
92
|
+
ctx.out.log(` ${id.padEnd(9)} ${a.name.padEnd(15)} ${a.globalDir} (project: ${a.projectDir})`);
|
|
93
|
+
}
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function runScan(args, ctx) {
|
|
98
|
+
const candidates = process.platform === "win32" ? ["py", "python", "python3"] : ["python3", "python"];
|
|
99
|
+
for (const py of candidates) {
|
|
100
|
+
const res = spawnSync(py, [SCANNER, ...args], { stdio: "inherit" });
|
|
101
|
+
if (res.error?.code === "ENOENT") continue;
|
|
102
|
+
if (res.error) {
|
|
103
|
+
ctx.out.error(`Could not run ${py}: ${res.error.message}`);
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
return res.status ?? 1;
|
|
107
|
+
}
|
|
108
|
+
ctx.out.error(
|
|
109
|
+
"The quick scan needs Python 3.8+ (python.org). Without it, /lilith still works: the agent checks by reading."
|
|
110
|
+
);
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function dispatch(command, rest, ctx) {
|
|
115
|
+
if (command === "scan") return runScan(rest, ctx);
|
|
116
|
+
const opts = parseArgs({ args: rest, options: OPTIONS, allowPositionals: false }).values;
|
|
117
|
+
if (opts.help || command === "help") return ctx.out.log(HELP), 0;
|
|
118
|
+
if (opts.version) return ctx.out.log(version()), 0;
|
|
119
|
+
if (command === "install") return runInstall(opts, ctx);
|
|
120
|
+
if (command === "uninstall") return runUninstall(opts, ctx);
|
|
121
|
+
if (command === "agents") return runAgents(ctx);
|
|
122
|
+
ctx.out.error(`Unknown command: ${command}\n\n${HELP}`);
|
|
123
|
+
return 2;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function main(argv, overrides = {}) {
|
|
127
|
+
const ctx = { env: process.env, home: homedir(), cwd: process.cwd(), out: console, ...overrides };
|
|
128
|
+
const words = argv.length === 0 || argv[0].startsWith("-") ? ["install", ...argv] : argv;
|
|
129
|
+
const [command, ...rest] = words;
|
|
130
|
+
try {
|
|
131
|
+
return dispatch(command, rest, ctx);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
const usage = err.code?.startsWith("ERR_PARSE_ARGS") ? `\n\n${HELP}` : "";
|
|
134
|
+
ctx.out.error(`Error: ${err.message}${usage}`);
|
|
135
|
+
return usage ? 2 : 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function isEntryPoint() {
|
|
140
|
+
try {
|
|
141
|
+
return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
|
|
142
|
+
} catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (isEntryPoint()) process.exitCode = main(process.argv.slice(2));
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lilith-skill",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Security check for vibecoded apps: an Agent Skill for Claude Code, Codex, Cursor, Copilot, Gemini CLI and more. Finds leaked keys, open Supabase/Firebase databases and missing login checks, in plain words.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Sunnik21/lilith.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/Sunnik21/lilith#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/Sunnik21/lilith/issues"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"bin": {
|
|
15
|
+
"lilith-skill": "bin/lilith.mjs"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/",
|
|
19
|
+
"src/",
|
|
20
|
+
"skills/lilith/",
|
|
21
|
+
"!**/__pycache__/",
|
|
22
|
+
"!**/*.pyc",
|
|
23
|
+
"!**/.DS_Store",
|
|
24
|
+
"THIRD_PARTY_NOTICES.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "node --test tests/*.test.mjs",
|
|
28
|
+
"test:py": "python3 tests/test_scan.py && python3 tests/test_supabase_check.py"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.3"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"agent-skill",
|
|
35
|
+
"skills",
|
|
36
|
+
"claude-code",
|
|
37
|
+
"codex",
|
|
38
|
+
"cursor",
|
|
39
|
+
"security",
|
|
40
|
+
"supabase",
|
|
41
|
+
"firebase",
|
|
42
|
+
"vibecoding"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT"
|
|
45
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lilith
|
|
3
|
+
description: Security check for vibecoded apps, in plain words for beginners. Finds leaked API keys, open Supabase or Firebase databases, missing login checks and unverified payments, then cleans up AI mess. Use when the user says "lilith", "check my app", "is my app safe", "security check", "audit", "clean up", "unslop", "before launch", or asks to secure a VPS.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Lilith: security check for vibecoded apps
|
|
7
|
+
|
|
8
|
+
You help someone launch an app they built with AI, usually a non-developer. Be a calm senior friend: find what is dangerous, explain it simply, fix it with permission.
|
|
9
|
+
|
|
10
|
+
**Talk:** the user's language, plain words (explain a technical term once); for every problem **what's wrong, why it matters (one real consequence), how to fix**; most dangerous first; no scaring or shaming; never "your app is secure", say what you checked; short messages.
|
|
11
|
+
|
|
12
|
+
## Modes
|
|
13
|
+
|
|
14
|
+
| The user says | Mode |
|
|
15
|
+
|---|---|
|
|
16
|
+
| "/lilith", "check my app", "is it safe", "audit", "ready to launch?" | **Security** (default): code + live database, report, one question |
|
|
17
|
+
| "/lilith full", "check everything", "security and cleanup" | **Full**: security, then code cleanup, then UI and copy |
|
|
18
|
+
| "/lilith clean", "clean up", "unslop", "looks AI-made" | **Cleanup** only (code, then UI and copy) |
|
|
19
|
+
| "/lilith server", "VPS", "Hetzner", "self-host" | **Server**: follow guides/server.md |
|
|
20
|
+
|
|
21
|
+
Cleanup runs only when asked.
|
|
22
|
+
|
|
23
|
+
## Steps
|
|
24
|
+
|
|
25
|
+
1. **Scan.** `python3 <this-skill-folder>/scripts/lilith_scan.py <project-root>`: stack, size, leads (hints, not findings), **read plan**. No Python: check by reading. Tell the user the stack in one line.
|
|
26
|
+
2. **Security.** Load what the table below says, go through S1 to S14, read the plan's files. A problem counts only if you can finish "[who] can [do what] to [whose data or money]".
|
|
27
|
+
3. **Live database** (Supabase or Firebase in the stack): follow the live check in the stack file. Skipped โ the report says "Live database: NOT checked".
|
|
28
|
+
4. **Cleanup** (full or cleanup mode only): code, then UI and copy. Cleanup never changes what the app does.
|
|
29
|
+
5. **Report** with templates/report.md. Security mode ends with exactly one question: "Fix the critical ones, or continue to cleanup?"
|
|
30
|
+
6. **Fix** only with permission: follow guides/fixing.md.
|
|
31
|
+
|
|
32
|
+
## Load this file when...
|
|
33
|
+
|
|
34
|
+
| File | When |
|
|
35
|
+
|---|---|
|
|
36
|
+
| guides/security-core.md | any security mode |
|
|
37
|
+
| guides/stacks/supabase.md | stack has Supabase (hands over the SQL check unread) |
|
|
38
|
+
| guides/stacks/firebase.md + checks/firebase_check.md | stack has Firebase |
|
|
39
|
+
| guides/stacks/stripe.md | stack has Stripe or Payments |
|
|
40
|
+
| guides/stacks/ai.md | stack has AI API |
|
|
41
|
+
| guides/cleanup-code.md | cleanup of code |
|
|
42
|
+
| guides/cleanup-ui.md | UI and copy cleanup (it routes to guides/ui/*) |
|
|
43
|
+
| templates/report.md | writing the report |
|
|
44
|
+
| guides/fixing.md + guides/fixes/S<n>.md | user agreed to fix S<n> (only those) |
|
|
45
|
+
| guides/server.md | server mode |
|
|
46
|
+
|
|
47
|
+
## Reading rules (save the user's tokens)
|
|
48
|
+
|
|
49
|
+
- **Batch reads:** every extra turn re-sends the whole conversation. Open all guide files a step needs in one go (parallel reads), and read the plan's files in a few large parallel batches, not one per turn.
|
|
50
|
+
- Read the plan's files first. Open others only when the plan or a lead points there.
|
|
51
|
+
- Grep before opening a file. Over 300 lines: read the plan's line ranges only.
|
|
52
|
+
- Never read lockfiles, build output, `node_modules`, generated types or binaries. Never re-read a file.
|
|
53
|
+
- Size **large**: say so and ask: "riskiest files only, or the full check?"
|
|
54
|
+
|
|
55
|
+
## Ground rules
|
|
56
|
+
|
|
57
|
+
- Read code. Never attack live sites, call production or use real users' data; give the owner a safe self-test.
|
|
58
|
+
- Never print a full secret: `sk_live_51Hโขโขโขโข4f2a`.
|
|
59
|
+
- Don't invent problems. Unsure: "worth checking" + the exact question.
|
|
60
|
+
- Ask before `npm audit fix --force`, deleting files or rewriting git history.
|
|
61
|
+
- Project conventions beat Lilith's style rules.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Live rules check for Firebase
|
|
2
|
+
|
|
3
|
+
The rules file in the repo (`firestore.rules`, `storage.rules`, `database.rules.json`) is not always what is running. Rules can be edited in the console, or the file was never deployed. The rules that protect the data are the **deployed** ones, so check those.
|
|
4
|
+
|
|
5
|
+
## What to ask the user (2 minutes)
|
|
6
|
+
|
|
7
|
+
Say, in their language:
|
|
8
|
+
|
|
9
|
+
> Your app's data is protected by "rules" stored in Firebase. I'll check the ones that are live right now. Copying them is safe: rules are settings, not your users' data.
|
|
10
|
+
>
|
|
11
|
+
> 1. Open console.firebase.google.com and pick your project.
|
|
12
|
+
> 2. **Firestore Database โ Rules** tab. Copy everything in the editor and paste it here.
|
|
13
|
+
> 3. If you use them, do the same for **Storage โ Rules** and **Realtime Database โ Rules**.
|
|
14
|
+
>
|
|
15
|
+
> If you'd rather skip this, say "skip" and I'll mark the live rules as not checked.
|
|
16
|
+
|
|
17
|
+
## What to do with the pasted rules
|
|
18
|
+
|
|
19
|
+
1. **Compare with the repo.** If the repo has a rules file, diff it against the pasted text. If they differ, say so in one line: "The rules running now are not the ones in your code." The live rules decide what's protected, so judge those. Suggest deploying from the repo afterward (`firebase deploy --only firestore:rules,storage`) so they stay in sync.
|
|
20
|
+
2. **Apply the S3 patterns** from [../guides/stacks/firebase.md](../guides/stacks/firebase.md) to the live rules:
|
|
21
|
+
|
|
22
|
+
| Pattern in live rules | Severity | Plain meaning |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `allow read, write: if true;` (or `allow write: if true`) | ๐ด Critical | Anyone on the internet can read and change this data. |
|
|
25
|
+
| `".read": true` / `".write": true` (Realtime Database) | ๐ด Critical | Same, for Realtime Database. |
|
|
26
|
+
| `request.time < timestamp.date(...)` | ๐ด Critical | "Test mode": open to everyone until that date, then the app breaks. |
|
|
27
|
+
| `if request.auth != null` on data that belongs to one user (`users`, `orders`, `messages`, `profiles`) | ๐ High | Any logged-in user can read or change every other user's data. Signing up is free, so this is close to open. |
|
|
28
|
+
| `allow read: if true` on truly public data (blog posts, product list) with no write rule for everyone | ๐ก Fine | Say it's OK and why. |
|
|
29
|
+
| A wildcard `match /{document=**}` with a broad `allow` | ๐ด/๐ | That rule covers every collection, including ones added later. |
|
|
30
|
+
|
|
31
|
+
3. **Report** each problem in the normal what / why / fix format. The fix is a rule that ties data to its owner:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
match /orders/{orderId} {
|
|
35
|
+
allow read, update, delete: if request.auth != null && request.auth.uid == resource.data.userId;
|
|
36
|
+
allow create: if request.auth != null && request.auth.uid == request.resource.data.userId;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
4. In the report header write **Live database: checked (Firebase rules pasted on <date>)**. If the user skipped, write **Live database: NOT checked** and add the steps above to "Only you can do this".
|
|
41
|
+
|
|
42
|
+
## Limits
|
|
43
|
+
|
|
44
|
+
- Pasted rules show what's allowed, not what data exists. A collection with no rule is denied by default, which is safe.
|
|
45
|
+
- Firebase App Check and API key restrictions live elsewhere in the console. Mention them under "Nice to have" only.
|