Green Login Tests Can Miss SQL Injection Risks, Developer Experiment Shows
A software developer demonstrated that standard login behavior tests can pass even when SQL queries are built unsafely using f-strings, leaving applications vulnerable to SQL injection. The experiment compared two login implementations — one embedding user input directly into the SQL string and another using parameterized placeholders — both of which passed identical response-based tests. A separate 'parameterization contract test' using a fake database object was introduced to inspect exactly what SQL and parameters reached the cursor.execute call. The unsafe f-string implementation failed this contract test, as user values were embedded in the query string with no parameter tuple, while the parameterized version passed cleanly. The developer concluded that behavior tests and parameterization contract tests cover different boundaries and both are necessary for robust security coverage.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in