Live data from Hacker News

Supabase MCP can leak your entire SQL database

generalanalysis.com

111–120 of 502 posts

Re: Supabase MCP can leak your entire SQL database

#111
post #29
post #27

Earlier quoted context omitted.

Yes, I know it was an example, I was just running with it because it's a convenient example. My point is that we've known for a couple decades at least that letting user input touch your production, unfiltered and unsanitized, is bad. The same concept as SQL exists with user-generated AI input. Sanitize input, map input to known/approved outputs, robust security boundaries, etc. Yet, for some reason, every week there…

But how can you sanitize text? That's what makes this stuff hard: the previous lessons we have learned about web application security don't entirely match up to how LLMs work. If you show me an app with a SQL injection hole or XSS hole, I know how to fix it. If your app has a prompt injection hole, the answer may turn out to be "your app is fundamentally insecure and cannot be built safely". Nobody wants to hear that…

Interesting!

But, in the CaMel proposal example, what prevents malicious instructions in the un-trusted content returning an email address that is in the trusted contacts list, but is not the correct one?

This situation is less concerning, yes, but generally, how would you prevent instructions that attempt to reduce the accuracy of parsing, for example, while not actually doing anything catastrophic

Re: Supabase MCP can leak your entire SQL database

#112
post #13

Earlier quoted context omitted.

Isn't the fix exactly the same? Have the LLM map the request to a preset list of approved queries.

The original problem is Output = LLM(UntrustedInput); What you're suggesting is "TrustedInput" = LLM(UntrustedInput); Output = LLM("TrustedInput"); But ultimately this just pulls the issue up a level, if that.

You believe sanitized, parameterized queries are safe, right? This works the same way. The AIs job is to select the query, which is a simple classification task. What gets executed is hard coded by you, modulo the sanitized arguments.

And don't forget to set the permissions.

Re: Supabase MCP can leak your entire SQL database

#113
post #43

Supabase engineer here working on MCP. A few weeks ago we added the following mitigations to help with prompt injections: - Encourage folks to use read-only by default in our docs [1] - Wrap all SQL responses with prompting that discourages the LLM from following instructions/commands injected within user data [2] - Write E2E tests to confirm that even less capable LLMs don't fall for the attack [2] We noticed that t…

[deleted]

Re: Supabase MCP can leak your entire SQL database

#114
post #43

Supabase engineer here working on MCP. A few weeks ago we added the following mitigations to help with prompt injections: - Encourage folks to use read-only by default in our docs [1] - Wrap all SQL responses with prompting that discourages the LLM from following instructions/commands injected within user data [2] - Write E2E tests to confirm that even less capable LLMs don't fall for the attack [2] We noticed that t…

> Wrap all SQL responses with prompting that discourages the LLM from following instructions/commands injected within user data [2] I genuinely cannot tell if this is a joke? This must not be possible by design, not “discouraged”. This comment alone, if serious, should mean that anyone using your product should look for alternatives immediately.

Here's a tool you can install that grants your LLM access to . The whole point of the tool is to access and would be worthless without it. We tricked the LLM you gave access to into giving us that data by asking it nicely for it because you installed that interleaves untrusted attacker-supplied text into your LLMs text stream and provides a ready-made means of transmitting the data back to somewhere the attacker can access.

This really isn't the fault of the Supabase MCP, the fact that they're bothering to do anything is going above and beyond. We're going to see a lot more people discovering the hard way just how extremely high trust MCP tools are.

Re: Supabase MCP can leak your entire SQL database

#115
post #71

Earlier quoted context omitted.

Untrusted user input can be escaped if you _must_ eval (however ill-advised), depending on your language (look no further than shell escaping...). There is a set of rules you can apply to guarantee untrusted input will be stringified and not run as code. They may be fiddly, and you may wish to outsource them to a battle-tested library, but they _do_ exist. Nothing exists like this for an LLM.

Which doesn’t make any sense. Why can’t we have escaping for prompts? Because it’s not “natural”?

Prompts don't have a syntax in the first place, so how could you "escape" anything? They're just an arbitrary sequence of tokens that you hope will bias the model sufficiently toward some useful output.

Re: Supabase MCP can leak your entire SQL database

