您的 Supabase 是公开的。
Your Supabase Is Public

原始链接: https://skilldeliver.com/your-supabase-is-public

一位开发者发现Supabase构建的应用程序中存在反复出现的安全漏洞:数据库公开暴露。他只需检查网站代码,就反复发现Supabase API密钥允许完全访问用户数据——包括用户名、电子邮件,甚至密码哈希——通过简单的`curl`请求即可实现。 问题在于开发者创建面向公众的用户表,*却没有*实施行级安全(RLS),从而将公共API密钥变成了主密钥。开发者承认用户技能起作用,但他认为像Supabase这样的平台可以在创建用户表时提供更清晰的警告,或者像Pocketbase那样实施默认安全措施,从而主动防止这种情况发生。 鉴于像Lovable这样的平台每天都有大量的项目创建量(10万+),暴露数据库的潜在规模令人担忧,引发了关于平台责任引导开发者进行安全配置的问题。

## Supabase 安全问题:摘要 最近的 Hacker News 讨论强调了 Supabase 的一个潜在安全问题:如果禁用行级别安全 (RLS),数据库很容易被暴露。虽然 Supabase 默认 RLS 处于开启状态,但禁用它会产生警告,作者认为创建公开访问的数据却出奇地容易。 许多评论者不同意,认为 Supabase 会主动提示用户启用 RLS,并且不安全性需要用户刻意操作。争论的中心在于 Supabase 的设计是否固有地鼓励不安全的配置,特别是与 PocketBase 等替代方案相比。 一个关键点是“氛围编码”工具(如 Lovable)的兴起,它们生成应用程序时缺乏强大的安全意识,可能导致非技术用户创建易受攻击的设置。另一些人指出 RLS 本身的复杂性是安全实施的障碍。最终,讨论强调了理解安全最佳实践的重要性,无论使用哪个平台,并突出了 Supabase 在易用性和强大安全性之间的平衡。
相关文章

原文

I was chatting with a close friend of mine and he sent me a link to his new SaaS that he's developing. Of course when a friend sends me their new project my natural tendency is to try hack it.

First simple step: inspecting, checking if there's something interesting.

Supabase credentials exposed in network inspector

Voila, there is. A Supabase URL and anon key.

What makes it particularly easy is when they're using Supabase. It's so common from my side that every time I get access to a Supabase anon key just from inspecting the website and doing a simple curl request to check the tables everything is always unprotected and I get access to the whole database.

This is the third time I've discovered this and one of them was a seed stage startup 💀

With this endpoint you can fetch the OpenAPI schema to see what's exposed:

curl -X GET \
  'https://your-project.supabase.co/rest/v1/?apikey=your-anon-key' \
  -H "Accept: application/openapi+json"

But the schema itself isn't that interesting. The interesting part is checking if they've created a users table and have an endpoint for it. And in my case it was something like this:

curl -X GET \
  'https://your-project.supabase.co/rest/v1/users' \
  -H "apikey: your-anon-key" \
  -H "Authorization: Bearer your-anon-key"

And if you're lucky (which happens way too often) this returns a nice JSON with all the users names, nicknames, emails, passwords hashes and whatever else they decided to store.

I've never used Supabase for a production app but I think what's happening is people are creating additional public users tables and not setting proper RLS for them. The anon key is designed to be public but if you are not careful that anon key becomes a master key to your entire database.

I'm not going to blame the vibe-coding wave entirely. Maybe I'll put the blame on Supabase instead? Maybe it can be simple if check if they create users table there should be a massive red warning popup explaining that everything in this table will be public unless RLS is enabled.

Supabase RLS warning

And in the spirit of Lovable announcing their $330 million Series B and knowing they also use Supabase. I'm starting to wonder what percentage of users actually make this mistake. With over 100,000 projects being created daily on platforms like Lovable, how many of those have exposed databases?

Again, you can take the stance that this is a skill issue on the users part but I'm not sure about that. You can design a system in a way that prevents this type of stuff from happening.

As an example Pocketbase handles this much better. It has a default _pb_users_auth_ collection that you can easily extend with new fields, and most importantly, it has default proper access control checks like id = @request.auth.id already configured. You literally have to go out of your way to make it insecure.

Pocketbase default access control

So I guess here the place where I need to say something smart or LLM generated conclusion - but I don't have. Merry Christmas! 🎄

联系我们 contact @ memedata.com