---
title: "Discussion on \"The query that runs fine until someone types an apostrophe\" | Hashnode"
description: "Discussion on \"The query that runs fine until someone types an apostrophe\". A query built with an f-string or a `+` reads like ordinary code and passes every test - until a value carries an apostrophe, an `OR 1=1`, or a `;` and your database runs it as SQL. Here is the injection behind CWE-89, why parameterization is the only real fix, and sqlfence, a static linter that fails the build when a query is built from user input."
url: "https://hashnode.com/posts/sqlfence-sql-injection-static-linter/6ab346306ee6fc6b2ff3b49b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [The query that runs fine until someone types an apostrophe](https://jaytank.hashnode.dev/sqlfence-sql-injection-static-linter?utm_source=hashnode&utm_medium=feed)

A query built with an f-string or a \`+\` reads like ordinary code and passes every test - until a value carries an apostrophe, an \`OR 1=1\`, or a \`;\` and your database runs it as SQL. Here is the injection behind CWE-89, why parameterization is the only real fix, and sqlfence, a static linter that fails the build when a query is built from user input.

Sep 23 · 8 min read · jaytank.hashnode.dev  
Read the article

-   [#security](https://hashnode.com/tag/security)
-   [#webdevelopment](https://hashnode.com/tag/webdevelopment)
-   [#go](https://hashnode.com/tag/go)
-   [#devops](https://hashnode.com/tag/devops)
-   [#databases](https://hashnode.com/tag/databases)

## Written by

[JAY TANK](https://hashnode.com/@jaytank)

@jaytank

  
[View profile](https://hashnode.com/@jaytank)

Engineering insights on building and scaling modern software.

Cloud &amp; Platform Engineer focused on building systems that scale and endure. I explore how infrastructure, automation, and engineering practices come together to support modern software teams.

## Responses 2

Markdown supported · ⌘↵ to post

[Mihai\_LeanZero](https://hashnode.com/@mihaileanzero)

[Sep 23](https://hashnode.com/posts/sqlfence-sql-injection-static-linter/6ab346306ee6fc6b2ff3b49b/comment/6ab356e4a4c69b692425fd35)

The line/window-scoped tradeoff you called out is the right thing to flag, and the case that bites in real codebases is usually a DAO or repository wrapper - the query lives in get\_by\_id(user\_id) two files away from the request handler, so the taint never crosses back into the same function window and sqlfence stays quiet on exactly the pattern that ships in most services with a data layer. Worth documenting as a known gap rather than letting a clean run imply full coverage - I'd rather a linter say "can't tell, wrapped call" on that shape than go silent on it.

[JAY TANK](https://hashnode.com/@jaytank)

[Sep 28](https://hashnode.com/posts/sqlfence-sql-injection-static-linter/6ab346306ee6fc6b2ff3b49b/comment/6ab356e4a4c69b692425fd35#reply-6ab9dd9d2cd60d174130112c)

Really appreciate this - and you've named the exact case that matters most: the query living in get\_by\_id() in the data layer, one or two hops from the handler, is precisely where intraprocedural taint goes quiet. You're right that a clean run shouldn't be read as full coverage there.

Two things I'm taking from this:

1.  I'll document the wrapped-call / cross-function boundary as an explicit known gap in the README, so a green result never over-promises.
    
2.  I like your "can't tell, wrapped call" idea a lot - surfacing a low-confidence "tainted value crosses a function boundary here" note is far more honest than silence. Tracking it as a planned signal (likely opt-in so it stays low-noise).
    

Thanks for pushing on the honesty of the output - that's the part I most want to get right.