#116
post #96

Earlier quoted context omitted.

Which doesn’t make any sense. Why can’t we have escaping for prompts? Because it’s not “natural”?

We don't have escaping for eval! There's a whole literature in the web security field for why that approach is cursed!

Heh - I hope I didn't suggest that you _should_ use eval in production. It's a catastrophically bad idea due to the unchecked power.

You do raise a good point that this is effectively eval, but I would also imagine that no developer is running `SELECT username FROM users LIMIT 1 |xargs "bash -c"`, either, even on their local machine.

Re: Supabase MCP can leak your entire SQL database

#117
post #71

Earlier quoted context omitted.

Untrusted user input can be escaped if you _must_ eval (however ill-advised), depending on your language (look no further than shell escaping...). There is a set of rules you can apply to guarantee untrusted input will be stringified and not run as code. They may be fiddly, and you may wish to outsource them to a battle-tested library, but they _do_ exist. Nothing exists like this for an LLM.

Which doesn’t make any sense. Why can’t we have escaping for prompts? Because it’s not “natural”?

I'll be honest -- I'm not sure. I don't fully understand LLMs enough to give a decisive answer. My cop-out answer would be "non-determinism", but I would love a more complete one.

Re: Supabase MCP can leak your entire SQL database

#118
post #95
post #80

Earlier quoted context omitted.

Right: The LLM is an engine for taking an arbitrary document and making a plausibly-longer document. There is no intrinsic/reliable difference between any part of the document and any other part. Everything else—like a "conversation"—is stage-trickery and writing tools to parse the output.

Yes. "Writing tools to parse the output" is the work, like in any application connecting untrusted data to trusted code. I think people maybe are getting hung up on the idea that you can neutralize HTML content with output filtering and then safely handle it, and you can't do that with LLM inputs. But I'm not talking about simply rendering a string; I'm talking about passing a string to eval(). The equivalent, then,…

Where would you insert the second LLM to mitigate the problem in OP? I don't see where you would.

Re: Supabase MCP can leak your entire SQL database

#119
post #110
post #88

Earlier quoted context omitted.

Co-founder of General Analysis here. Technically this is not a responsibility of Supabase MCP - this vulnerability is a combination of: 1. Unsanitized data included in agent context 2. Foundation models being unable to distinguish instructions and data 3. Bad access scoping (cursor having too much access) This vulnerability can be found almost everywhere in common MCP use patterns. We are working on guardrails for MC…

In the non-AI world, a database server mostly always just executes any query you give it to, assuming right permissions. They are not responsible only in the way they wouldn't be responsible for an application-level sql injection vulnerability. But that's not to say that they wouldn't be capable of adding safeguards on their end, not even on their MCP layer. Adding policies and narrowing access to whatever comes thro…

> But that's not to say that they wouldn't be capable of adding safeguards on their end, not even on their MCP layer. Adding policies and narrowing access to whatever comes through MCP to the server and so on would be more assuring measures than what their comment here suggest around more prompting.

This is certainly prudent advice, and why I found the GA example support application to be a bit simplistic. I think a more realistic database application in Supabase or on any other platform would take advantage of multiple roles, privileges, Row Level Security, and other affordances within the database to provide invariants and security guarantees.

Re: Supabase MCP can leak your entire SQL database

#120
post #96

Earlier quoted context omitted.

We don't have escaping for eval! There's a whole literature in the web security field for why that approach is cursed!

Fair enough but how did we not learn from that fiasco? We have escaping for every other protocol and interface since.

> Fair enough but how did we not learn from that fiasco?

We certainly have and that's why so many people are saying that prompt injection is a problem. That can be done with HTML injection because you know that someone will try to include the string "" so you can escape the first " tag. There is no such thing to escape with prompts. The browser is expecting a certain content structure that an LLM just isn't.

It might help to think about the inputs that go into the LLM: it's just a bunch of tokens. It is literally never anything else. Even after it generates the next token, that is just added to the current tokens and passed through again. You might define a token for your LLM but then an attacker could just type that out themselves and you probably just made things easier for them. As it is, there is no way for current LLM architectures to distinguish user tokens from non-user tokens, nor from generated tokens.

Post reply on HN