guardvibe 1.1.1 → 1.3.3
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 +191 -21
- package/README.md +111 -32
- package/build/data/rules/api-security.d.ts +3 -0
- package/build/data/rules/api-security.d.ts.map +1 -0
- package/build/data/rules/api-security.js +131 -0
- package/build/data/rules/api-security.js.map +1 -0
- package/build/data/rules/auth.js +1 -1
- package/build/data/rules/auth.js.map +1 -1
- package/build/data/rules/core.js +4 -4
- package/build/data/rules/core.js.map +1 -1
- package/build/data/rules/cve-versions.d.ts.map +1 -1
- package/build/data/rules/cve-versions.js +97 -0
- package/build/data/rules/cve-versions.js.map +1 -1
- package/build/data/rules/database.js +4 -4
- package/build/data/rules/database.js.map +1 -1
- package/build/data/rules/index.d.ts.map +1 -1
- package/build/data/rules/index.js +4 -0
- package/build/data/rules/index.js.map +1 -1
- package/build/data/rules/modern-stack.d.ts +3 -0
- package/build/data/rules/modern-stack.d.ts.map +1 -0
- package/build/data/rules/modern-stack.js +414 -0
- package/build/data/rules/modern-stack.js.map +1 -0
- package/build/data/rules/nextjs.js +1 -1
- package/build/data/rules/nextjs.js.map +1 -1
- package/build/index.js +20 -1
- package/build/index.js.map +1 -1
- package/build/tools/check-code.d.ts.map +1 -1
- package/build/tools/check-code.js +45 -0
- package/build/tools/check-code.js.map +1 -1
- package/build/tools/fix-code.d.ts +17 -0
- package/build/tools/fix-code.d.ts.map +1 -0
- package/build/tools/fix-code.js +142 -0
- package/build/tools/fix-code.js.map +1 -0
- package/package.json +20 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,191 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 GokLab
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# GuardVibe
|
|
2
2
|
|
|
3
|
-
**The security MCP built for vibe coding.**
|
|
3
|
+
**The security MCP built for vibe coding.** 239 security rules covering the entire AI-generated code journey — from first line to production deployment.
|
|
4
4
|
|
|
5
5
|
Works with **Claude Code, Cursor, Gemini CLI, Codex, Windsurf**, and any MCP-compatible coding agent.
|
|
6
6
|
|
|
@@ -8,17 +8,38 @@ Works with **Claude Code, Cursor, Gemini CLI, Codex, Windsurf**, and any MCP-com
|
|
|
8
8
|
|
|
9
9
|
Most security tools are built for enterprise security teams. GuardVibe is built for **you** — the developer using AI to build and ship web apps fast.
|
|
10
10
|
|
|
11
|
-
- **
|
|
11
|
+
- **239 security rules** purpose-built for the stacks AI agents generate
|
|
12
12
|
- **Zero setup friction** — `npx guardvibe` and you're scanning
|
|
13
13
|
- **No account required** — runs 100% locally, no API keys, no cloud
|
|
14
14
|
- **Understands your stack** — not generic SAST, but rules that know Next.js, Supabase, Stripe, Clerk, and the tools you actually use
|
|
15
|
-
- **CVE version intelligence** — detects known vulnerable package versions in package.json
|
|
15
|
+
- **CVE version intelligence** — detects 21 known vulnerable package versions in package.json
|
|
16
16
|
- **AI agent security** — detects MCP server vulnerabilities, excessive AI permissions, indirect prompt injection
|
|
17
|
+
- **Auto-fix suggestions** — `fix_code` tool returns concrete patches the AI agent can apply
|
|
17
18
|
- **Pre-commit hook** — block insecure code before it reaches your repo
|
|
18
19
|
- **CI/CD ready** — GitHub Actions workflow with SARIF upload to Security tab
|
|
19
20
|
- **Agent-friendly output** — JSON format for AI agents, Markdown for humans, SARIF for CI/CD
|
|
20
21
|
- **Plugin system** — extend with community or premium rule packs
|
|
21
22
|
|
|
23
|
+
## How GuardVibe Compares
|
|
24
|
+
|
|
25
|
+
GuardVibe is purpose-built for the AI coding workflow. Traditional tools are excellent for enterprise CI/CD pipelines — GuardVibe fills a different gap.
|
|
26
|
+
|
|
27
|
+
| Capability | GuardVibe | Traditional SAST | Dependency Scanners |
|
|
28
|
+
|-----------|-----------|-----------------|-------------------|
|
|
29
|
+
| Runs inside AI agents (MCP) | Native | Not supported | Not supported |
|
|
30
|
+
| Zero config setup | `npx guardvibe` | Account + config required | Built-in (limited) |
|
|
31
|
+
| Vibecoding stack rules (Next.js, Supabase, Clerk, tRPC, Hono) | 100+ dedicated | Generic patterns | Not applicable |
|
|
32
|
+
| AI/LLM security (prompt injection, MCP, tool abuse) | 17 rules | Experimental/None | None |
|
|
33
|
+
| Auto-fix suggestions for AI agents | `fix_code` tool | CLI autofix | Not supported |
|
|
34
|
+
| CVE version detection | 21 packages | Extensive | Extensive |
|
|
35
|
+
| Compliance mapping (SOC2, PCI-DSS, HIPAA) | Built-in | Paid tier | None |
|
|
36
|
+
| SARIF CI/CD export | Yes | Yes | Limited |
|
|
37
|
+
| Rule count | 239 (focused) | 5000+ (broad) | N/A |
|
|
38
|
+
|
|
39
|
+
**When to use GuardVibe:** You're building with AI agents and want security scanning integrated into your coding workflow — no dashboard, no account, no CI setup.
|
|
40
|
+
|
|
41
|
+
**When to use traditional tools:** You need deep AST analysis, enterprise dashboards, org-wide policy enforcement, or coverage across hundreds of languages.
|
|
42
|
+
|
|
22
43
|
## Quick Start
|
|
23
44
|
|
|
24
45
|
### MCP setup (recommended)
|
|
@@ -59,22 +80,28 @@ npx guardvibe ci github # Generates .github/workflows/guardvibe.yml
|
|
|
59
80
|
## What GuardVibe Scans
|
|
60
81
|
|
|
61
82
|
### Application Code
|
|
62
|
-
Next.js App Router, Server Actions, Server Components, React, Express, FastAPI, Go
|
|
83
|
+
Next.js App Router, Server Actions, Server Components, React, Express, Hono, tRPC, GraphQL, FastAPI, Go
|
|
63
84
|
|
|
64
|
-
### Authentication
|
|
65
|
-
Clerk, Auth.js (NextAuth), Supabase Auth — middleware checks, secret exposure, session handling, SSR cookie auth, admin method protection
|
|
85
|
+
### Authentication & Authorization
|
|
86
|
+
Clerk, Auth.js (NextAuth), Supabase Auth, OAuth/OIDC (state parameter, PKCE) — middleware checks, secret exposure, session handling, SSR cookie auth, admin method protection
|
|
66
87
|
|
|
67
|
-
### Database
|
|
68
|
-
Supabase (RLS, anon vs service role), Prisma (raw query injection), Drizzle (SQL injection)
|
|
88
|
+
### Database & ORM
|
|
89
|
+
Supabase (RLS, anon vs service role), Prisma (raw query injection, CVEs), Drizzle (SQL injection), Turso/LibSQL (client exposure, SQL injection), Convex (auth bypass, internal function exposure)
|
|
69
90
|
|
|
70
91
|
### Payments
|
|
71
|
-
Stripe (webhook signatures,
|
|
92
|
+
Stripe (webhook signatures, replay protection, secret keys), Polar.sh, LemonSqueezy
|
|
72
93
|
|
|
73
94
|
### Third-Party Services
|
|
74
|
-
Resend (email injection), Upstash Redis, Pinecone, PostHog, Google Analytics (PII tracking)
|
|
95
|
+
Resend (email HTML injection), Upstash Redis, Pinecone, PostHog, Google Analytics (PII tracking), Uploadthing (auth, file type/size)
|
|
96
|
+
|
|
97
|
+
### AI / LLM Security
|
|
98
|
+
Prompt injection detection, LLM output sinks, system prompt leaks, MCP server SSRF/path traversal/command injection, `dangerouslyAllowBrowser`, missing `maxTokens`, AI API key client exposure, indirect prompt injection via external data
|
|
75
99
|
|
|
76
|
-
###
|
|
77
|
-
|
|
100
|
+
### OWASP API Security
|
|
101
|
+
BOLA/IDOR (Broken Object Level Authorization), mass assignment (spread request body, Object.assign), missing pagination, rate limiting, admin endpoint authorization, verbose error leaks
|
|
102
|
+
|
|
103
|
+
### Modern Stack
|
|
104
|
+
Zod `.passthrough()` mass assignment, `z.any()` bypass, file upload validation, `server-only` import guard, webhook replay protection, CSP headers, `unsafe-inline`/`unsafe-eval` detection, cron endpoint auth
|
|
78
105
|
|
|
79
106
|
### Mobile
|
|
80
107
|
React Native, Expo — AsyncStorage secrets, deep link token exposure, hardcoded API URLs, ATS configuration
|
|
@@ -82,8 +109,8 @@ React Native, Expo — AsyncStorage secrets, deep link token exposure, hardcoded
|
|
|
82
109
|
### Firebase
|
|
83
110
|
Firestore security rules, Firebase Admin SDK exposure, storage rules, custom token validation
|
|
84
111
|
|
|
85
|
-
### CVE Version Intelligence
|
|
86
|
-
|
|
112
|
+
### CVE Version Intelligence (21 CVEs)
|
|
113
|
+
Next.js (3 CVEs), React, Express, Axios, jsonwebtoken, lodash, node-fetch, tar, xml2js, crypto-js, Prisma (2 CVEs), next-auth (2 CVEs), sharp, ws, undici (2 CVEs)
|
|
87
114
|
|
|
88
115
|
### Deployment & Config
|
|
89
116
|
Vercel (vercel.json, cron secrets, headers), Next.js config, Docker, Docker Compose, Fly.io, Render, Netlify, Cloudflare
|
|
@@ -92,10 +119,7 @@ Vercel (vercel.json, cron secrets, headers), Next.js config, Docker, Docker Comp
|
|
|
92
119
|
Dockerfile security, GitHub Actions CI/CD, Terraform (S3, IAM, RDS, security groups)
|
|
93
120
|
|
|
94
121
|
### Secrets & Environment
|
|
95
|
-
API keys (AWS, GitHub, Stripe, OpenAI, Resend), .env management, .gitignore coverage, high-entropy detection, NEXT_PUBLIC exposure
|
|
96
|
-
|
|
97
|
-
### Webhooks & Web Security
|
|
98
|
-
Signature verification, open redirects, robots.txt exposure, source maps, meta tag injection, CSP headers
|
|
122
|
+
API keys (AWS, GitHub, Stripe, OpenAI, Resend, Turso), .env management, .gitignore coverage, high-entropy detection, NEXT_PUBLIC exposure
|
|
99
123
|
|
|
100
124
|
### Compliance
|
|
101
125
|
SOC2, PCI-DSS, HIPAA control mapping with compliance reports
|
|
@@ -103,7 +127,7 @@ SOC2, PCI-DSS, HIPAA control mapping with compliance reports
|
|
|
103
127
|
### Supply Chain
|
|
104
128
|
Malicious postinstall scripts, unpinned GitHub Actions, typosquat detection
|
|
105
129
|
|
|
106
|
-
## Tools (
|
|
130
|
+
## Tools (12 MCP tools)
|
|
107
131
|
|
|
108
132
|
| Tool | What it does |
|
|
109
133
|
|------|-------------|
|
|
@@ -118,17 +142,20 @@ Malicious postinstall scripts, unpinned GitHub Actions, typosquat detection
|
|
|
118
142
|
| `compliance_report` | SOC2 / PCI-DSS / HIPAA compliance mapping |
|
|
119
143
|
| `export_sarif` | SARIF v2.1.0 export for CI/CD integration |
|
|
120
144
|
| `get_security_docs` | Security best practices and guides |
|
|
145
|
+
| `fix_code` | **Auto-fix suggestions** with concrete patches for AI agents |
|
|
121
146
|
|
|
122
147
|
All scanning tools support `format: "json"` for machine-readable output.
|
|
123
148
|
|
|
124
|
-
## Security Rules (
|
|
149
|
+
## Security Rules (239 rules across 23 modules)
|
|
125
150
|
|
|
126
151
|
| Category | Rules | Coverage |
|
|
127
152
|
|----------|-------|----------|
|
|
128
|
-
| Core OWASP |
|
|
129
|
-
| Next.js App Router | 13 | Server Actions, secret exposure, auth bypass,
|
|
130
|
-
| Auth (Clerk / Auth.js / Supabase Auth) | 16 | Middleware, secret keys, session storage, role checks, SSR cookies
|
|
153
|
+
| Core OWASP | 19 | SQL injection, XSS, CSRF, command injection, CORS, SSRF, hardcoded secrets |
|
|
154
|
+
| Next.js App Router | 13 | Server Actions, secret exposure, auth bypass, CSP, redirects |
|
|
155
|
+
| Auth (Clerk / Auth.js / Supabase Auth) | 16 | Middleware, secret keys, session storage, role checks, SSR cookies |
|
|
131
156
|
| Database (Supabase / Prisma / Drizzle) | 8 | Raw queries, client exposure, service role leaks |
|
|
157
|
+
| OWASP API Security | 10 | BOLA/IDOR, mass assignment, pagination, rate limiting, error leaks |
|
|
158
|
+
| Modern Stack | 30 | Zod, tRPC, Hono, GraphQL, Uploadthing, Turso, Convex, OAuth, CSP, webhooks, AI SDK |
|
|
132
159
|
| Deployment Config | 16 | Vercel, Next.js config, Docker Compose, Fly, Render, Netlify |
|
|
133
160
|
| Payments (Stripe / Polar / Lemon) | 9 | Webhook signatures, key exposure, price manipulation |
|
|
134
161
|
| Services (Resend / Upstash / Pinecone / PostHog) | 11 | API key leaks, PII tracking, email injection |
|
|
@@ -136,7 +163,7 @@ All scanning tools support `format: "json"` for machine-readable output.
|
|
|
136
163
|
| React Native / Expo | 10 | AsyncStorage secrets, deep links, ATS, hardcoded URLs |
|
|
137
164
|
| Firebase | 7 | Firestore rules, admin SDK, storage, custom tokens |
|
|
138
165
|
| AI / LLM Security | 14 | Prompt injection, MCP SSRF, excessive agency, indirect injection |
|
|
139
|
-
| CVE Version Intelligence |
|
|
166
|
+
| CVE Version Intelligence | 20 | Known vulnerable versions in package.json (21 CVEs) |
|
|
140
167
|
| Shell / Bash | 5 | Pipe to bash, chmod 777, rm -rf, sudo password |
|
|
141
168
|
| SQL | 4 | DROP/DELETE without WHERE, stacked queries, GRANT ALL |
|
|
142
169
|
| Supply Chain | 2 | Malicious install scripts, unpinned actions |
|
|
@@ -167,24 +194,30 @@ npm install guardvibe-rules-awesome
|
|
|
167
194
|
|
|
168
195
|
Plugins matching `guardvibe-rules-*`, `@guardvibe/rules-*`, or `@guardvibe-pro/rules-*` are discovered automatically.
|
|
169
196
|
|
|
170
|
-
|
|
197
|
+
### Writing a Plugin
|
|
198
|
+
|
|
199
|
+
A plugin is an npm package that exports a `GuardVibePlugin` object:
|
|
171
200
|
|
|
172
201
|
```typescript
|
|
202
|
+
// index.ts
|
|
173
203
|
import type { GuardVibePlugin } from "guardvibe/plugins";
|
|
174
204
|
|
|
175
205
|
const plugin: GuardVibePlugin = {
|
|
176
206
|
name: "my-rules",
|
|
177
207
|
version: "1.0.0",
|
|
208
|
+
description: "My custom security rules",
|
|
178
209
|
rules: [
|
|
179
210
|
{
|
|
180
211
|
id: "CUSTOM001",
|
|
181
212
|
name: "My Custom Rule",
|
|
182
|
-
severity: "high",
|
|
213
|
+
severity: "high", // "critical" | "high" | "medium" | "low" | "info"
|
|
183
214
|
owasp: "A01:2025 Broken Access Control",
|
|
184
|
-
description: "
|
|
185
|
-
pattern: /
|
|
186
|
-
languages: ["javascript", "typescript"],
|
|
187
|
-
fix: "How to fix
|
|
215
|
+
description: "What this rule detects and why it's dangerous",
|
|
216
|
+
pattern: /vulnerable_pattern_here/g, // RegExp with global flag
|
|
217
|
+
languages: ["javascript", "typescript"], // which file types to scan
|
|
218
|
+
fix: "How to fix the vulnerability",
|
|
219
|
+
fixCode: "// Copy-paste secure code example",
|
|
220
|
+
compliance: ["SOC2:CC6.1"], // optional compliance mapping
|
|
188
221
|
},
|
|
189
222
|
],
|
|
190
223
|
};
|
|
@@ -192,6 +225,39 @@ const plugin: GuardVibePlugin = {
|
|
|
192
225
|
export default plugin;
|
|
193
226
|
```
|
|
194
227
|
|
|
228
|
+
### Plugin Rule Schema
|
|
229
|
+
|
|
230
|
+
| Field | Type | Required | Description |
|
|
231
|
+
|-------|------|----------|-------------|
|
|
232
|
+
| `id` | string | Yes | Unique rule ID (e.g., "CUSTOM001") |
|
|
233
|
+
| `name` | string | Yes | Human-readable rule name |
|
|
234
|
+
| `severity` | string | Yes | `critical`, `high`, `medium`, `low`, or `info` |
|
|
235
|
+
| `owasp` | string | Yes | OWASP category mapping |
|
|
236
|
+
| `description` | string | Yes | What the rule detects |
|
|
237
|
+
| `pattern` | RegExp | Yes | Regex pattern to match vulnerable code (use `/g` flag) |
|
|
238
|
+
| `languages` | string[] | Yes | File types to scan |
|
|
239
|
+
| `fix` | string | Yes | How to fix the issue |
|
|
240
|
+
| `fixCode` | string | No | Copy-paste secure code example |
|
|
241
|
+
| `compliance` | string[] | No | SOC2/PCI-DSS/HIPAA control IDs |
|
|
242
|
+
|
|
243
|
+
### Loading Plugins
|
|
244
|
+
|
|
245
|
+
Plugins are loaded from three sources:
|
|
246
|
+
|
|
247
|
+
1. **Auto-discovery:** Any installed npm package matching `guardvibe-rules-*` or `@guardvibe/rules-*`
|
|
248
|
+
2. **Config-specified:** Packages listed in `.guardviberc` `plugins` array
|
|
249
|
+
3. **Local paths:** Relative paths in `.guardviberc` `plugins` array
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
// .guardviberc
|
|
253
|
+
{
|
|
254
|
+
"plugins": [
|
|
255
|
+
"guardvibe-rules-awesome",
|
|
256
|
+
"./my-local-rules"
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
195
261
|
## Configuration
|
|
196
262
|
|
|
197
263
|
Create a `.guardviberc` file in your project root:
|
|
@@ -242,9 +308,22 @@ AI agent fixes issues before they reach production
|
|
|
242
308
|
Tested on a real 644-file Next.js + Supabase project:
|
|
243
309
|
|
|
244
310
|
- Scan time: **502ms**
|
|
245
|
-
- False positive rate: **near zero** (
|
|
311
|
+
- False positive rate: **near zero** (comment/string filtering, human-readable text detection)
|
|
246
312
|
- Detection rate: **100%** on known vulnerability patterns
|
|
247
313
|
|
|
314
|
+
## Security
|
|
315
|
+
|
|
316
|
+
GuardVibe takes supply chain security seriously:
|
|
317
|
+
|
|
318
|
+
- **npm provenance** — every published version is cryptographically signed via Sigstore, linking the package to this exact GitHub repo and commit. Verify with `npm audit signatures`
|
|
319
|
+
- **2FA enabled** — npm account protected with two-factor authentication
|
|
320
|
+
- **Branch protection** — force push disabled on main, admin enforcement enabled
|
|
321
|
+
- **Tag protection** — version tags (`v*`) cannot be deleted or force-pushed
|
|
322
|
+
- **Minimal CI permissions** — GitHub Actions workflows use `permissions: contents: read` only
|
|
323
|
+
- **Zero runtime dependencies** — only MCP SDK and Zod (both widely audited)
|
|
324
|
+
|
|
325
|
+
To report a vulnerability, please email security@goklab.com or open a GitHub issue.
|
|
326
|
+
|
|
248
327
|
## License
|
|
249
328
|
|
|
250
|
-
|
|
329
|
+
Apache 2.0 — open source, patent-safe, enterprise-ready. Built by [GokLab](https://github.com/goklab).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-security.d.ts","sourceRoot":"","sources":["../../../src/data/rules/api-security.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,eAAO,MAAM,gBAAgB,EAAE,YAAY,EAkK1C,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// OWASP API Security Top 10 rules
|
|
2
|
+
// See: https://owasp.org/API-Security/
|
|
3
|
+
export const apiSecurityRules = [
|
|
4
|
+
// API1:2023 — Broken Object Level Authorization (BOLA)
|
|
5
|
+
{
|
|
6
|
+
id: "VG950",
|
|
7
|
+
name: "BOLA: Direct Object Reference Without Ownership Check",
|
|
8
|
+
severity: "high",
|
|
9
|
+
owasp: "API1:2023 Broken Object Level Authorization",
|
|
10
|
+
description: "API endpoint accesses a resource by user-supplied ID without verifying that the authenticated user owns or has access to that resource. This is the #1 API vulnerability (BOLA/IDOR).",
|
|
11
|
+
pattern: /(?:findUnique|findFirst|findById|findOne|getOne)\s*\(\s*\{?\s*(?:where\s*:\s*\{)?\s*(?:id|_id)\s*:\s*(?:req\.(?:params|query|body)|params\.|args\.|input\.)/gi,
|
|
12
|
+
languages: ["javascript", "typescript"],
|
|
13
|
+
fix: "Always include an ownership check: add the authenticated user's ID to the query filter (e.g., { where: { id, userId } }).",
|
|
14
|
+
fixCode: '// Always scope queries to the authenticated user\nconst { userId } = await auth();\nconst item = await prisma.item.findFirst({\n where: { id: params.id, userId }, // ownership check!\n});\nif (!item) return new Response("Not Found", { status: 404 });',
|
|
15
|
+
compliance: ["SOC2:CC6.6", "PCI-DSS:Req6.5.10", "HIPAA:§164.312(a)"],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "VG951",
|
|
19
|
+
name: "BOLA: Delete/Update Without Ownership Verification",
|
|
20
|
+
severity: "critical",
|
|
21
|
+
owasp: "API1:2023 Broken Object Level Authorization",
|
|
22
|
+
description: "Delete or update operation uses user-supplied ID without verifying resource ownership. Any authenticated user can modify or delete other users' resources.",
|
|
23
|
+
pattern: /(?:delete|update|destroy|remove)\s*\(\s*\{?\s*(?:where\s*:\s*\{)?\s*(?:id|_id)\s*:\s*(?:req\.(?:params|query|body)|params\.|args\.|input\.)(?:(?!userId|user_id|ownerId|owner_id|createdBy|created_by)[\s\S]){0,200}?\}/gi,
|
|
24
|
+
languages: ["javascript", "typescript"],
|
|
25
|
+
fix: "Include the authenticated user's ID in the where clause to prevent unauthorized modifications.",
|
|
26
|
+
fixCode: '// Scope mutations to the authenticated user\nconst { userId } = await auth();\nawait prisma.post.delete({\n where: { id: params.id, userId }, // ownership!\n});',
|
|
27
|
+
compliance: ["SOC2:CC6.6", "PCI-DSS:Req6.5.10", "HIPAA:§164.312(a)"],
|
|
28
|
+
},
|
|
29
|
+
// API2:2023 — Broken Authentication
|
|
30
|
+
{
|
|
31
|
+
id: "VG952",
|
|
32
|
+
name: "API Route Without Authentication",
|
|
33
|
+
severity: "high",
|
|
34
|
+
owasp: "API2:2023 Broken Authentication",
|
|
35
|
+
description: "Next.js Route Handler that performs data operations without any authentication check. API routes are publicly accessible by default.",
|
|
36
|
+
pattern: /export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|DELETE|PATCH)\s*\([^)]*\)\s*\{(?:(?!auth\s*\(|getServerSession|currentUser|getUser|requireAuth|verifyToken|checkAuth|clerkClient|getToken|session|protect)[\s\S]){10,}?(?:prisma|db|supabase|query|fetch|sql)\.\w+/g,
|
|
37
|
+
languages: ["javascript", "typescript"],
|
|
38
|
+
fix: "Add authentication at the start of every Route Handler that reads or writes data.",
|
|
39
|
+
fixCode: 'import { auth } from "@clerk/nextjs/server";\n\nexport async function GET() {\n const { userId } = await auth();\n if (!userId) return new Response("Unauthorized", { status: 401 });\n // ... data access\n}',
|
|
40
|
+
compliance: ["SOC2:CC6.6", "PCI-DSS:Req6.5.10"],
|
|
41
|
+
},
|
|
42
|
+
// API3:2023 — Broken Object Property Level Authorization (Mass Assignment)
|
|
43
|
+
{
|
|
44
|
+
id: "VG953",
|
|
45
|
+
name: "Mass Assignment: Spreading Request Body into Database",
|
|
46
|
+
severity: "high",
|
|
47
|
+
owasp: "API3:2023 Broken Object Property Level Authorization",
|
|
48
|
+
description: "Request body is spread directly into a database create/update operation. Attackers can inject extra fields (like role, isAdmin, price) that the API didn't intend to accept.",
|
|
49
|
+
pattern: /(?:create|update|upsert|insert)\s*\(\s*\{[\s\S]{0,100}?(?:\.\.\.(?:req\.body|body|input|data|args)|(?:data|values)\s*:\s*(?:req\.body|body|input))\s*\}/gi,
|
|
50
|
+
languages: ["javascript", "typescript"],
|
|
51
|
+
fix: "Explicitly pick allowed fields instead of spreading the entire request body. Use a validation schema (zod) to define exactly which fields are accepted.",
|
|
52
|
+
fixCode: '// BAD: mass assignment\nawait prisma.user.update({ where: { id }, data: { ...req.body } });\n\n// GOOD: explicit fields\nconst { name, email } = schema.parse(req.body);\nawait prisma.user.update({ where: { id }, data: { name, email } });',
|
|
53
|
+
compliance: ["SOC2:CC6.6", "PCI-DSS:Req6.5.1"],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "VG954",
|
|
57
|
+
name: "Mass Assignment: Object.assign from User Input",
|
|
58
|
+
severity: "high",
|
|
59
|
+
owasp: "API3:2023 Broken Object Property Level Authorization",
|
|
60
|
+
description: "Object.assign or spread is used to merge user input directly into a model/entity object, allowing attackers to overwrite internal fields.",
|
|
61
|
+
pattern: /Object\.assign\s*\(\s*(?:user|item|record|entity|model|doc|document)\s*,\s*(?:req\.body|body|input|args|data)\s*\)/gi,
|
|
62
|
+
languages: ["javascript", "typescript"],
|
|
63
|
+
fix: "Pick specific allowed fields from user input before merging into model objects.",
|
|
64
|
+
fixCode: '// BAD: Object.assign(user, req.body);\n\n// GOOD: explicit pick\nconst { name, bio } = schema.parse(req.body);\nObject.assign(user, { name, bio });',
|
|
65
|
+
compliance: ["SOC2:CC6.6"],
|
|
66
|
+
},
|
|
67
|
+
// API4:2023 — Unrestricted Resource Consumption
|
|
68
|
+
{
|
|
69
|
+
id: "VG955",
|
|
70
|
+
name: "Missing Pagination on List Endpoint",
|
|
71
|
+
severity: "medium",
|
|
72
|
+
owasp: "API4:2023 Unrestricted Resource Consumption",
|
|
73
|
+
description: "Database query returns all records without pagination (no limit/take/top). An attacker can request the entire table, causing DoS or exposing excessive data.",
|
|
74
|
+
pattern: /(?:findMany|find|select|from)\s*\((?:(?!limit|take|top|pageSize|per_?page|first|last|\.limit|LIMIT)[\s\S]){5,}?\)/gi,
|
|
75
|
+
languages: ["javascript", "typescript"],
|
|
76
|
+
fix: "Always add pagination: use take/limit with a maximum value. Never return unbounded result sets.",
|
|
77
|
+
fixCode: '// Add pagination\nconst items = await prisma.item.findMany({\n take: Math.min(Number(searchParams.get("limit")) || 20, 100),\n skip: Number(searchParams.get("offset")) || 0,\n});',
|
|
78
|
+
compliance: ["SOC2:CC7.1"],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: "VG956",
|
|
82
|
+
name: "Missing Rate Limiting on API Route",
|
|
83
|
+
severity: "medium",
|
|
84
|
+
owasp: "API4:2023 Unrestricted Resource Consumption",
|
|
85
|
+
description: "Next.js API route handler performs expensive operations (database writes, external API calls, email sending) without any rate limiting. Attackers can abuse this to exhaust resources.",
|
|
86
|
+
pattern: /export\s+(?:async\s+)?function\s+POST\s*\([^)]*\)\s*\{(?:(?!rateLimit|rateLimiter|limiter|throttle|upstash|Ratelimit)[\s\S]){10,}?(?:\.create\s*\(|\.insert\s*\(|\.send\s*\(|resend\.|sendgrid\.|fetch\s*\(\s*['"]https)/g,
|
|
87
|
+
languages: ["javascript", "typescript"],
|
|
88
|
+
fix: "Add rate limiting to POST endpoints that create resources or call external services. Use @upstash/ratelimit or similar.",
|
|
89
|
+
fixCode: 'import { Ratelimit } from "@upstash/ratelimit";\nimport { Redis } from "@upstash/redis";\n\nconst ratelimit = new Ratelimit({\n redis: Redis.fromEnv(),\n limiter: Ratelimit.slidingWindow(10, "60 s"),\n});\n\nexport async function POST(req: Request) {\n const { success } = await ratelimit.limit(userId);\n if (!success) return new Response("Too Many Requests", { status: 429 });\n}',
|
|
90
|
+
compliance: ["SOC2:CC7.1"],
|
|
91
|
+
},
|
|
92
|
+
// API5:2023 — Broken Function Level Authorization
|
|
93
|
+
{
|
|
94
|
+
id: "VG957",
|
|
95
|
+
name: "Admin Endpoint Without Role Verification",
|
|
96
|
+
severity: "high",
|
|
97
|
+
owasp: "API5:2023 Broken Function Level Authorization",
|
|
98
|
+
description: "Endpoint in /admin or /api/admin path performs operations without verifying admin role or permissions. Any authenticated user could access admin functionality.",
|
|
99
|
+
pattern: /(?:\/api\/admin|\/admin)[\s\S]*?export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|DELETE|PATCH)\s*\([^)]*\)\s*\{(?:(?!role|isAdmin|orgRole|permission|requireAdmin|checkRole|adminOnly|org:admin)[\s\S]){10,}?(?:prisma|db|supabase|sql)\.\w+/g,
|
|
100
|
+
languages: ["javascript", "typescript"],
|
|
101
|
+
fix: "Always verify admin role/permissions in admin endpoints.",
|
|
102
|
+
fixCode: 'const { userId, orgRole } = await auth();\nif (orgRole !== "org:admin") {\n return new Response("Forbidden", { status: 403 });\n}',
|
|
103
|
+
compliance: ["SOC2:CC6.6", "HIPAA:§164.312(d)"],
|
|
104
|
+
},
|
|
105
|
+
// API6:2023 — Unrestricted Access to Sensitive Business Flows
|
|
106
|
+
{
|
|
107
|
+
id: "VG958",
|
|
108
|
+
name: "Sensitive Business Operation Without Confirmation",
|
|
109
|
+
severity: "medium",
|
|
110
|
+
owasp: "API6:2023 Unrestricted Access to Sensitive Business Flows",
|
|
111
|
+
description: "Destructive or irreversible operations (delete account, transfer money, cancel subscription) executed without a confirmation step or re-authentication.",
|
|
112
|
+
pattern: /(?:deleteAccount|deleteUser|cancelSubscription|transferFunds|refund|terminat)\w*\s*(?:=\s*async|\([\s\S]*?\)\s*(?:=>|{))(?:(?!confirm|verify|reauthenticate|twoFactor|2fa|otp|challenge)[\s\S]){10,}?(?:delete|destroy|remove|cancel)\s*\(/gi,
|
|
113
|
+
languages: ["javascript", "typescript"],
|
|
114
|
+
fix: "Add a confirmation step or re-authentication before destructive operations.",
|
|
115
|
+
compliance: ["SOC2:CC6.6"],
|
|
116
|
+
},
|
|
117
|
+
// API8:2023 — Security Misconfiguration
|
|
118
|
+
{
|
|
119
|
+
id: "VG959",
|
|
120
|
+
name: "Verbose Error Response Leaks Internal Details",
|
|
121
|
+
severity: "medium",
|
|
122
|
+
owasp: "API8:2023 Security Misconfiguration",
|
|
123
|
+
description: "Catch block sends the raw error message or stack trace in the API response. This leaks internal implementation details to attackers.",
|
|
124
|
+
pattern: /catch\s*\(\s*(?:err|error|e)\s*\)\s*\{[\s\S]{0,200}?(?:res\.(?:json|send|status)|Response\.json|NextResponse\.json)\s*\([\s\S]{0,100}?(?:err|error|e)\.(?:message|stack|toString)/gi,
|
|
125
|
+
languages: ["javascript", "typescript"],
|
|
126
|
+
fix: "Return generic error messages to the client. Log detailed errors server-side only.",
|
|
127
|
+
fixCode: 'catch (error) {\n console.error("Internal error:", error); // log server-side\n return Response.json(\n { error: "Something went wrong" }, // generic to client\n { status: 500 }\n );\n}',
|
|
128
|
+
compliance: ["SOC2:CC7.2"],
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
//# sourceMappingURL=api-security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-security.js","sourceRoot":"","sources":["../../../src/data/rules/api-security.ts"],"names":[],"mappings":"AAEA,kCAAkC;AAClC,uCAAuC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAmB;IAC9C,uDAAuD;IACvD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,uDAAuD;QAC7D,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,6CAA6C;QACpD,WAAW,EACT,uLAAuL;QACzL,OAAO,EACL,+JAA+J;QACjK,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,2HAA2H;QAChI,OAAO,EACL,8PAA8P;QAChQ,UAAU,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,CAAC;KACrE;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,oDAAoD;QAC1D,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,6CAA6C;QACpD,WAAW,EACT,4JAA4J;QAC9J,OAAO,EACL,2NAA2N;QAC7N,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,gGAAgG;QACrG,OAAO,EACL,oKAAoK;QACtK,UAAU,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,CAAC;KACrE;IAED,oCAAoC;IACpC;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,kCAAkC;QACxC,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,iCAAiC;QACxC,WAAW,EACT,sIAAsI;QACxI,OAAO,EACL,sQAAsQ;QACxQ,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,mFAAmF;QACxF,OAAO,EACL,kNAAkN;QACpN,UAAU,EAAE,CAAC,YAAY,EAAE,mBAAmB,CAAC;KAChD;IAED,2EAA2E;IAC3E;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,uDAAuD;QAC7D,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,sDAAsD;QAC7D,WAAW,EACT,8KAA8K;QAChL,OAAO,EACL,2JAA2J;QAC7J,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,yJAAyJ;QAC9J,OAAO,EACL,gPAAgP;QAClP,UAAU,EAAE,CAAC,YAAY,EAAE,kBAAkB,CAAC;KAC/C;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,gDAAgD;QACtD,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,sDAAsD;QAC7D,WAAW,EACT,2IAA2I;QAC7I,OAAO,EACL,sHAAsH;QACxH,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,iFAAiF;QACtF,OAAO,EACL,sJAAsJ;QACxJ,UAAU,EAAE,CAAC,YAAY,CAAC;KAC3B;IAED,gDAAgD;IAChD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,qCAAqC;QAC3C,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,6CAA6C;QACpD,WAAW,EACT,8JAA8J;QAChK,OAAO,EACL,qHAAqH;QACvH,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,iGAAiG;QACtG,OAAO,EACL,uLAAuL;QACzL,UAAU,EAAE,CAAC,YAAY,CAAC;KAC3B;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,oCAAoC;QAC1C,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,6CAA6C;QACpD,WAAW,EACT,wLAAwL;QAC1L,OAAO,EACL,2NAA2N;QAC7N,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,yHAAyH;QAC9H,OAAO,EACL,mYAAmY;QACrY,UAAU,EAAE,CAAC,YAAY,CAAC;KAC3B;IAED,kDAAkD;IAClD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,0CAA0C;QAChD,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,+CAA+C;QACtD,WAAW,EACT,iKAAiK;QACnK,OAAO,EACL,+OAA+O;QACjP,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,0DAA0D;QAC/D,OAAO,EACL,oIAAoI;QACtI,UAAU,EAAE,CAAC,YAAY,EAAE,mBAAmB,CAAC;KAChD;IAED,8DAA8D;IAC9D;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,mDAAmD;QACzD,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,2DAA2D;QAClE,WAAW,EACT,yJAAyJ;QAC3J,OAAO,EACL,8OAA8O;QAChP,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,6EAA6E;QAClF,UAAU,EAAE,CAAC,YAAY,CAAC;KAC3B;IAED,wCAAwC;IACxC;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,+CAA+C;QACrD,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE,qCAAqC;QAC5C,WAAW,EACT,sIAAsI;QACxI,OAAO,EACL,qLAAqL;QACvL,SAAS,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;QACvC,GAAG,EAAE,oFAAoF;QACzF,OAAO,EACL,oMAAoM;QACtM,UAAU,EAAE,CAAC,YAAY,CAAC;KAC3B;CACF,CAAC"}
|
package/build/data/rules/auth.js
CHANGED
|
@@ -190,7 +190,7 @@ export const authRules = [
|
|
|
190
190
|
severity: "high",
|
|
191
191
|
owasp: "A01:2025 Broken Access Control",
|
|
192
192
|
description: "Next.js project uses Supabase Auth but middleware.ts/proxy.ts does not refresh the Supabase session. Without this, sessions expire and users get unexpectedly logged out.",
|
|
193
|
-
pattern: /
|
|
193
|
+
pattern: /export\s+(?:async\s+)?function\s+middleware\s*\([^)]*\)\s*\{(?:(?!supabase|createServerClient|updateSession)[\s\S]){50,}(?:\n\}|$)/g,
|
|
194
194
|
languages: ["javascript", "typescript"],
|
|
195
195
|
fix: "Add Supabase session refresh to your middleware.",
|
|
196
196
|
fixCode: '// middleware.ts\nimport { createServerClient } from "@supabase/ssr";\nimport { NextResponse, type NextRequest } from "next/server";\n\nexport async function middleware(request: NextRequest) {\n const response = NextResponse.next();\n const supabase = createServerClient(url, anonKey, {\n cookies: { /* cookie handlers */ }\n });\n await supabase.auth.getUser(); // refreshes session\n return response;\n}',
|