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

Fix false positive for single or double quotes that are safely escaped #49

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

hansott
Copy link
Member

@hansott hansott commented Jan 6, 2025

With a partial match

@kapyteinaikido kapyteinaikido self-requested a review January 6, 2025 17:47
#[test]
fn test_partial_match_single_quote() {
let starts_with = r#"
SELECT "foo" WHERE "bar" = '''; sleep 15 ;"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add is injection cases

// However, if the user input is `'value` and the single quote is escaped with another single quote
// `'value` becomes `'''value'` in the query so we still find an exact match
// (vice versa for double quotes)
if userinput.contains("'") || userinput.contains('"') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starts_with?

The start of the string, the double quote to escape the next double
quote, the actual double quote of the user input
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.

4 participants