sinapse-ai 9.3.0 → 9.4.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.
Files changed (192) hide show
  1. package/.claude/CLAUDE.md +56 -343
  2. package/.claude/rules/agent-authority.md +6 -0
  3. package/.claude/rules/agent-handoff.md +5 -0
  4. package/.claude/rules/cross-squad-routing.md +5 -0
  5. package/.claude/rules/hook-governance.md +6 -0
  6. package/.claude/rules/mcp-usage.md +3 -1
  7. package/.claude/rules/safe-collaboration.md +10 -0
  8. package/.claude/rules/security-data-protection.md +9 -0
  9. package/.claude/rules/squad-awareness.md +3 -1
  10. package/.claude/rules/tool-examples.md +6 -0
  11. package/.claude/rules/workflow-execution.md +7 -0
  12. package/.codex/agents/analyst.md +253 -72
  13. package/.codex/agents/architect.md +455 -68
  14. package/.codex/agents/data-engineer.md +492 -106
  15. package/.codex/agents/developer.md +560 -0
  16. package/.codex/agents/devops.md +518 -69
  17. package/.codex/agents/product-lead.md +335 -0
  18. package/.codex/agents/project-lead.md +377 -0
  19. package/.codex/agents/quality-gate.md +449 -0
  20. package/.codex/agents/sinapse-orqx.md +9 -7
  21. package/.codex/agents/sprint-lead.md +287 -0
  22. package/.codex/agents/squad-creator.md +344 -0
  23. package/.codex/agents/ux-design-expert.md +495 -0
  24. package/.codex/delegation-matrix.json +756 -44
  25. package/.codex/handoff-packet.schema.json +30 -6
  26. package/.sinapse-ai/data/entity-registry.yaml +175 -363
  27. package/.sinapse-ai/data/registry-update-log.jsonl +16 -0
  28. package/.sinapse-ai/development/agents/analyst.md +90 -0
  29. package/.sinapse-ai/development/agents/architect.md +73 -0
  30. package/.sinapse-ai/development/agents/developer.md +69 -0
  31. package/.sinapse-ai/development/agents/devops.md +117 -0
  32. package/.sinapse-ai/development/agents/quality-gate.md +85 -0
  33. package/.sinapse-ai/development/checklists/agent-quality-gate.md +27 -0
  34. package/.sinapse-ai/development/checklists/brownfield-compatibility-checklist.md +20 -0
  35. package/.sinapse-ai/development/checklists/code-review-checklist.md +106 -0
  36. package/.sinapse-ai/development/checklists/issue-triage-checklist.md +9 -0
  37. package/.sinapse-ai/development/checklists/memory-audit-checklist.md +16 -0
  38. package/.sinapse-ai/development/checklists/pr-quality-checklist.md +72 -0
  39. package/.sinapse-ai/development/checklists/security-deployment-checklist.md +54 -0
  40. package/.sinapse-ai/development/checklists/self-critique-checklist.md +19 -1
  41. package/.sinapse-ai/development/skills/debug.md +57 -0
  42. package/.sinapse-ai/development/skills/fast-review.md +69 -0
  43. package/.sinapse-ai/development/skills/research-synthesis.md +77 -0
  44. package/.sinapse-ai/development/skills/security-scan.md +73 -0
  45. package/.sinapse-ai/development/skills/verify.md +53 -0
  46. package/.sinapse-ai/development/templates/squad/agent-template.md +17 -4
  47. package/.sinapse-ai/development/templates/squad/checklist-template.md +13 -5
  48. package/.sinapse-ai/development/templates/squad/task-template.md +7 -0
  49. package/.sinapse-ai/development/templates/squad/workflow-template.yaml +7 -0
  50. package/.sinapse-ai/development/workflows/fast-track.yaml +87 -0
  51. package/.sinapse-ai/infrastructure/scripts/validate-codex-delegation.js +3 -1
  52. package/.sinapse-ai/install-manifest.yaml +71 -35
  53. package/docs/codex-integration-process.md +22 -0
  54. package/docs/codex-parity-program.md +27 -0
  55. package/docs/ide-integration.md +36 -0
  56. package/package.json +1 -1
  57. package/squads/claude-code-mastery/knowledge-base/claude-code-internals-reference.md +927 -0
  58. package/squads/squad-brand/knowledge-base/archetype-brand-mapping.md +12 -1
  59. package/squads/squad-brand/knowledge-base/brand-activism-cultural-branding.md +216 -0
  60. package/squads/squad-brand/knowledge-base/brand-audit-criteria.md +58 -0
  61. package/squads/squad-brand/knowledge-base/brand-digital-strategy.md +188 -0
  62. package/squads/squad-brand/knowledge-base/brand-legal-ip.md +222 -0
  63. package/squads/squad-brand/knowledge-base/brand-naming-framework.md +163 -0
  64. package/squads/squad-brand/knowledge-base/branding-master-reference.md +1001 -0
  65. package/squads/squad-brand/knowledge-base/color-psychology.md +25 -12
  66. package/squads/squad-brand/knowledge-base/employer-personal-branding.md +206 -0
  67. package/squads/squad-brand/knowledge-base/routing-catalog.md +34 -0
  68. package/squads/squad-brand/knowledge-base/sonic-branding-principles.md +6 -1
  69. package/squads/squad-brand/knowledge-base/typography-personality.md +34 -0
  70. package/squads/squad-claude/knowledge-base/context-window-optimization.md +334 -0
  71. package/squads/squad-claude/knowledge-base/knowledge-architecture-reference.md +403 -0
  72. package/squads/squad-claude/knowledge-base/memory-systems-reference.md +412 -0
  73. package/squads/squad-claude/knowledge-base/obsidian-claude-integration.md +423 -0
  74. package/squads/squad-claude/knowledge-base/retrieval-augmented-generation.md +320 -0
  75. package/squads/squad-claude/knowledge-base/skill-creation-patterns.md +380 -0
  76. package/squads/squad-claude/knowledge-base/swarm-orchestration-patterns.md +411 -0
  77. package/squads/squad-cloning/knowledge-base/clone-quality-assurance.md +211 -0
  78. package/squads/squad-cloning/knowledge-base/confidence-scoring.md +51 -0
  79. package/squads/squad-cloning/knowledge-base/cross-squad-deployment.md +47 -0
  80. package/squads/squad-cloning/knowledge-base/ethical-guidelines.md +237 -0
  81. package/squads/squad-cloning/knowledge-base/knowledge-graph-for-clones.md +295 -0
  82. package/squads/squad-cloning/knowledge-base/memory-architecture-for-clones.md +229 -0
  83. package/squads/squad-cloning/knowledge-base/multi-agent-deployment-patterns.md +320 -0
  84. package/squads/squad-cloning/knowledge-base/skill-standard-for-clones.md +262 -0
  85. package/squads/squad-cloning/knowledge-base/sop-extraction-guide.md +243 -0
  86. package/squads/squad-commercial/knowledge-base/account-based-selling.md +206 -0
  87. package/squads/squad-commercial/knowledge-base/ai-as-competitive-infrastructure.md +14 -0
  88. package/squads/squad-commercial/knowledge-base/ai-in-sales.md +199 -0
  89. package/squads/squad-commercial/knowledge-base/brazilian-sales-context.md +195 -0
  90. package/squads/squad-commercial/knowledge-base/customer-success-operations.md +83 -2
  91. package/squads/squad-commercial/knowledge-base/prospecting-pipeline-generation.md +69 -0
  92. package/squads/squad-commercial/knowledge-base/sales-enablement-playbook.md +260 -0
  93. package/squads/squad-commercial/knowledge-base/sales-methodology-comparison.md +185 -0
  94. package/squads/squad-commercial/knowledge-base/sales-revenue-master-reference.md +1123 -0
  95. package/squads/squad-content/knowledge-base/brazilian-content-context.md +176 -0
  96. package/squads/squad-content/knowledge-base/competitor-analysis-methods.md +40 -1
  97. package/squads/squad-content/knowledge-base/content-architecture-taxonomy.md +206 -0
  98. package/squads/squad-content/knowledge-base/content-formats-encyclopedia.md +58 -1
  99. package/squads/squad-content/knowledge-base/content-references-bibliography.md +130 -0
  100. package/squads/squad-content/knowledge-base/content-strategy-master-reference.md +1097 -0
  101. package/squads/squad-content/knowledge-base/content-tech-stack.md +150 -0
  102. package/squads/squad-content/knowledge-base/copywriting-formulas-library.md +188 -0
  103. package/squads/squad-content/knowledge-base/email-newsletter-strategy.md +161 -0
  104. package/squads/squad-content/knowledge-base/platform-algorithm-intelligence.md +86 -1
  105. package/squads/squad-content/knowledge-base/social-algorithms-master-reference.md +1007 -0
  106. package/squads/squad-content/knowledge-base/video-audio-content-playbook.md +218 -0
  107. package/squads/squad-copy/knowledge-base/ai-copy-production.md +254 -0
  108. package/squads/squad-copy/knowledge-base/brazilian-copywriting-context.md +242 -0
  109. package/squads/squad-copy/knowledge-base/email-copywriting-system.md +299 -0
  110. package/squads/squad-copy/knowledge-base/landing-page-copy-architecture.md +267 -0
  111. package/squads/squad-copy/knowledge-base/power-words-catalog.md +205 -0
  112. package/squads/squad-copy/knowledge-base/seo-copywriting.md +255 -0
  113. package/squads/squad-copy/knowledge-base/video-script-copywriting.md +239 -0
  114. package/squads/squad-council/knowledge-base/brand-strategy-models.md +193 -0
  115. package/squads/squad-council/knowledge-base/growth-strategy-models.md +267 -0
  116. package/squads/squad-council/knowledge-base/innovation-disruption-frameworks.md +193 -0
  117. package/squads/squad-council/knowledge-base/market-analysis-frameworks.md +240 -0
  118. package/squads/squad-council/knowledge-base/organizational-leadership-models.md +212 -0
  119. package/squads/squad-council/knowledge-base/sales-strategy-models.md +215 -0
  120. package/squads/squad-courses/knowledge-base/course-launch-strategy.md +251 -0
  121. package/squads/squad-courses/knowledge-base/domain-advocacia-curriculum.md +385 -0
  122. package/squads/squad-courses/knowledge-base/domain-contabilidade-curriculum.md +266 -0
  123. package/squads/squad-courses/knowledge-base/platform-comparison.md +68 -0
  124. package/squads/squad-courses/knowledge-base/video-production-guide.md +70 -0
  125. package/squads/squad-cybersecurity/knowledge-base/cloud-security-reference.md +363 -0
  126. package/squads/squad-cybersecurity/knowledge-base/compliance-frameworks.md +273 -0
  127. package/squads/squad-cybersecurity/knowledge-base/database-security.md +438 -0
  128. package/squads/squad-cybersecurity/knowledge-base/incident-response-playbook.md +420 -0
  129. package/squads/squad-cybersecurity/knowledge-base/network-security-reference.md +477 -0
  130. package/squads/squad-cybersecurity/knowledge-base/penetration-testing-methodology.md +350 -0
  131. package/squads/squad-cybersecurity/knowledge-base/vulnerability-management.md +349 -0
  132. package/squads/squad-design/knowledge-base/brazilian-design-context.md +223 -0
  133. package/squads/squad-design/knowledge-base/component-api-patterns.md +208 -4
  134. package/squads/squad-design/knowledge-base/design-system-master-reference.md +1302 -0
  135. package/squads/squad-design/knowledge-base/design-systems-frameworks.md +91 -1
  136. package/squads/squad-design/knowledge-base/responsive-modern-css.md +96 -4
  137. package/squads/squad-design/knowledge-base/wcag-aria-reference.md +117 -5
  138. package/squads/squad-design/knowledge-base/web-performance-reference.md +127 -4
  139. package/squads/squad-finance/knowledge-base/brazilian-taxation.md +263 -0
  140. package/squads/squad-finance/knowledge-base/contabilidade-master-reference.md +998 -0
  141. package/squads/squad-finance/knowledge-base/finance-master-reference.md +946 -0
  142. package/squads/squad-finance/knowledge-base/financial-reporting-analysis.md +316 -0
  143. package/squads/squad-finance/knowledge-base/fintech-brazilian-context.md +242 -0
  144. package/squads/squad-finance/knowledge-base/fpa-planning-frameworks.md +286 -0
  145. package/squads/squad-finance/knowledge-base/ma-and-transactions.md +285 -0
  146. package/squads/squad-finance/knowledge-base/risk-management.md +233 -0
  147. package/squads/squad-finance/knowledge-base/startups-venture-capital.md +337 -0
  148. package/squads/squad-growth/knowledge-base/ai-growth-playbook.md +216 -0
  149. package/squads/squad-growth/knowledge-base/attribution-models.md +78 -0
  150. package/squads/squad-growth/knowledge-base/brazilian-growth-context.md +208 -0
  151. package/squads/squad-growth/knowledge-base/community-led-growth.md +175 -0
  152. package/squads/squad-growth/knowledge-base/content-marketing-flywheel.md +190 -0
  153. package/squads/squad-growth/knowledge-base/email-lifecycle-framework.md +192 -0
  154. package/squads/squad-growth/knowledge-base/growth-frameworks-catalog.md +82 -0
  155. package/squads/squad-growth/knowledge-base/growth-master-reference.md +1168 -0
  156. package/squads/squad-growth/knowledge-base/routing-catalog.md +53 -11
  157. package/squads/squad-paidmedia/knowledge-base/audiences-segmentation-deep.md +285 -0
  158. package/squads/squad-paidmedia/knowledge-base/creative-strategy-deep.md +294 -0
  159. package/squads/squad-paidmedia/knowledge-base/google-ads-account-architecture.md +87 -0
  160. package/squads/squad-paidmedia/knowledge-base/meta-ads-campaign-architecture.md +76 -0
  161. package/squads/squad-paidmedia/knowledge-base/paid-media-metrics-reference.md +117 -0
  162. package/squads/squad-paidmedia/knowledge-base/paid-traffic-master-reference.md +1308 -0
  163. package/squads/squad-paidmedia/knowledge-base/routing-catalog.md +95 -18
  164. package/squads/squad-paidmedia/knowledge-base/traffic-masters-frameworks.md +71 -0
  165. package/squads/squad-product/knowledge-base/brazilian-product-context.md +284 -0
  166. package/squads/squad-product/knowledge-base/discovery-methodology-playbook.md +141 -0
  167. package/squads/squad-product/knowledge-base/pm-frameworks-reference.md +125 -9
  168. package/squads/squad-product/knowledge-base/product-analytics-formulas.md +72 -0
  169. package/squads/squad-product/knowledge-base/product-led-growth-reference.md +155 -13
  170. package/squads/squad-product/knowledge-base/product-market-fit-framework.md +222 -0
  171. package/squads/squad-product/knowledge-base/routing-catalog.md +32 -0
  172. package/squads/squad-research/knowledge-base/agentic-second-brain-reference.md +591 -0
  173. package/squads/squad-research/knowledge-base/ai-augmented-research.md +212 -0
  174. package/squads/squad-research/knowledge-base/brazilian-market-research-sources.md +197 -0
  175. package/squads/squad-research/knowledge-base/community-platforms-reference.md +786 -0
  176. package/squads/squad-research/knowledge-base/community-research-methods.md +194 -0
  177. package/squads/squad-research/knowledge-base/mixed-methods-research-design.md +168 -0
  178. package/squads/squad-research/knowledge-base/network-effects-analysis.md +192 -0
  179. package/squads/squad-research/knowledge-base/qualitative-research-deep-methods.md +202 -0
  180. package/squads/squad-research/knowledge-base/quantitative-research-methods.md +208 -0
  181. package/squads/squad-research/knowledge-base/research-frameworks-encyclopedia.md +40 -0
  182. package/squads/squad-research/knowledge-base/research-synthesis-frameworks.md +223 -0
  183. package/squads/squad-storytelling/knowledge-base/brand-mythology-framework.md +236 -0
  184. package/squads/squad-storytelling/knowledge-base/brazilian-storytelling-context.md +237 -0
  185. package/squads/squad-storytelling/knowledge-base/data-storytelling.md +232 -0
  186. package/squads/squad-storytelling/knowledge-base/improv-storytelling.md +226 -0
  187. package/squads/squad-storytelling/knowledge-base/persuasion-narrative-techniques.md +269 -0
  188. package/squads/squad-storytelling/knowledge-base/social-movement-narratives.md +191 -0
  189. package/squads/squad-storytelling/knowledge-base/video-storytelling.md +252 -0
  190. package/squads/claude-code-mastery/data/swarm-orchestration-patterns.yaml +0 -378
  191. package/squads/squad-animations/knowledge-base/framer-motion-complete-reference.md +0 -710
  192. package/squads/squad-animations/knowledge-base/web-animations-api-view-transitions.md +0 -478
