Skip to content

Conversation

@viveka1302
Copy link

Description:

GoLang was chosen for this checker for complex logical control of flow of execution.

Basic Idea:

SQL injection vulnerability in this checker is assumed when a SQL query contains concatenated string (f-string or interpolation) with user-input instead of parameterisation.

Logic:

To identify an SQL execution call, we search for the most common execution calls across all SQL libraries and ORMs, like:
execute, executemany, executescript
Once we find such a call, the first case we check for, is if the developer has passed a string directly to the execution call, in which case, a normal tree-sitter-query is enough.
If instead, we find a variable passed as parameter, instead of raw string, we use Go to trace the variable back to it's origin, whether it's in the same file or in a different file in the same project (hence, accounting for multiple layers of variables being passed in one another).
Once spotted, we check the assigned value for any concatenated strings. If found, the user receives Report.

Type Of Change

  • New Checker

Checklist:

  • All required checkers added
  • Test case added
  • Not tested (since current Github Actions workflow does not have support for testing Go checkers, as per test_runner.go)

@vercel
Copy link

vercel bot commented Feb 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
globstar ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2025 7:07am

@MashyBasker
Copy link
Contributor

Hey, could you please add test directives to the test files.

@viveka1302
Copy link
Author

Sure, I'll get back to that this evening! Thanks

@viveka1302
Copy link
Author

@MashyBasker Added!

@sourya-deepsource sourya-deepsource force-pushed the sql-injection-py-checker branch from 6e24cec to c57caa6 Compare March 9, 2025 12:34
Signed-off-by: Vivek Anand <78247712+viveka1302@users.noreply.github.com>
Signed-off-by: Vivek Anand <78247712+viveka1302@users.noreply.github.com>
@sourya-deepsource
Copy link
Contributor

This is being done in a different way (using scope analysis and data flow) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants