- Notifications
You must be signed in to change notification settings - Fork715
fix: dashboard search text for variables SQL query#8342
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Greptile Summary
This PR fixes a critical SQL injection vulnerability in the dashboard variables search functionality. The issue was in theVariablesValueSelector.vue component where user-provided search text was being directly interpolated into SQL queries without proper quoting.
The vulnerability existed in the dynamic query construction for dashboard variable searches. When users search for values in dashboard variables, the system constructs a SQL query using thestr_match function. The original code was passing the escaped search text directly without surrounding quotes:
// Vulnerable codeWHEREstr_match(${field},${escapeSingleQuotes(searchText)})
This meant that even thoughescapeSingleQuotes was being used, the search text was being treated as a SQL identifier or expression rather than a string literal, potentially allowing attackers to inject malicious SQL code.
The fix adds single quotes around the escaped search text:
// Fixed codeWHEREstr_match(${field},'${escapeSingleQuotes(searchText)}')
This ensures the search text is properly treated as a string parameter to thestr_match function, preventing SQL injection while maintaining the intended search functionality. The change integrates seamlessly with the existing dashboard variable system and doesn't affect the user experience - it simply makes the SQL query construction secure.
Confidence score: 5/5
- This PR is extremely safe to merge and fixes a critical security vulnerability with minimal risk
- Score reflects a straightforward security fix with clear benefits and no breaking changes to functionality
- No files require special attention beyond the single line change in VariablesValueSelector.vue
Context used:
Context - Avoid directly interpolating values into SQL queries; instead, generate parameter placeholders and bind them safely to prevent SQL injection and enable plan caching. (link)
1 file reviewed, no comments
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
78a5919 intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
PR Type
Bug fix
Description
Fix SQL search text interpolation
Quote escaped search text in query
Prevent malformed WHERE clause
Improve variable value selector reliability
Diagram Walkthrough
File Walkthrough
VariablesValueSelector.vue
Properly quote escaped search text in SQLweb/src/components/dashboards/VariablesValueSelector.vue