@@ -0,0 +1,273 @@
1
+ # Compliance Frameworks Reference
2
+
3
+ ## Purpose
4
+
5
+ Deep reference for LGPD, ISO 27001, SOC 2, and PCI DSS — requirements, implementation guidance, and decision-making support. Used by Govern (compliance-officer) for gap assessments, policy work, and remediation planning.
6
+
7
+ ---
8
+
9
+ ## LGPD — Lei Geral de Proteção de Dados
10
+
11
+ ### Overview
12
+
13
+ - **Law:** Lei 13.709/2018
14
+ - **Effective:** August 2020
15
+ - **Enforced by:** ANPD (Autoridade Nacional de Proteção de Dados)
16
+ - **Scope:** Applies to any processing of personal data of individuals in Brazil, regardless of where the processor is located
17
+ - **Model:** Based heavily on EU GDPR but with Brazilian context
18
+
19
+ **Critical 2025 Update:** The ANPD became an **independent regulatory agency** in 2025 via Medida Provisória 1.317/2025, giving it full autonomy. This significantly increases enforcement capacity and risk of penalties.
20
+
21
+ ### LGPD vs. GDPR — Key Differences
22
+
23
+ | Aspect | LGPD | GDPR |
24
+ |--------|------|------|
25
+ | Data residency | Not explicitly required | Not explicitly required |
26
+ | International transfers | SCCs required (from Aug 2025) | SCCs or adequacy decision |
27
+ | DPO mandatory? | Yes (Encarregado) | Yes for certain controllers |
28
+ | Right to explanation (AI) | Article 20 | Article 22 |
29
+ | Penalties | Up to 2% of revenue in Brazil, max R$ 50M | Up to 4% of global revenue |
30
+ | Children's data | Article 14 — special protection | Article 8 GDPR |
31
+ | Legal age for consent | 18 (children need parental consent) | 16 (member state variation) |
32
+
33
+ ### Key Articles — Technical Implementation
34
+
35
+ | Article | Requirement | Technical Implementation |
36
+ |---------|-------------|------------------------|
37
+ | **Art. 7-8** | Lawful basis for processing — consent must be explicit | Opt-in forms (never pre-checked), granular consent per purpose |
38
+ | **Art. 9** | Transparency — inform data subjects | Privacy policy, accessible and plain language |
39
+ | **Art. 11** | Sensitive data special protection | Extra security controls for health, biometric, political, religious data |
40
+ | **Art. 14** | Children's data | Parental consent mechanism, age verification |
41
+ | **Art. 18** | Data subject rights | Portal: access, correction, deletion, portability, revoke consent |
42
+ | **Art. 20** | Automated decision-making | Ability to request human review of algorithmic decisions |
43
+ | **Art. 33** | International data transfers | SCCs required (grace period ended Aug 23, 2025) |
44
+ | **Art. 38** | RIPD (DPIA) | Data Protection Impact Assessment for high-risk processing |
45
+ | **Art. 41** | DPO (Encarregado) | Designate and publish contact; ANPD registration if required |
46
+ | **Art. 46** | Security measures | Encryption, access control, RLS, incident procedures |
47
+ | **Art. 48** | Breach notification | 3 business days to ANPD + data subjects |
48
+
49
+ ### LGPD Technical Checklist
50
+
51
+ ```
52
+ Consent Management
53
+ [ ] Opt-in forms with explicit, specific consent (not pre-checked)
54
+ [ ] Separate consent per processing purpose
55
+ [ ] Consent withdrawal mechanism as easy as giving consent
56
+ [ ] Consent records stored with timestamp and mechanism
57
+
58
+ Data Subject Rights Portal
59
+ [ ] Data export endpoint (download my data)
60
+ [ ] Data correction form or interface
61
+ [ ] Account/data deletion mechanism
62
+ [ ] Consent revocation mechanism
63
+ [ ] Response within 15 days (LGPD Art. 19)
64
+
65
+ DPO (Encarregado)
66
+ [ ] Designated DPO with name and contact published on website
67
+ [ ] DPO contactable for data subject requests
68
+ [ ] ANPD registration if organization qualifies
69
+
70
+ Technical Security (Art. 46)
71
+ [ ] TLS 1.2+ on all data transmission
72
+ [ ] Encryption at rest for personal data
73
+ [ ] Access control with least privilege
74
+ [ ] Audit logging for personal data access
75
+ [ ] RLS policies in database
76
+
77
+ Breach Response (Art. 48)
78
+ [ ] Incident detection capability
79
+ [ ] Breach notification procedure documented
80
+ [ ] ANPD contact and form known
81
+ [ ] Data subjects notification template ready
82
+ [ ] 3 business day timeline enforced
83
+
84
+ International Transfers (Art. 33, since Aug 2025)
85
+ [ ] Standard Contractual Clauses (SCCs) executed with all vendors
86
+ [ ] Data processing agreements with international processors
87
+ [ ] Transfer impact assessments for high-risk destinations
88
+ ```
89
+
90
+ ### ANPD Enforcement Priorities 2025-2026
91
+
92
+ Based on ANPD public statements:
93
+ 1. **Children's data** — apps used by minors, parental consent, age verification
94
+ 2. **AI and biometric data** — facial recognition, automated profiling
95
+ 3. **Data scraping** — web scraping of personal data without consent
96
+ 4. **Health data** — medical records, health apps
97
+
98
+ Organizations in these sectors should expect active inspections.
99
+
100
+ ---
101
+
102
+ ## ISO/IEC 27001:2022
103
+
104
+ ### Overview
105
+
106
+ - **Standard:** ISO/IEC 27001:2022 (latest revision — 93 controls vs. 114 in 2013 version)
107
+ - **Result:** Certification (audited by accredited certification body)
108
+ - **Scope:** Information Security Management System (ISMS)
109
+ - **Approach:** Risk-based — implement controls proportional to identified risks
110
+ - **Timeline:** 6-18 months for initial certification
111
+ - **Cost:** $30,000–$200,000+ depending on organization size
112
+
113
+ ### The 4 Control Themes (Annex A, 2022 revision)
114
+
115
+ | Theme | Controls | Coverage |
116
+ |-------|----------|---------|
117
+ | **Organizational** | 37 controls | Policies, risk management, supplier relationships, incident management |
118
+ | **People** | 8 controls | Screening, training, responsibilities, disciplinary process |
119
+ | **Physical** | 14 controls | Physical security, physical media, clean desk |
120
+ | **Technological** | 34 controls | Access control, cryptography, logging, vulnerability management |
121
+
122
+ ### ISO 27001 Clauses (Mandatory)
123
+
124
+ | Clause | Requirement |
125
+ |--------|-------------|
126
+ | **4** | Understanding the organization — context, interested parties, ISMS scope |
127
+ | **5** | Leadership — top management commitment, policies |
128
+ | **6** | Planning — risk assessment, risk treatment, objectives |
129
+ | **7** | Support — resources, competence, awareness, communication, documentation |
130
+ | **8** | Operation — risk treatment implementation, supplier assessment |
131
+ | **9** | Performance evaluation — monitoring, internal audit, management review |
132
+ | **10** | Improvement — nonconformities, corrective action, continual improvement |
133
+
134
+ ### New Controls in 2022 (not in 2013)
135
+
136
+ These 11 new controls reflect modern threats:
137
+ - Threat intelligence
138
+ - Information security for use of cloud services
139
+ - ICT readiness for business continuity
140
+ - Physical security monitoring
141
+ - Configuration management
142
+ - Information deletion
143
+ - Data masking
144
+ - Data leakage prevention
145
+ - Monitoring activities
146
+ - Web filtering
147
+ - Secure coding
148
+
149
+ ---
150
+
151
+ ## SOC 2 (Service Organization Controls 2)
152
+
153
+ ### Overview
154
+
155
+ - **Standard:** AICPA Trust Services Criteria
156
+ - **Result:** Attestation report (not certification)
157
+ - **Scope:** Controls relevant to security, availability, processing integrity, confidentiality, privacy of service organizations
158
+ - **Timeline:** Type I: 2-3 months | Type II: 6-12 months (observation period)
159
+ - **Cost:** $20,000–$100,000+
160
+
161
+ ### Type I vs. Type II
162
+
163
+ | Aspect | Type I | Type II |
164
+ |--------|--------|---------|
165
+ | What it says | Controls are suitably designed at a point in time | Controls operated effectively over a period (usually 6+ months) |
166
+ | Timeline | 2-3 months | 6-12 months (observation period required) |
167
+ | Value | Faster to achieve, good starting point | Higher assurance, preferred by enterprise buyers |
168
+ | When to get | Startup needing to close first enterprise deals | Established product with running controls |
169
+
170
+ ### The 5 Trust Service Criteria
171
+
172
+ | Criterion | Abbreviation | Scope |
173
+ |-----------|-------------|-------|
174
+ | **Security** | CC (Common Criteria) | The baseline — every SOC 2 includes this |
175
+ | **Availability** | A | System available for operation as committed |
176
+ | **Processing Integrity** | PI | System processing is complete, accurate, timely |
177
+ | **Confidentiality** | C | Information designated as confidential is protected |
178
+ | **Privacy** | P | Personal information collected in accordance with privacy commitments |
179
+
180
+ Most SaaS startups pursue Security + Availability + Confidentiality initially.
181
+
182
+ ### SOC 2 Common Criteria — Technical Controls
183
+
184
+ Key CC categories with technical implementation:
185
+
186
+ | CC Category | Examples of Evidence Needed |
187
+ |-------------|--------------------------|
188
+ | **CC6 — Logical and Physical Access** | MFA, access reviews, offboarding procedures, privileged access management |
189
+ | **CC7 — System Operations** | Monitoring, alert management, incident response, change management |
190
+ | **CC8 — Change Management** | Code review process, deployment approvals, environment separation |
191
+ | **CC9 — Risk Mitigation** | Vendor management, business continuity, encryption at rest and transit |
192
+
193
+ ---
194
+
195
+ ## PCI DSS v4.0
196
+
197
+ ### Overview
198
+
199
+ - **Standard:** Payment Card Industry Data Security Standard v4.0
200
+ - **Effective:** March 2024 (v3.2.1 retired March 2024)
201
+ - **Scope:** Any organization that stores, processes, or transmits cardholder data
202
+ - **Managed by:** PCI Security Standards Council
203
+ - **Validation levels:** SAQ (Self-Assessment) for smaller merchants, QSA audit for larger
204
+
205
+ ### 12 Requirements in 6 Goals
206
+
207
+ | Goal | Requirements |
208
+ |------|-------------|
209
+ | **Build and Maintain Secure Network** | R1: Firewalls; R2: No vendor defaults |
210
+ | **Protect Cardholder Data** | R3: Store data securely; R4: Encrypt transmission |
211
+ | **Vulnerability Management** | R5: Anti-malware; R6: Secure systems |
212
+ | **Access Control** | R7: Restrict access; R8: Identify and authenticate; R9: Physical access |
213
+ | **Monitor and Test** | R10: Log all access; R11: Test regularly |
214
+ | **Information Security Policy** | R12: Maintain policy |
215
+
216
+ ### Scope Reduction Strategy
217
+
218
+ **Use a tokenization/hosted payment page to minimize scope:**
219
+ ```
220
+ In scope (if you collect card data directly):
221
+ - All systems that process, store, or transmit card data
222
+ - All systems in the same network segment
223
+ - All administration systems for above
224
+
225
+ Minimal scope (using hosted payment fields / tokenization):
226
+ - Only your tokenization provider integration
227
+ - SAQ A is sufficient (lowest level — just questionnaire)
228
+ ```
229
+
230
+ **Recommended approach for most web apps:** Use Stripe, Braintree, or Adyen hosted payment fields. Card data never touches your servers. Scope reduces to SAQ A.
231
+
232
+ ---
233
+
234
+ ## Compliance Comparison Matrix
235
+
236
+ | Aspect | LGPD | ISO 27001 | SOC 2 | PCI DSS |
237
+ |--------|------|-----------|-------|---------|
238
+ | **Focus** | Privacy | InfoSec management | Trust for service orgs | Payment card security |
239
+ | **Result** | Compliance (legal) | Certification | Attestation report | Certificate/Report |
240
+ | **Mandatory for** | Brazilian personal data | Voluntary (market-driven) | Enterprise B2B customers | Card processing |
241
+ | **Geographic focus** | Brazil | Global | North America primary | Global |
242
+ | **Timeline** | Ongoing | 6-18 months | 2-12 months | Variable |
243
+ | **Overlap with others** | ~40% with GDPR | ~70% with SOC 2 | ~70% with ISO 27001 | — |
244
+
245
+ ### When to Pursue Which
246
+
247
+ | Situation | Recommendation |
248
+ |-----------|---------------|
249
+ | Any Brazilian personal data | LGPD is mandatory — not optional |
250
+ | Selling B2B SaaS to US companies | SOC 2 Type I first — reduces friction in deals |
251
+ | Selling globally or to European enterprises | ISO 27001 — globally recognized |
252
+ | Processing payments | PCI DSS scope reduction (tokenization), then SAQ A |
253
+ | Early-stage startup | Start with LGPD + SOC 2 Type I |
254
+ | Scaling to enterprise | Add ISO 27001, then SOC 2 Type II |
255
+
256
+ ### Overlap Efficiency
257
+
258
+ ISO 27001 and SOC 2 have ~70% control overlap. Pursuing both simultaneously is ~30% more efficient than sequential implementation:
259
+ - Same policies serve both
260
+ - Same control evidence collected once
261
+ - Same training program covers both
262
+ - Auditors can often share work product
263
+
264
+ ---
265
+
266
+ ## Sources
267
+
268
+ - LGPD full text: http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2018/lei/l13709.htm
269
+ - ANPD official: https://www.gov.br/anpd/pt-br
270
+ - ISO 27001:2022: https://www.iso.org/standard/27001
271
+ - AICPA SOC 2: https://www.aicpa-cima.com/resources/article/soc-2-engagements
272
+ - PCI DSS v4.0: https://www.pcisecuritystandards.org/
273
+ - ICLG Brazil Data Protection 2025-2026: https://iclg.com/practice-areas/data-protection-laws-and-regulations/brazil
@@ -0,0 +1,438 @@
1
+ # Database Security Reference
2
+
3
+ ## Purpose
4
+
5
+ Comprehensive reference for database security — RLS, parameterized queries, encryption, audit logging, and Supabase-specific patterns. Used across all squad agents, particularly when reviewing or implementing data access controls.
6
+
7
+ ---
8
+
9
+ ## Row Level Security (RLS)
10
+
11
+ ### Why RLS Is Non-Negotiable
12
+
13
+ RLS is the most critical security control for any Supabase-based application. In January 2025, 170+ applications built with Lovable were found with exposed databases (CVE-2025-48757) because developers did not enable RLS. **RLS is the difference between a secure app and a data breach.**
14
+
15
+ ### RLS Fundamentals
16
+
17
+ ```sql
18
+ -- Enable RLS on a table
19
+ ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
20
+
21
+ -- CRITICAL: Without policies, NOBODY can access data (deny-all by default)
22
+ -- You must create explicit policies for access
23
+
24
+ -- Check which tables have RLS enabled
25
+ SELECT tablename, rowsecurity
26
+ FROM pg_tables
27
+ WHERE schemaname = 'public';
28
+
29
+ -- Find tables WITHOUT RLS (pre-deploy gate -- any result = blocker)
30
+ SELECT tablename FROM pg_tables
31
+ WHERE schemaname = 'public' AND NOT rowsecurity;
32
+ ```
33
+
34
+ ### Core RLS Patterns
35
+
36
+ ```sql
37
+ -- Pattern 1: Users see only their own data
38
+ CREATE POLICY "users_own_data" ON profiles
39
+ FOR SELECT TO authenticated
40
+ USING ((SELECT auth.uid()) = user_id);
41
+
42
+ -- Pattern 2: Users manage only their own data (all operations)
43
+ CREATE POLICY "users_manage_own" ON profiles
44
+ FOR ALL TO authenticated
45
+ USING ((SELECT auth.uid()) = user_id)
46
+ WITH CHECK ((SELECT auth.uid()) = user_id);
47
+
48
+ -- Pattern 3: Publicly visible data (e.g., published posts)
49
+ CREATE POLICY "public_published_posts" ON posts
50
+ FOR SELECT
51
+ USING (published = true);
52
+
53
+ -- Pattern 4: Multi-tenant isolation (org-level)
54
+ CREATE POLICY "tenant_isolation" ON orders
55
+ FOR ALL TO authenticated
56
+ USING (
57
+ org_id IN (
58
+ SELECT org_id FROM org_members
59
+ WHERE user_id = (SELECT auth.uid())
60
+ )
61
+ );
62
+
63
+ -- Pattern 5: Role-based access (admin can see all)
64
+ CREATE POLICY "admin_full_access" ON profiles
65
+ FOR ALL TO authenticated
66
+ USING (
67
+ (SELECT auth.jwt() -> 'app_metadata' ->> 'role') = 'admin'
68
+ );
69
+
70
+ -- Pattern 6: Read for anyone, write only for owner
71
+ CREATE POLICY "anyone_can_read" ON articles
72
+ FOR SELECT
73
+ USING (true);
74
+
75
+ CREATE POLICY "owner_can_write" ON articles
76
+ FOR INSERT OR UPDATE OR DELETE TO authenticated
77
+ USING (author_id = (SELECT auth.uid()))
78
+ WITH CHECK (author_id = (SELECT auth.uid()));
79
+ ```
80
+
81
+ ### RLS Performance Optimization
82
+
83
+ | Technique | Performance Gain | Implementation |
84
+ |-----------|-----------------|----------------|
85
+ | Index policy columns | 99.94% | `CREATE INDEX idx_user ON table(user_id)` |
86
+ | Wrap functions in SELECT | 94.97% | `(SELECT auth.uid()) = user_id` not `auth.uid() = user_id` |
87
+ | Explicit role in FOR clause | 99.78% | `FOR SELECT TO authenticated` |
88
+ | Subquery vs JOIN in policies | 99.78% | Use `IN (SELECT ...)` not JOIN |
89
+ | Security definer functions | 99.993% | Cached auth lookups |
90
+
91
+ ```sql
92
+ -- SLOW: Function evaluated per row
93
+ USING (auth.uid() = user_id)
94
+
95
+ -- FAST: Function evaluated once, cached for all rows (up to 95% faster)
96
+ USING ((SELECT auth.uid()) = user_id)
97
+ ```
98
+
99
+ ### RLS Testing Patterns
100
+
101
+ **Critical:** The Supabase SQL Editor bypasses RLS. Always test via the SDK as a regular user.
102
+
103
+ ```typescript
104
+ // Test RLS via SDK -- this respects policies
105
+ const supabase = createClient(url, anonKey)
106
+
107
+ // Login as test user
108
+ const { data: { session } } = await supabase.auth.signInWithPassword({
109
+ email: 'testuser@example.com',
110
+ // Use environment variable -- never hardcode credentials
111
+ password: process.env.TEST_USER_PASSWORD
112
+ })
113
+
114
+ // This will be filtered by RLS -- should only return this user's rows
115
+ const { data, error } = await supabase.from('profiles').select('*')
116
+ console.log('User sees:', data) // Should only see own data
117
+
118
+ // Try accessing another user's data directly
119
+ const { data: otherData } = await supabase
120
+ .from('profiles')
121
+ .select('*')
122
+ .eq('user_id', 'other-user-uuid')
123
+ console.log('Should be empty:', otherData) // RLS should block this
124
+ ```
125
+
126
+ ### Views and RLS
127
+
128
+ Views bypass RLS by default in PostgreSQL 14 and below. In PostgreSQL 15+:
129
+
130
+ ```sql
131
+ -- PostgreSQL 15+ -- force view to respect RLS
132
+ CREATE VIEW active_profiles WITH (security_invoker = true)
133
+ AS SELECT * FROM profiles WHERE deleted_at IS NULL;
134
+
135
+ -- Or use security_barrier for older PG versions
136
+ CREATE VIEW user_profiles WITH (security_barrier = true)
137
+ AS SELECT id, name, email FROM profiles;
138
+ ```
139
+
140
+ ---
141
+
142
+ ## SQL Injection Prevention
143
+
144
+ ### Parameterized Queries — Always
145
+
146
+ ```javascript
147
+ // FORBIDDEN: String interpolation -- enables SQL injection
148
+ const dangerous = `SELECT * FROM users WHERE name = '${userInput}'`
149
+
150
+ // REQUIRED: Parameterized queries -- injection impossible
151
+ const safe = 'SELECT * FROM users WHERE name = $1'
152
+ const result = await db.query(safe, [userInput])
153
+
154
+ // Supabase: always safe -- PostgREST is parameterized
155
+ const { data } = await supabase.from('users').select('*').eq('name', userInput)
156
+
157
+ // pg (node-postgres): safe
158
+ const { rows } = await pool.query(
159
+ 'SELECT * FROM users WHERE email = $1 AND active = $2',
160
+ [email, true]
161
+ )
162
+
163
+ // Prisma: safe
164
+ const user = await prisma.user.findFirst({
165
+ where: { email: email }
166
+ })
167
+ ```
168
+
169
+ ### Dynamic Queries — Safe Pattern
170
+
171
+ When query structure must be dynamic, use identifier escaping:
172
+
173
+ ```javascript
174
+ // For dynamic table/column names (rare -- prefer static)
175
+ const { Client } = require('pg')
176
+ const client = new Client()
177
+
178
+ // NEVER: `SELECT * FROM ${tableName}` -- SQL injection
179
+ // SAFE: Use pg's identifier escaping
180
+ const safeQuery = `SELECT * FROM ${client.escapeIdentifier(tableName)}`
181
+ ```
182
+
183
+ ### Stored Procedures — Secure Pattern
184
+
185
+ ```sql
186
+ -- SAFE: Function uses parameterized query internally
187
+ CREATE OR REPLACE FUNCTION get_user_data(p_user_id UUID)
188
+ RETURNS TABLE(id UUID, name TEXT)
189
+ SECURITY DEFINER
190
+ SET search_path = public
191
+ LANGUAGE plpgsql AS $$
192
+ BEGIN
193
+ RETURN QUERY
194
+ SELECT u.id, u.name FROM users u WHERE u.id = p_user_id;
195
+ END;
196
+ $$;
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Encryption
202
+
203
+ ### Encryption at Rest
204
+
205
+ **PostgreSQL column-level encryption (pgcrypto):**
206
+ ```sql
207
+ -- Enable pgcrypto extension
208
+ CREATE EXTENSION IF NOT EXISTS pgcrypto;
209
+
210
+ -- Encryption key comes from app setting (set via environment, not hardcoded)
211
+ -- In app startup: SET app.encryption_key = '<value from secrets manager>'
212
+
213
+ -- Encrypt sensitive data before storing
214
+ INSERT INTO sensitive_data (user_id, ssn_encrypted)
215
+ VALUES (
216
+ $1,
217
+ pgp_sym_encrypt($2, current_setting('app.encryption_key'))
218
+ );
219
+
220
+ -- Decrypt when reading
221
+ SELECT
222
+ user_id,
223
+ pgp_sym_decrypt(ssn_encrypted::bytea, current_setting('app.encryption_key')) AS ssn
224
+ FROM sensitive_data
225
+ WHERE user_id = $1;
226
+ ```
227
+
228
+ **Supabase Vault — preferred for secrets:**
229
+ ```sql
230
+ -- Store secret in Vault (key_name must be descriptive, value from env/secrets manager)
231
+ SELECT vault.create_secret(
232
+ '<secret-value-from-env>', -- Use env var -- never hardcode
233
+ 'api_key_name',
234
+ 'Description of what this key is for'
235
+ );
236
+
237
+ -- Read secret (decrypted on the fly)
238
+ SELECT decrypted_secret FROM vault.decrypted_secrets WHERE name = 'api_key_name';
239
+
240
+ -- CRITICAL: Disable statement logging before inserting secrets
241
+ -- Otherwise plaintext appears in Supabase logs
242
+ ALTER SYSTEM SET log_statement = 'none';
243
+ SELECT pg_reload_conf();
244
+ -- Insert secret here
245
+ -- Re-enable
246
+ ALTER SYSTEM SET log_statement = 'all';
247
+ SELECT pg_reload_conf();
248
+ ```
249
+
250
+ ### Encryption in Transit
251
+
252
+ ```sql
253
+ -- Force SSL for all direct connections
254
+ ALTER SYSTEM SET ssl = on;
255
+ ALTER SYSTEM SET ssl_min_protocol_version = 'TLSv1.2';
256
+
257
+ -- Check current SSL status
258
+ SHOW ssl;
259
+ SELECT * FROM pg_stat_ssl;
260
+
261
+ -- Verify client is using SSL
262
+ SELECT pid, usename, ssl, version, cipher
263
+ FROM pg_stat_ssl
264
+ JOIN pg_stat_activity ON pg_stat_ssl.pid = pg_stat_activity.pid;
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Database Access Control
270
+
271
+ ### Least Privilege Roles
272
+
273
+ ```sql
274
+ -- Application read-only role
275
+ CREATE ROLE app_readonly;
276
+ GRANT CONNECT ON DATABASE myapp TO app_readonly;
277
+ GRANT USAGE ON SCHEMA public TO app_readonly;
278
+ GRANT SELECT ON ALL TABLES IN SCHEMA public TO app_readonly;
279
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO app_readonly;
280
+
281
+ -- Application read-write role (no DDL)
282
+ CREATE ROLE app_readwrite;
283
+ GRANT CONNECT ON DATABASE myapp TO app_readwrite;
284
+ GRANT USAGE ON SCHEMA public TO app_readwrite;
285
+ GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO app_readwrite;
286
+ GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO app_readwrite;
287
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public
288
+ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO app_readwrite;
289
+
290
+ -- Migration role (DDL allowed -- rotate credentials after migrations)
291
+ CREATE ROLE app_migrations;
292
+ GRANT ALL ON DATABASE myapp TO app_migrations;
293
+ ```
294
+
295
+ ### Supabase Key Management
296
+
297
+ | Key | Where to Use | Security Level |
298
+ |-----|-------------|---------------|
299
+ | `anon` (publishable) | Frontend/client code | Respects RLS -- safe to expose |
300
+ | `service_role` | Backend server only | Bypasses ALL RLS -- never expose to client |
301
+ | Direct DB connection string | Migrations only | Highest privilege -- use secrets manager |
302
+
303
+ ```typescript
304
+ // WRONG: service_role in frontend (bypasses RLS entirely)
305
+ // NEVER: createClient(url, process.env.SUPABASE_SERVICE_ROLE_KEY) in browser code
306
+
307
+ // RIGHT: anon key in frontend, service_role only on server
308
+ // Frontend -- uses anon key via environment variable
309
+ const clientSupabase = createClient(
310
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
311
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
312
+ )
313
+
314
+ // Server/API routes only -- service role from non-public env
315
+ const adminSupabase = createClient(
316
+ process.env.SUPABASE_URL!,
317
+ process.env.SUPABASE_SERVICE_ROLE_KEY! // NOT prefixed with NEXT_PUBLIC_
318
+ )
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Audit Logging
324
+
325
+ ### Automatic Audit Log with Triggers
326
+
327
+ ```sql
328
+ -- Audit log table
329
+ CREATE TABLE audit_log (
330
+ id BIGSERIAL PRIMARY KEY,
331
+ table_name TEXT NOT NULL,
332
+ record_id UUID NOT NULL,
333
+ action TEXT CHECK (action IN ('INSERT', 'UPDATE', 'DELETE')),
334
+ old_data JSONB,
335
+ new_data JSONB,
336
+ changed_by UUID REFERENCES auth.users(id),
337
+ changed_at TIMESTAMPTZ DEFAULT now(),
338
+ ip_address INET,
339
+ user_agent TEXT
340
+ );
341
+
342
+ -- Generic trigger function
343
+ CREATE OR REPLACE FUNCTION audit_trigger_func()
344
+ RETURNS TRIGGER AS $$
345
+ BEGIN
346
+ INSERT INTO audit_log (table_name, record_id, action, old_data, new_data, changed_by)
347
+ VALUES (
348
+ TG_TABLE_NAME,
349
+ COALESCE(NEW.id, OLD.id),
350
+ TG_OP,
351
+ CASE WHEN TG_OP IN ('UPDATE', 'DELETE') THEN row_to_json(OLD)::jsonb END,
352
+ CASE WHEN TG_OP IN ('INSERT', 'UPDATE') THEN row_to_json(NEW)::jsonb END,
353
+ auth.uid()
354
+ );
355
+ RETURN COALESCE(NEW, OLD);
356
+ END;
357
+ $$ LANGUAGE plpgsql SECURITY DEFINER;
358
+
359
+ -- Apply to sensitive tables
360
+ CREATE TRIGGER audit_profiles
361
+ AFTER INSERT OR UPDATE OR DELETE ON profiles
362
+ FOR EACH ROW EXECUTE FUNCTION audit_trigger_func();
363
+
364
+ CREATE TRIGGER audit_transactions
365
+ AFTER INSERT OR UPDATE OR DELETE ON financial_transactions
366
+ FOR EACH ROW EXECUTE FUNCTION audit_trigger_func();
367
+ ```
368
+
369
+ ### RLS on Audit Log
370
+
371
+ ```sql
372
+ -- Only admins can see the full audit log
373
+ ALTER TABLE audit_log ENABLE ROW LEVEL SECURITY;
374
+
375
+ CREATE POLICY "admin_see_all_audit"
376
+ ON audit_log
377
+ FOR SELECT TO authenticated
378
+ USING (
379
+ (SELECT auth.jwt() -> 'app_metadata' ->> 'role') = 'admin'
380
+ );
381
+
382
+ -- Users can only see their own audit entries
383
+ CREATE POLICY "users_see_own_audit"
384
+ ON audit_log
385
+ FOR SELECT TO authenticated
386
+ USING (changed_by = (SELECT auth.uid()));
387
+ ```
388
+
389
+ ---
390
+
391
+ ## Common Database Security Misconfigurations
392
+
393
+ | Misconfiguration | Risk | Fix |
394
+ |----------------|------|-----|
395
+ | Table with no RLS enabled | Anyone can read all data via API | `ALTER TABLE t ENABLE ROW LEVEL SECURITY` |
396
+ | service_role key in frontend | Full database bypass | Move to server-side only |
397
+ | SQL string concatenation | SQL injection | Use parameterized queries |
398
+ | No SSL enforcement | Data in transit interceptable | Set `ssl_min_protocol_version = 'TLSv1.2'` |
399
+ | Superuser app credentials | Privilege escalation trivial | Create least-privilege role |
400
+ | No connection limits | Connection exhaustion DoS | Set `connection_limit` on roles |
401
+ | Unencrypted sensitive columns | Data breach exposes plaintext | pgcrypto or Vault |
402
+ | Public schema grants to public | PostgreSQL 14 default allows all public | `REVOKE ALL ON SCHEMA public FROM public` |
403
+ | Statement logging enabled with secrets | Secrets in logs | Disable before inserting secrets |
404
+
405
+ ---
406
+
407
+ ## Pre-Deploy Database Security Gate
408
+
409
+ ```sql
410
+ -- Run this before every production deployment
411
+ -- Any row returned = BLOCKER
412
+
413
+ -- 1. Tables without RLS
414
+ SELECT 'TABLE_NO_RLS' as issue, tablename
415
+ FROM pg_tables
416
+ WHERE schemaname = 'public' AND NOT rowsecurity;
417
+
418
+ -- 2. Overprivileged connections check
419
+ SELECT 'SUPERUSER_APP' as issue, usename
420
+ FROM pg_user
421
+ WHERE usesuper = true AND usename != 'postgres';
422
+
423
+ -- 3. Tables with no policies (RLS on but no policies = deny all)
424
+ SELECT 'TABLE_NO_POLICIES' as issue, t.tablename
425
+ FROM pg_tables t
426
+ LEFT JOIN pg_policies p ON p.tablename = t.tablename AND p.schemaname = t.schemaname
427
+ WHERE t.schemaname = 'public' AND t.rowsecurity = true AND p.policyname IS NULL;
428
+ ```
429
+
430
+ ---
431
+
432
+ ## Sources
433
+
434
+ - Supabase RLS Documentation: https://supabase.com/docs/guides/database/postgres/row-level-security
435
+ - Supabase Security Best Practices: https://supabase.com/docs/guides/security
436
+ - CVE-2025-48757 (Lovable/RLS): https://nvd.nist.gov/vuln/detail/CVE-2025-48757
437
+ - OWASP SQL Injection Prevention: https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
438
+ - PostgreSQL Security Documentation: https://www.postgresql.org/docs/current/security.html