supasec 1.0.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/.env +1 -0
- package/LICENSE +21 -0
- package/README.md +276 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +30 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +22 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/scan.d.ts +23 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +235 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/models/finding.d.ts +88 -0
- package/dist/models/finding.d.ts.map +1 -0
- package/dist/models/finding.js +80 -0
- package/dist/models/finding.js.map +1 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +23 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/scan-result.d.ts +103 -0
- package/dist/models/scan-result.d.ts.map +1 -0
- package/dist/models/scan-result.js +168 -0
- package/dist/models/scan-result.js.map +1 -0
- package/dist/reporters/index.d.ts +6 -0
- package/dist/reporters/index.d.ts.map +1 -0
- package/dist/reporters/index.js +22 -0
- package/dist/reporters/index.js.map +1 -0
- package/dist/reporters/terminal.d.ts +20 -0
- package/dist/reporters/terminal.d.ts.map +1 -0
- package/dist/reporters/terminal.js +346 -0
- package/dist/reporters/terminal.js.map +1 -0
- package/dist/scanners/index.d.ts +7 -0
- package/dist/scanners/index.d.ts.map +1 -0
- package/dist/scanners/index.js +23 -0
- package/dist/scanners/index.js.map +1 -0
- package/dist/scanners/rls/analyzer.d.ts +44 -0
- package/dist/scanners/rls/analyzer.d.ts.map +1 -0
- package/dist/scanners/rls/analyzer.js +519 -0
- package/dist/scanners/rls/analyzer.js.map +1 -0
- package/dist/scanners/rls/index.d.ts +6 -0
- package/dist/scanners/rls/index.d.ts.map +1 -0
- package/dist/scanners/rls/index.js +22 -0
- package/dist/scanners/rls/index.js.map +1 -0
- package/dist/scanners/secrets/detector.d.ts +32 -0
- package/dist/scanners/secrets/detector.d.ts.map +1 -0
- package/dist/scanners/secrets/detector.js +251 -0
- package/dist/scanners/secrets/detector.js.map +1 -0
- package/dist/scanners/secrets/index.d.ts +7 -0
- package/dist/scanners/secrets/index.d.ts.map +1 -0
- package/dist/scanners/secrets/index.js +23 -0
- package/dist/scanners/secrets/index.js.map +1 -0
- package/dist/scanners/secrets/patterns.d.ts +57 -0
- package/dist/scanners/secrets/patterns.d.ts.map +1 -0
- package/dist/scanners/secrets/patterns.js +285 -0
- package/dist/scanners/secrets/patterns.js.map +1 -0
- package/npm-publishing-guide.md +38 -0
- package/package.json +69 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RLS Policy Analyzer
|
|
4
|
+
* Analyzes Row Level Security policies for vulnerabilities
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.analyzeRLS = analyzeRLS;
|
|
8
|
+
const finding_js_1 = require("../../models/finding.js");
|
|
9
|
+
/**
|
|
10
|
+
* Analyze RLS configuration for security issues
|
|
11
|
+
*/
|
|
12
|
+
async function analyzeRLS(options) {
|
|
13
|
+
const findings = [];
|
|
14
|
+
let findingCounter = 1;
|
|
15
|
+
// Check each table for RLS issues
|
|
16
|
+
for (const table of options.tables) {
|
|
17
|
+
const tableFindings = analyzeTable(table, options.policies, findingCounter);
|
|
18
|
+
findings.push(...tableFindings.findings);
|
|
19
|
+
findingCounter = tableFindings.nextCounter;
|
|
20
|
+
}
|
|
21
|
+
// Check for overly permissive policies
|
|
22
|
+
const policyFindings = analyzePolicies(options.policies, findingCounter);
|
|
23
|
+
findings.push(...policyFindings.findings);
|
|
24
|
+
findingCounter = policyFindings.nextCounter;
|
|
25
|
+
return {
|
|
26
|
+
findings,
|
|
27
|
+
tablesScanned: options.tables.length,
|
|
28
|
+
policiesScanned: options.policies.length
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Analyze a single table for RLS issues
|
|
33
|
+
*/
|
|
34
|
+
function analyzeTable(table, allPolicies, startCounter) {
|
|
35
|
+
const findings = [];
|
|
36
|
+
let counter = startCounter;
|
|
37
|
+
// Get policies for this table
|
|
38
|
+
const tablePolicies = allPolicies.filter(p => p.table === table.name && p.schema === table.schema);
|
|
39
|
+
// Check if RLS is enabled
|
|
40
|
+
if (!table.hasRLSEnabled) {
|
|
41
|
+
findings.push(createNoRLSFinding(table, counter++));
|
|
42
|
+
}
|
|
43
|
+
// Check for sensitive columns
|
|
44
|
+
const sensitiveColumns = detectSensitiveColumns(table.columns);
|
|
45
|
+
if (sensitiveColumns.length > 0 && !table.hasRLSEnabled) {
|
|
46
|
+
findings.push(createSensitiveDataFinding(table, sensitiveColumns, counter++));
|
|
47
|
+
}
|
|
48
|
+
// Check for missing policies
|
|
49
|
+
if (table.hasRLSEnabled && tablePolicies.length === 0) {
|
|
50
|
+
findings.push(createNoPolicyFinding(table, counter++));
|
|
51
|
+
}
|
|
52
|
+
// Check for bypass policies
|
|
53
|
+
for (const policy of tablePolicies) {
|
|
54
|
+
if (isBypassPolicy(policy)) {
|
|
55
|
+
findings.push(createBypassPolicyFinding(table, policy, counter++));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { findings, nextCounter: counter };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Analyze policies for security issues
|
|
62
|
+
*/
|
|
63
|
+
function analyzePolicies(policies, startCounter) {
|
|
64
|
+
const findings = [];
|
|
65
|
+
let counter = startCounter;
|
|
66
|
+
for (const policy of policies) {
|
|
67
|
+
// Check for missing user isolation
|
|
68
|
+
if (!hasUserIsolation(policy)) {
|
|
69
|
+
findings.push(createNoIsolationFinding(policy, counter++));
|
|
70
|
+
}
|
|
71
|
+
// Check for overly broad roles
|
|
72
|
+
if (policy.roles.includes('public') || policy.roles.includes('anon')) {
|
|
73
|
+
findings.push(createPublicRoleFinding(policy, counter++));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { findings, nextCounter: counter };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Detect sensitive columns in a table
|
|
80
|
+
*/
|
|
81
|
+
function detectSensitiveColumns(columns) {
|
|
82
|
+
const sensitivePatterns = [
|
|
83
|
+
/email/i,
|
|
84
|
+
/phone/i,
|
|
85
|
+
/password/i,
|
|
86
|
+
/secret/i,
|
|
87
|
+
/token/i,
|
|
88
|
+
/ssn/i,
|
|
89
|
+
/social/i,
|
|
90
|
+
/credit/i,
|
|
91
|
+
/card/i,
|
|
92
|
+
/payment/i,
|
|
93
|
+
/address/i,
|
|
94
|
+
/name/i,
|
|
95
|
+
/birth/i,
|
|
96
|
+
/dob/i,
|
|
97
|
+
/passport/i,
|
|
98
|
+
/license/i
|
|
99
|
+
];
|
|
100
|
+
return columns.filter(col => sensitivePatterns.some(pattern => pattern.test(col.name)));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Check if a policy is a bypass policy (allows everything)
|
|
104
|
+
*/
|
|
105
|
+
function isBypassPolicy(policy) {
|
|
106
|
+
const bypassPatterns = [
|
|
107
|
+
/^\s*true\s*$/i,
|
|
108
|
+
/^\s*1\s*=\s*1\s*$/i,
|
|
109
|
+
/^\s*'[^']*'\s*=\s*'[^']*'\s*$/i
|
|
110
|
+
];
|
|
111
|
+
const expression = policy.usingExpression || policy.withCheckExpression || '';
|
|
112
|
+
return bypassPatterns.some(pattern => pattern.test(expression));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if a policy has user isolation
|
|
116
|
+
*/
|
|
117
|
+
function hasUserIsolation(policy) {
|
|
118
|
+
const isolationPatterns = [
|
|
119
|
+
/auth\.uid\(\)/i,
|
|
120
|
+
/auth\.jwt\(\)/i,
|
|
121
|
+
/current_user/i,
|
|
122
|
+
/user_id/i
|
|
123
|
+
];
|
|
124
|
+
const expression = policy.usingExpression || policy.withCheckExpression || '';
|
|
125
|
+
return isolationPatterns.some(pattern => pattern.test(expression));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create finding for missing RLS
|
|
129
|
+
*/
|
|
130
|
+
function createNoRLSFinding(table, counter) {
|
|
131
|
+
return {
|
|
132
|
+
finding_id: (0, finding_js_1.generateFindingId)('rls', counter),
|
|
133
|
+
timestamp: new Date().toISOString(),
|
|
134
|
+
severity: 'CRITICAL',
|
|
135
|
+
category: 'rls',
|
|
136
|
+
subcategory: 'rls_disabled',
|
|
137
|
+
title: `Table '${table.name}' has RLS disabled`,
|
|
138
|
+
description: `The table '${table.name}' does not have Row Level Security enabled. All data in this table is accessible to anyone with the anon key.`,
|
|
139
|
+
location: {
|
|
140
|
+
table: `${table.schema}.${table.name}`
|
|
141
|
+
},
|
|
142
|
+
evidence: {
|
|
143
|
+
table_name: table.name,
|
|
144
|
+
schema: table.schema,
|
|
145
|
+
row_count: table.rowCount,
|
|
146
|
+
rls_enabled: false
|
|
147
|
+
},
|
|
148
|
+
impact: {
|
|
149
|
+
severity_score: 9.5,
|
|
150
|
+
description: `Complete exposure of ${table.rowCount} records in table '${table.name}'`,
|
|
151
|
+
affected_resources: [`${table.schema}.${table.name}`],
|
|
152
|
+
compliance_violations: ['GDPR-Article-32', 'SOC2-CC6.1']
|
|
153
|
+
},
|
|
154
|
+
remediation: {
|
|
155
|
+
summary: `Enable Row Level Security on table '${table.name}'`,
|
|
156
|
+
priority: 'IMMEDIATE',
|
|
157
|
+
effort: 'LOW',
|
|
158
|
+
steps: [
|
|
159
|
+
{
|
|
160
|
+
order: 1,
|
|
161
|
+
action: `Enable RLS on ${table.name}`,
|
|
162
|
+
sql: `ALTER TABLE ${table.schema}.${table.name} ENABLE ROW LEVEL SECURITY;`
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
order: 2,
|
|
166
|
+
action: 'Create a policy to restrict access',
|
|
167
|
+
sql: `CREATE POLICY "Users can only access own data"
|
|
168
|
+
ON ${table.schema}.${table.name}
|
|
169
|
+
FOR SELECT
|
|
170
|
+
USING (auth.uid() = user_id);`
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
sql: `-- Enable RLS on ${table.name}
|
|
174
|
+
ALTER TABLE ${table.schema}.${table.name} ENABLE ROW LEVEL SECURITY;
|
|
175
|
+
|
|
176
|
+
-- Create basic user isolation policy
|
|
177
|
+
CREATE POLICY "Users can only access own data"
|
|
178
|
+
ON ${table.schema}.${table.name}
|
|
179
|
+
FOR SELECT
|
|
180
|
+
USING (auth.uid() = user_id);
|
|
181
|
+
|
|
182
|
+
-- Create policy for inserts
|
|
183
|
+
CREATE POLICY "Users can only insert own data"
|
|
184
|
+
ON ${table.schema}.${table.name}
|
|
185
|
+
FOR INSERT
|
|
186
|
+
WITH CHECK (auth.uid() = user_id);
|
|
187
|
+
|
|
188
|
+
-- Create policy for updates
|
|
189
|
+
CREATE POLICY "Users can only update own data"
|
|
190
|
+
ON ${table.schema}.${table.name}
|
|
191
|
+
FOR UPDATE
|
|
192
|
+
USING (auth.uid() = user_id)
|
|
193
|
+
WITH CHECK (auth.uid() = user_id);`,
|
|
194
|
+
auto_fixable: true
|
|
195
|
+
},
|
|
196
|
+
references: [
|
|
197
|
+
{
|
|
198
|
+
title: 'Row Level Security Documentation',
|
|
199
|
+
url: 'https://supabase.com/docs/guides/auth/row-level-security'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
title: 'OWASP A01:2021 - Broken Access Control',
|
|
203
|
+
url: 'https://owasp.org/Top10/A01_2021-Broken_Access_Control/'
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
false_positive_likelihood: 'VERY_LOW',
|
|
207
|
+
confidence: 1.0
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create finding for sensitive data without RLS
|
|
212
|
+
*/
|
|
213
|
+
function createSensitiveDataFinding(table, sensitiveColumns, counter) {
|
|
214
|
+
const columnNames = sensitiveColumns.map(c => c.name).join(', ');
|
|
215
|
+
return {
|
|
216
|
+
finding_id: (0, finding_js_1.generateFindingId)('rls', counter),
|
|
217
|
+
timestamp: new Date().toISOString(),
|
|
218
|
+
severity: 'CRITICAL',
|
|
219
|
+
category: 'rls',
|
|
220
|
+
subcategory: 'sensitive_data_exposed',
|
|
221
|
+
title: `Sensitive data in '${table.name}' without RLS protection`,
|
|
222
|
+
description: `Table '${table.name}' contains sensitive columns (${columnNames}) but does not have Row Level Security enabled.`,
|
|
223
|
+
location: {
|
|
224
|
+
table: `${table.schema}.${table.name}`
|
|
225
|
+
},
|
|
226
|
+
evidence: {
|
|
227
|
+
table_name: table.name,
|
|
228
|
+
sensitive_columns: sensitiveColumns.map(c => c.name),
|
|
229
|
+
row_count: table.rowCount
|
|
230
|
+
},
|
|
231
|
+
impact: {
|
|
232
|
+
severity_score: 10.0,
|
|
233
|
+
description: `PII/PCI data exposure - GDPR/CCPA violation risk`,
|
|
234
|
+
affected_resources: [`${table.schema}.${table.name}`],
|
|
235
|
+
compliance_violations: ['GDPR-Article-32', 'CCPA-§1798.100', 'PCI-DSS-3.2']
|
|
236
|
+
},
|
|
237
|
+
remediation: {
|
|
238
|
+
summary: `Enable RLS immediately and restrict access to sensitive data`,
|
|
239
|
+
priority: 'IMMEDIATE',
|
|
240
|
+
effort: 'MEDIUM',
|
|
241
|
+
steps: [
|
|
242
|
+
{
|
|
243
|
+
order: 1,
|
|
244
|
+
action: 'Enable RLS on the table',
|
|
245
|
+
sql: `ALTER TABLE ${table.schema}.${table.name} ENABLE ROW LEVEL SECURITY;`
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
order: 2,
|
|
249
|
+
action: 'Create restrictive policies',
|
|
250
|
+
sql: `CREATE POLICY "Restrict sensitive data access"
|
|
251
|
+
ON ${table.schema}.${table.name}
|
|
252
|
+
FOR SELECT
|
|
253
|
+
USING (auth.uid() = user_id);`
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
sql: `-- Enable RLS and create policies for ${table.name}
|
|
257
|
+
ALTER TABLE ${table.schema}.${table.name} ENABLE ROW LEVEL SECURITY;
|
|
258
|
+
|
|
259
|
+
-- Restrict access to user's own data
|
|
260
|
+
CREATE POLICY "Users can only access own data"
|
|
261
|
+
ON ${table.schema}.${table.name}
|
|
262
|
+
FOR ALL
|
|
263
|
+
USING (auth.uid() = user_id)
|
|
264
|
+
WITH CHECK (auth.uid() = user_id);`,
|
|
265
|
+
auto_fixable: true
|
|
266
|
+
},
|
|
267
|
+
references: [
|
|
268
|
+
{
|
|
269
|
+
title: 'Row Level Security Documentation',
|
|
270
|
+
url: 'https://supabase.com/docs/guides/auth/row-level-security'
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
title: 'GDPR Article 32 - Security of Processing',
|
|
274
|
+
url: 'https://gdpr-info.eu/art-32-gdpr/'
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
false_positive_likelihood: 'VERY_LOW',
|
|
278
|
+
confidence: 1.0
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Create finding for no policies
|
|
283
|
+
*/
|
|
284
|
+
function createNoPolicyFinding(table, counter) {
|
|
285
|
+
return {
|
|
286
|
+
finding_id: (0, finding_js_1.generateFindingId)('rls', counter),
|
|
287
|
+
timestamp: new Date().toISOString(),
|
|
288
|
+
severity: 'HIGH',
|
|
289
|
+
category: 'rls',
|
|
290
|
+
subcategory: 'no_policies',
|
|
291
|
+
title: `Table '${table.name}' has no RLS policies`,
|
|
292
|
+
description: `RLS is enabled on '${table.name}' but no policies are defined. No one can access the data.`,
|
|
293
|
+
location: {
|
|
294
|
+
table: `${table.schema}.${table.name}`
|
|
295
|
+
},
|
|
296
|
+
evidence: {
|
|
297
|
+
table_name: table.name,
|
|
298
|
+
rls_enabled: true,
|
|
299
|
+
policy_count: 0
|
|
300
|
+
},
|
|
301
|
+
impact: {
|
|
302
|
+
severity_score: 6.0,
|
|
303
|
+
description: 'Application functionality may be broken - no data access possible',
|
|
304
|
+
affected_resources: [`${table.schema}.${table.name}`]
|
|
305
|
+
},
|
|
306
|
+
remediation: {
|
|
307
|
+
summary: `Create RLS policies for table '${table.name}'`,
|
|
308
|
+
priority: 'HIGH',
|
|
309
|
+
effort: 'MEDIUM',
|
|
310
|
+
steps: [
|
|
311
|
+
{
|
|
312
|
+
order: 1,
|
|
313
|
+
action: 'Create SELECT policy',
|
|
314
|
+
sql: `CREATE POLICY "Enable read access"
|
|
315
|
+
ON ${table.schema}.${table.name}
|
|
316
|
+
FOR SELECT
|
|
317
|
+
USING (true);`
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
sql: `-- Create basic policies for ${table.name}
|
|
321
|
+
CREATE POLICY "Enable read access for all users"
|
|
322
|
+
ON ${table.schema}.${table.name}
|
|
323
|
+
FOR SELECT
|
|
324
|
+
USING (true);
|
|
325
|
+
|
|
326
|
+
CREATE POLICY "Enable insert for authenticated users only"
|
|
327
|
+
ON ${table.schema}.${table.name}
|
|
328
|
+
FOR INSERT
|
|
329
|
+
WITH CHECK (auth.role() = 'authenticated');`,
|
|
330
|
+
auto_fixable: true
|
|
331
|
+
},
|
|
332
|
+
references: [
|
|
333
|
+
{
|
|
334
|
+
title: 'Creating RLS Policies',
|
|
335
|
+
url: 'https://supabase.com/docs/guides/auth/row-level-security#policies'
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
false_positive_likelihood: 'LOW',
|
|
339
|
+
confidence: 0.95
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Create finding for bypass policy
|
|
344
|
+
*/
|
|
345
|
+
function createBypassPolicyFinding(table, policy, counter) {
|
|
346
|
+
return {
|
|
347
|
+
finding_id: (0, finding_js_1.generateFindingId)('rls', counter),
|
|
348
|
+
timestamp: new Date().toISOString(),
|
|
349
|
+
severity: 'CRITICAL',
|
|
350
|
+
category: 'rls',
|
|
351
|
+
subcategory: 'bypass_policy',
|
|
352
|
+
title: `Bypass policy detected on '${table.name}'`,
|
|
353
|
+
description: `Policy '${policy.name}' uses a permissive expression that allows all access.`,
|
|
354
|
+
location: {
|
|
355
|
+
table: `${table.schema}.${table.name}`
|
|
356
|
+
},
|
|
357
|
+
evidence: {
|
|
358
|
+
policy_name: policy.name,
|
|
359
|
+
expression: policy.usingExpression || policy.withCheckExpression,
|
|
360
|
+
command: policy.command
|
|
361
|
+
},
|
|
362
|
+
impact: {
|
|
363
|
+
severity_score: 9.0,
|
|
364
|
+
description: 'Policy allows unrestricted access - effectively disables RLS',
|
|
365
|
+
affected_resources: [`${table.schema}.${table.name}`],
|
|
366
|
+
compliance_violations: ['SOC2-CC6.1']
|
|
367
|
+
},
|
|
368
|
+
remediation: {
|
|
369
|
+
summary: `Replace bypass policy with proper user isolation`,
|
|
370
|
+
priority: 'IMMEDIATE',
|
|
371
|
+
effort: 'LOW',
|
|
372
|
+
steps: [
|
|
373
|
+
{
|
|
374
|
+
order: 1,
|
|
375
|
+
action: 'Drop the bypass policy',
|
|
376
|
+
sql: `DROP POLICY IF EXISTS "${policy.name}" ON ${table.schema}.${table.name};`
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
order: 2,
|
|
380
|
+
action: 'Create proper policy with user isolation',
|
|
381
|
+
sql: `CREATE POLICY "User isolation"
|
|
382
|
+
ON ${table.schema}.${table.name}
|
|
383
|
+
FOR ${policy.command}
|
|
384
|
+
USING (auth.uid() = user_id);`
|
|
385
|
+
}
|
|
386
|
+
],
|
|
387
|
+
sql: `-- Replace bypass policy on ${table.name}
|
|
388
|
+
DROP POLICY IF EXISTS "${policy.name}" ON ${table.schema}.${table.name};
|
|
389
|
+
|
|
390
|
+
-- Create proper user isolation policy
|
|
391
|
+
CREATE POLICY "User data isolation"
|
|
392
|
+
ON ${table.schema}.${table.name}
|
|
393
|
+
FOR ${policy.command}
|
|
394
|
+
USING (auth.uid() = user_id)
|
|
395
|
+
WITH CHECK (auth.uid() = user_id);`,
|
|
396
|
+
auto_fixable: true
|
|
397
|
+
},
|
|
398
|
+
references: [
|
|
399
|
+
{
|
|
400
|
+
title: 'RLS Policy Expressions',
|
|
401
|
+
url: 'https://supabase.com/docs/guides/auth/row-level-security#policy-expressions'
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
false_positive_likelihood: 'LOW',
|
|
405
|
+
confidence: 0.95
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Create finding for missing user isolation
|
|
410
|
+
*/
|
|
411
|
+
function createNoIsolationFinding(policy, counter) {
|
|
412
|
+
return {
|
|
413
|
+
finding_id: (0, finding_js_1.generateFindingId)('rls', counter),
|
|
414
|
+
timestamp: new Date().toISOString(),
|
|
415
|
+
severity: 'HIGH',
|
|
416
|
+
category: 'rls',
|
|
417
|
+
subcategory: 'no_user_isolation',
|
|
418
|
+
title: `Policy '${policy.name}' lacks user isolation`,
|
|
419
|
+
description: `The policy does not verify user identity, potentially allowing users to access other users' data.`,
|
|
420
|
+
location: {
|
|
421
|
+
table: `${policy.schema}.${policy.table}`
|
|
422
|
+
},
|
|
423
|
+
evidence: {
|
|
424
|
+
policy_name: policy.name,
|
|
425
|
+
using_expression: policy.usingExpression,
|
|
426
|
+
with_check_expression: policy.withCheckExpression
|
|
427
|
+
},
|
|
428
|
+
impact: {
|
|
429
|
+
severity_score: 7.5,
|
|
430
|
+
description: 'IDOR vulnerability - users may access other users\' data',
|
|
431
|
+
affected_resources: [`${policy.schema}.${policy.table}`],
|
|
432
|
+
compliance_violations: ['OWASP-A01-2021']
|
|
433
|
+
},
|
|
434
|
+
remediation: {
|
|
435
|
+
summary: `Add user isolation to policy '${policy.name}'`,
|
|
436
|
+
priority: 'HIGH',
|
|
437
|
+
effort: 'MEDIUM',
|
|
438
|
+
steps: [
|
|
439
|
+
{
|
|
440
|
+
order: 1,
|
|
441
|
+
action: 'Review the policy and add user isolation',
|
|
442
|
+
sql: `-- Example: Add user isolation
|
|
443
|
+
ALTER POLICY "${policy.name}"
|
|
444
|
+
ON ${policy.schema}.${policy.table}
|
|
445
|
+
USING (auth.uid() = user_id);`
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
sql: `-- Update policy to include user isolation
|
|
449
|
+
DROP POLICY IF EXISTS "${policy.name}" ON ${policy.schema}.${policy.table};
|
|
450
|
+
|
|
451
|
+
CREATE POLICY "${policy.name}_with_isolation"
|
|
452
|
+
ON ${policy.schema}.${policy.table}
|
|
453
|
+
FOR ${policy.command}
|
|
454
|
+
USING (auth.uid() = user_id)
|
|
455
|
+
WITH CHECK (auth.uid() = user_id);`,
|
|
456
|
+
auto_fixable: true
|
|
457
|
+
},
|
|
458
|
+
references: [
|
|
459
|
+
{
|
|
460
|
+
title: 'User Isolation with RLS',
|
|
461
|
+
url: 'https://supabase.com/docs/guides/auth/row-level-security#authenticated-users'
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
false_positive_likelihood: 'MEDIUM',
|
|
465
|
+
confidence: 0.8
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Create finding for public role
|
|
470
|
+
*/
|
|
471
|
+
function createPublicRoleFinding(policy, counter) {
|
|
472
|
+
return {
|
|
473
|
+
finding_id: (0, finding_js_1.generateFindingId)('rls', counter),
|
|
474
|
+
timestamp: new Date().toISOString(),
|
|
475
|
+
severity: 'MEDIUM',
|
|
476
|
+
category: 'rls',
|
|
477
|
+
subcategory: 'public_role',
|
|
478
|
+
title: `Policy '${policy.name}' grants access to public/anonymous users`,
|
|
479
|
+
description: `The policy allows access to public or anonymous users. Ensure this is intentional.`,
|
|
480
|
+
location: {
|
|
481
|
+
table: `${policy.schema}.${policy.table}`
|
|
482
|
+
},
|
|
483
|
+
evidence: {
|
|
484
|
+
policy_name: policy.name,
|
|
485
|
+
roles: policy.roles,
|
|
486
|
+
command: policy.command
|
|
487
|
+
},
|
|
488
|
+
impact: {
|
|
489
|
+
severity_score: 5.0,
|
|
490
|
+
description: 'Anonymous users may access data - verify this is intended',
|
|
491
|
+
affected_resources: [`${policy.schema}.${policy.table}`]
|
|
492
|
+
},
|
|
493
|
+
remediation: {
|
|
494
|
+
summary: `Review if public access is required for '${policy.name}'`,
|
|
495
|
+
priority: 'MEDIUM',
|
|
496
|
+
effort: 'LOW',
|
|
497
|
+
steps: [
|
|
498
|
+
{
|
|
499
|
+
order: 1,
|
|
500
|
+
action: 'If public access is not needed, restrict to authenticated users',
|
|
501
|
+
sql: `-- Restrict to authenticated users
|
|
502
|
+
ALTER POLICY "${policy.name}"
|
|
503
|
+
ON ${policy.schema}.${policy.table}
|
|
504
|
+
TO authenticated;`
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
auto_fixable: false
|
|
508
|
+
},
|
|
509
|
+
references: [
|
|
510
|
+
{
|
|
511
|
+
title: 'RLS Policy Roles',
|
|
512
|
+
url: 'https://supabase.com/docs/guides/auth/row-level-security#policy-roles'
|
|
513
|
+
}
|
|
514
|
+
],
|
|
515
|
+
false_positive_likelihood: 'MEDIUM',
|
|
516
|
+
confidence: 0.7
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
//# sourceMappingURL=analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../../../src/scanners/rls/analyzer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA8CH,gCAqBC;AAjED,wDAAqE;AAyCrE;;GAEG;AACI,KAAK,UAAU,UAAU,CAAC,OAAuB;IACtD,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,IAAI,cAAc,GAAG,CAAC,CAAC;IAEvB,kCAAkC;IAClC,KAAK,MAAM,KAAK,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;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,MAAM,CAAC,IAAI;YACxB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB;QACD,MAAM,EAAE;YACN,cAAc,EAAE,GAAG;YACnB,WAAW,EAAE,2DAA2D;YACxE,kBAAkB,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;SACzD;QACD,WAAW,EAAE;YACX,OAAO,EAAE,4CAA4C,MAAM,CAAC,IAAI,GAAG;YACnE,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE;gBACL;oBACE,KAAK,EAAE,CAAC;oBACR,MAAM,EAAE,iEAAiE;oBACzE,GAAG,EAAE;gBACC,MAAM,CAAC,IAAI;OACpB,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK;oBAChB;iBACX;aACF;YACD,YAAY,EAAE,KAAK;SACpB;QACD,UAAU,EAAE;YACV;gBACE,KAAK,EAAE,kBAAkB;gBACzB,GAAG,EAAE,uEAAuE;aAC7E;SACF;QACD,yBAAyB,EAAE,QAAQ;QACnC,UAAU,EAAE,GAAG;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scanners/rls/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RLS Scanner Module
|
|
4
|
+
* Export all RLS analysis functionality
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./analyzer.js"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scanners/rls/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,gDAA8B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secrets Detector
|
|
3
|
+
* Main scanner module for detecting exposed secrets in frontend bundles
|
|
4
|
+
*/
|
|
5
|
+
import { Finding } from '../../models/finding.js';
|
|
6
|
+
export interface SecretsScanOptions {
|
|
7
|
+
content: string;
|
|
8
|
+
sourceUrl: string;
|
|
9
|
+
sourceType: 'javascript' | 'html' | 'sourcemap' | 'env';
|
|
10
|
+
}
|
|
11
|
+
export interface SecretsScanResult {
|
|
12
|
+
findings: Finding[];
|
|
13
|
+
scannedBytes: number;
|
|
14
|
+
scanDurationMs: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Scan content for exposed secrets
|
|
18
|
+
*/
|
|
19
|
+
export declare function scanForSecrets(options: SecretsScanOptions): Promise<SecretsScanResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Scan JavaScript bundle for secrets
|
|
22
|
+
*/
|
|
23
|
+
export declare function scanJavaScriptBundle(jsContent: string, url: string): Promise<SecretsScanResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Scan HTML content for secrets
|
|
26
|
+
*/
|
|
27
|
+
export declare function scanHTML(htmlContent: string, url: string): Promise<SecretsScanResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Scan source map for secrets
|
|
30
|
+
*/
|
|
31
|
+
export declare function scanSourceMap(sourceMapContent: string, url: string): Promise<SecretsScanResult>;
|
|
32
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../src/scanners/secrets/detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAyC,MAAM,yBAAyB,CAAC;AAGzF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,KAAK,CAAC;CACzD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsB5F;AA8MD;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMrG;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAM3F;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMrG"}
|