English 中文(简体)
外部链接的图像——如何防止交叉点描述
原标题:Externally linked images - How to prevent cross site scripting
  • 时间:2010-09-06 15:02:10
  •  标签:
  • xss

On my site, I want to allow users to add reference to images which are hosted anywhere on the internet. These images can then be seen by all users of my site. As far as I understand, this could open the risk of cross site scripting, as in the following scenario: User A adds a link to a gif which he hosts on his own webserver. This webserver is configured in such a way, that it returns javascript instead of the image. User B opens the page containg the image. Instead of seeing the image, javascript is executed.

My current security messures are currently such, that both on save and open, all content is encoded. I am using asp.net(c#) on the server and a lot of jquery on the client to build ui elements, including the generation of image tags.

这种对地雷的恐惧是否正确? 我在这里没有其他重要的安全漏洞? 最重要的是,我如何防止这次袭击? 我现在能想到的唯一安全方式是,在服务器上 image光图像,如果它包含除双元数据以外的任何东西,则进行检查。

最佳回答

检查档案确实是一种形象的胜利。 当服务器提出要求时,攻击者可以回去一件事,如果潜在受害者提出同样的要求,则可以回去一件事。

说到,只要你将URL限制在只字标的斜体内印制,那么你就存在一个CSRF缺陷,但不是一个XSS。

Someone could for instance create an "image" URL along the lines of: http://yoursite.com/admin/?action=create_user&un=bob&pw=alice Or, more realistically but more annoyingly; http://yoursite.com/logout/

如果所有敏感行动(博客、编辑简介、设立员额、改变语言/主题)都受到震动,那么,像这一 would那样的攻击媒介给使用者带来任何好处。

但是,回到你的问题;除非有某些目前的浏览器,否则,我就认为你已经获得XSS。 Oh,记住他们的形象,URL并不包括奇迹。 例如:><script>alert(1)</script><!--显然具有不良效果。 我假定你知道会逃脱。

问题回答

Your approach to security is incorrect. Don t approach the topic as "I have a user input, so how can I prevent XSS". Rather approach it like it this: "I have user input - it should be restrictive as possible - i.e. allowing nothing through". Then based on that allow only what s absolutely essential - plain-text strings thoroughly sanitized to prevent anything but a URL, and the specific, necessary characters for URLS only. Then Once it is sanitized I should only allow images. Testing for that is hard because it can be easily tricked. However, it should still be tested for. Then because you re using an input field you should make sure that everything from javascript scripts and escape characters, HTML, XML and SQL injections are all converted to plaintext and rendered harmless and useless. Consider your users as being both idiots and hackers - that they ll input everything incorrectly and try to hack something into your input space.

除此以外,你还可能处理版权方面的法律问题。 未经版权所有人同意和许可,版权图像一般不得在他人的遗址上使用,通常以书面形式(或电子邮件)获取。 因此,让用户有机会简单地从某个地点取出图像,就有可能让他们拿到版权材料,并在未经许可的情况下将其张贴在贵国,这是非法的。 某些网站以来源为名,另一些网站则要求支付费用,另一些网站则将起诉你,并将整个领域缩小版权侵犯的范围。





相关问题
JavaScript Code injected into my website pages

I need to know if there is any way of writing additional code to JavaScript files already deployed on the server. I am facing a problem with an ASP.NET 2.0 website and it is related to the ...

Security in a Rails app - User submitted data

I m currently in the process of writing my first Rails app. I m writing a simple blog app that will allow users to comment on posts. I m pretty new to Rails, so I m looking for a bit of guidance on ...

XSS on jsbin.com

Anyone know if jsbin.com implements any protection for XSS or other javascript attacks? I see jsbin links used fairly regularly on sites like this one and I can t find any indication from the site ...

ASP.NET: Looking for solution to solve XSS

We got a long-running website where XSS lurks. The problem comes from that some developers directly - without using HtmlEncode/Decode() - retrieve Request["sth"] to do the process, putting on the web. ...

热门标签