4 ms·
> Programmers are fairly well trained in SQL injection [...] My first (naive) reaction was “oh, I’ll just filter for content like ‘ignore previous instructions’
by ptx 3y ago
> Programmers are fairly well trained in SQL injection [...] My first (naive) reaction was “oh, I’ll just filter for content like ‘ignore previous instructions’”. How hard can that be? So I added a few checks for that and similar phrases [...] Passing prompts to GPT to sanitize them
What? The lesson learned from decades of SQL injection is that trying to filter and add checks (trying to enumerate all bad inputs) doesn't work, and neither does "sanitizing". Things cannot be made "safe" for all possible contexts. They need to be appropriately encoded for the context where they're used.
The solution is to use protocols and APIs that separate the query from the parameters. He even mentions parametrization at the very end!