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 not panic when cargo check #2993

Closed
y-pull opened this issue Jan 16, 2024 · 2 comments
Closed

sql injection not panic when cargo check #2993

y-pull opened this issue Jan 16, 2024 · 2 comments
Labels

Comments

@y-pull
Copy link

y-pull commented Jan 16, 2024

Bug Description

i wanna validate whether the sqlx can defend sql injection,and i wrote this below

then cargo check keeps circling and i check all my code again and again in many hours till i delete the code below

i think may sqlx throw an error or panic is the better way to tell coder to write like that is incorrect

thanks,sqlx is a good tool and i love it

Minimal Reproduction

let arg = " id ; SELECT 1 -- ";
sqlx::query!("SELECT * FROM `test` ORDER BY ?", arg).fetch_all(&dbpool).await;

Info

  • SQLx version: 0.7.3
  • SQLx features enabled: ["runtime-tokio", "mysql", "macros", "time", "rust_decimal", "json"]
  • Database server and version: Mysql
  • Operating system: almalinux 9.3
  • rustc --version: 1.75.0
@abonander
Copy link
Collaborator

SQL injection is a non-issue in this case because query parameters explicitly prevent it. arg is received as a separate string by the database server and is not parsed as SQL. See the FAQ answer I just wrote: https://github.com/launchbadge/sqlx/pull/2997/files?short_path=c7bd425#diff-c7bd425fd98aad1f9fef20099637bcbdcfadeb566ba1f83bb40ce484f195b8cf

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
@y-pull
Copy link
Author

y-pull commented Jan 18, 2024

thanks, really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants