Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Go Interface based Checker for SQL injection vulnerability #119

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

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)

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 Feb 25, 2025 6:02pm

@MashyBasker
Copy link
Collaborator

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!

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.

2 participants