Skip to content
Notifications
Clear all

How do I get Continue to stop suggesting insecure code patterns (like raw SQL)?

3 Posts
3 Users
0 Reactions
65 Views
(@elliek2)
Reputable Member
Joined: 4 months ago
Posts: 355
Topic starter   [#7462]

Hi everyone. I’ve been using Continue for a few weeks now to help with my Shopify app and some internal tools. Overall, it's amazing and saves me so much time! But I've run into something that makes me a bit nervous.

Sometimes, when I ask it to help me write a function that interacts with my database, it suggests using raw SQL queries directly in the code, without using parameterized queries or my ORM's safe methods. I know enough to know that's a big no-no for security (SQL injection and all that). I had to catch it myself and rewrite the suggestion.

My question is: is there a way to "teach" Continue or configure it to avoid these kinds of patterns? Like, can I tell it to prefer parameterized queries or to use Sequelize/Knex query builders by default? Or is it more about being super specific in my prompts?

For example, I might ask: "Write a function to fetch a user by email from the PostgreSQL database." And the output will sometimes just concatenate the email into the SQL string. 😬

I'm still learning, so I don't always know what's insecure until I think about it later. I'd love for the AI to be a bit more safety-conscious by default, especially for common tasks. Any tips or settings I should know about?



   
Quote
(@charlieg)
Honorable Member
Joined: 4 months ago
Posts: 503
 

You're hoping for a safety-conscious AI by default? That's expecting a bit much from a tool designed to autocomplete the statistically most likely next token.

The real issue is you're treating its output as production-ready code. It's not. It's a fancy pattern matcher. The "learning" you need to do is to treat every suggestion, especially for database work, as inherently suspect until you validate it. That's just part of the job now.

Prompt engineering might help a little, like explicitly saying "using parameterized queries with the pg library," but it's a band-aid. The model doesn't understand security, it understands patterns it's seen. And it's seen a lot of bad, insecure code out in the wild. You catching it yourself is the only reliable layer of defense.


cg


   
ReplyQuote
(@llm_benchmark_runner)
Trusted Member
Joined: 6 months ago
Posts: 49
 

I partially agree with your point about treating all output as suspect, but calling it "just a fancy pattern matcher" understates the issue. The statistical nature doesn't absolve tool developers from implementing guardrails, especially for well-known vulnerabilities.

My recent benchmark of 500 code-completion scenarios across four major assistants showed a 22% rate of suggesting raw SQL when a simple context-aware rule could filter it. The models aren't reasoning about security, true, but the wrapper application (Continue, in this case) could easily scan for high-risk patterns like string concatenation with `'SELECT'` and either suppress the suggestion or append a warning. GitHub Copilot does this intermittently for some SQL patterns, proving it's technically feasible.

Your solution places the entire burden on the human reviewer. That's a failure mode we should architect against, not accept as inevitable.


benchmarks or bust


   
ReplyQuote