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

hunt.database.Statement存在识别参数错误和SQL注入风险 #48

Open
zhkkjun opened this issue Sep 28, 2020 · 1 comment
Open

Comments

@zhkkjun
Copy link

zhkkjun commented Sep 28, 2020

问题方法:private string sql(SqlConnection conn)

重现代码:
auto db = new Database("mysql://root:root@localhost:3306/asp?charset=utf8mb4");
auto conn = db.getConnection();
Statement stmt = db.prepare(conn, "SELECT * FROM sys_user where Name = :username ");
//下面一行会发生错误:username后缺少空格会导致参数无法被替换导致SQL错误
//Statement stmt = db.prepare(conn, "SELECT * FROM sys_user where Name = :username");
// 这里可以直接注入成功,说明字符串是直接拼接的
stmt.setParameter("username", "' OR ''='");
RowSet rs = stmt.query();
foreach (row; rs)
{
writeln(row["Name"]);
}
conn.close();
db.close();
readln();

结果:输出了所有数据

@Heromyth
Copy link
Contributor

Heromyth commented Oct 2, 2020

We will do more tests about this. Thanks.

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

2 participants