简体   繁体   English

php, html mysql &#39;select * from table&#39; 解释为<select></select>选项框

[英]php, html mysql 'select * from table' interpreted as <select></select> option box

I've just hit a weird display issue.我刚刚遇到了一个奇怪的显示问题。

I have an ecommerce site which allows the user to add free text in a description field.我有一个电子商务网站,它允许用户在描述字段中添加自由文本。 This value is stored in an mysql database and later read out to the screen in a description.该值存储在 mysql 数据库中,稍后在描述中读出到屏幕上。

During some testing I've found that if the user puts 'select * from table' it is stored and returned correctly but the html is turning it into在一些测试中,我发现如果用户输入“select * from table”,它会被正确存储并返回,但 html 正在将其转换为

<span class="idesc break-word">TESTING TESTING %$#$!OIUOQI#UQO@)( <select *="" from="" table=""></select></span>

在此处输入图片说明

which in turn appears as an empty select drop down box.它反过来显示为一个空的选择下拉框。

I already use ?我已经用了? bind variables in the php to mysql code so firstly:首先将php中的变量绑定到mysql代码:

  1. Is there something else I should be doing to protect against dodgy data entry?还有什么我应该做的来防止狡猾的数据输入吗?
  2. Is this indicative that I could be open to other such attacks?这是否表明我可能对其他此类攻击持开放态度?

If values of the field that was created in that manner are being passed further down he application and can end up sent to database than yes you are open to SQL injection attacks.如果以这种方式创建的字段的值被进一步向下传递到应用程序并且最终可以发送到数据库,那么您很容易受到 SQL 注入攻击。

Is there some code that is looking for "select" and decides that a field should be created from that?是否有一些代码正在寻找“选择”并决定应该从中创建一个字段? If yes, that looks somewhat dangerous and there could be more areas where this ecommerce app makes potentially dangerous decisions.如果是,那看起来有些危险,并且该电子商务应用程序可能会在更多领域做出潜在危险的决定。

Binding is a good step in preventing unexpected data types from being entered, but going a step further like limiting some characters eg ;<> is also a good way.绑定是防止输入意外数据类型的一个很好的步骤,但更进一步,例如限制某些字符,例如 ;<> 也是一个好方法。 What worries me with your example is that you were not expecting a select field, but got one;你的例子让我担心的是,你并不期待一个选择字段,而是得到了一个; that means that once broken that mechanism could be further exploited to interact with your database.这意味着一旦被破坏,该机制可能会被进一步利用来与您的数据库进行交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM