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

SQL injection attack #74

Open
huzhenjie opened this issue Sep 24, 2020 · 0 comments
Open

SQL injection attack #74

huzhenjie opened this issue Sep 24, 2020 · 0 comments

Comments

@huzhenjie
Copy link

where email="${options.email}" or name="${options.name}"

The code here will case SQL injection attack.

async getExistOne(options ) {
    let _sql = `
    SELECT * from user_info
      where email="${options.email}" or name="${options.name}" // SQL injection attack
      limit 1`
    let result = await dbUtils.query( _sql )
    if ( Array.isArray(result) && result.length > 0 ) {
      result = result[0]
    } else {
      result = null
    }
    return result
  }

Suggestion

SELECT * from user_info where email=? or name=? limit 1
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

No branches or pull requests

1 participant