dsa45132 2013-11-05 19:06
浏览 27
已采纳

保护来自XSS的PayPal捐赠表格 - CodeIgniter

I'm really paranoid about whether my donation form is safe from XSS or not (maybe I've been reading too many XSS articles). I've used the button generator provided by PayPal and inserted that into my page, but I also added a select element which has the 'item_name' value as its name attribute (one of PayPals html values):

i.e. like this:

<select name="item_name">
<option>...</option>
...
</select>

My first concern is whether that okay to do, because I'm storing the donate button in my account as a saved button, and PayPal says to put the code they give you "as-is" into your page, without alteration. I know its self evident, but its just a cheeky select element that'll make a better user experience :P. Is that okay?

Another question I want to ask is should I make the action attribute on the form that PayPal has given me point to a function in my controller which sanitizes the select elements value using htmlspecialchars() (is it even necessary to check the select element for such a purpose?), and in that function somehow point back to the PayPal url?

I don't have any other form on my website apart from an email me form, which I will apply XSS filtering to, but this PayPal form has got me confused as to how I need to protect it.

  • 写回答

2条回答 默认 最新

  • duanmingting9544 2013-11-05 19:09
    关注

    If you are not taking input from the client and displaying it on your website, you do not need to worry.

    The two primary cases of XSS would be database and request based. In a database-based system, an attacker submits malicious code to a publicly displayed field (comment form, something along those lines). Then, whenever the data from this form is display, the code is run - assuming the database is not properly sanitized.

    The other method would be XSS via a GET request. An attacker sends a victim a link to your site with malicious code as a parameter in the URL. If this parameter is displayed on the page and not properly sanitized, XSS can occur.

    echo "You just bought a " . $_GET['itemname'];
    

    You should not need to worry in your case, and don't bother sending to a controller to sanitize first - PayPal takes care of that themselves.

    Additional note: You don't need to worry about XSS in your email form, Javascript is not run by mail clients. What you do need to worry about is header injection.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效