由于电子邮件地址有这么多有效字符,是否有任何有效电子邮件地址本身可能是 XSS 攻击或 SQL 注入(inject)?我在网上找不到这方面的任何信息。
The local-part of the e-mail address may use any of these ASCII characters:
- Uppercase and lowercase English letters (a–z, A–Z)
- Digits 0 to 9
- Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~
- Character . (dot, period, full stop) provided that it is not the last character, and provided also that it does not appear two or more times consecutively (e.g. John..Doe@example.com).
http://en.wikipedia.org/wiki/E-mail_address#RFC_specification
我不是在问如何防止这些攻击(我已经在使用参数化查询和转义/HTML 净化器),这更像是一个概念验证。
首先想到的是'OR 1=1--@gmail.com
,只是不允许有空格。所有 SQL 注入(inject)都需要空格吗?
最佳答案
但是,如果用引号括起来,则允许使用空格,因此 "'OR 1=1--"@gmail.com
是一个有效的电子邮件地址。此外,这可能不是什么大问题,但从技术上讲,这些都是有效的电子邮件地址:
' BAD SQL STUFF -- <fake@ryanbrunner.com>
fake@ryanbrunner.com (' BAD SQL STUFF --)
即使这不可能,您仍然没有理由不使用参数化查询并对所有显示给用户的用户输入数据进行编码。
关于php - 有效的电子邮件地址 - XSS 和 SQL 注入(inject),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2923594/