Web 应用程序跨站脚本

发布于 2024-11-03 09:36:56 字数 493 浏览 1 评论 0原文

我的网站 http://www.imayne.com 似乎存在此问题,已由 MacAfee 验证。有人可以告诉我如何解决这个问题吗? (标题)

它是这样说的:

一般解决方案:

在接受用户输入时,如果您将数据显示回客户端,请确保对潜在的恶意字符进行 HTML 编码。

通过执行以下操作,确保参数和用户输入得到清理:

  • 删除<输入并替换为“<”;
  • 删除>输入并替换为“>”;
  • 删除 ' 输入并替换为“&apos”;
  • 删除“输入并替换为“””;
  • 去掉)输入并替换为“)”;
  • 删除( 输入并替换为“(”;
  • 我似乎无法显示实际的代码。这个网站正在展示其他东西。

    我不是网络开发人员,但我可以做一些事情。我正在努力遵守 PCI 标准。

    My website http://www.imayne.com seems to have this issue, verified by MacAfee. Can someone show me how to fix this? (Title)

    It says this:

    General Solution:

    When accepting user input ensure that you are HTML encoding potentially malicious characters if you ever display the data back to the client.

    Ensure that parameters and user input are sanitized by doing the following:

  • Remove < input and replace with "<";
  • Remove > input and replace with ">";
  • Remove ' input and replace with "&apos";
  • Remove " input and replace with """;
  • Remove ) input and replace with ")";
  • Remove ( input and replace with "(";
  • I cannot seem to show the actual code. This website is showing something else.

    Im not a web dev but I can do a little. Im trying to be PCI compliant.

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(3

    习ぎ惯性依靠 2024-11-10 09:36:56

    让我回答你的问题并给你一些建议。正确防止 XSS 需要通过在用户输入时定义可接受值的白名单,而不是禁止值的黑名单。在您开始考虑编码之前,这首先需要发生。

    一旦开始编码,请使用您选择的框架中的库,不要尝试自己进行字符替换。有关于此的更多信息,请参见 面向 .NET 开发人员的 OWASP Top 10 第 2 部分:跨站脚本 (XSS)(不用担心它是面向 .NET 的,这些概念在所有框架中都是一致的)。

    现在,请提供一些友好的建议:尽快获得专家支持。您在电子商务网站中发现了一个非常明显的反射型 XSS 缺陷,并且根据您在此页面上的评论,这不是您想要自行解决的问题。此缺陷的明显性质表明您很可能在该网站中遇到了更隐蔽的问题。您自己承认,“您在这里是个菜鸟”,您不会在一夜之间获得充分保护此类网站所需的能力。

    Let me both answer your question and give you some advice. Preventing XSS properly needs to be done by defining a white-list of acceptable values at the point of user input, not a black-black of disallowed values. This needs to happen first and foremost before you even begin thinking about encoding.

    Once you get to encoding, use a library from your chosen framework, don't attempt character substitution yourself. There's more information about this here in OWASP Top 10 for .NET developers part 2: Cross-Site Scripting (XSS) (don't worry about it being .NET orientated, the concepts are consistent across all frameworks).

    Now for some friendly advice: get some expert support ASAP. You've got a fundamentally obvious reflective XSS flaw in an e-commerce site and based on your comments on this page, this is not something you want to tackle on your own. The obvious nature of this flaw suggests you've quite likely got more obscure problems in the site as well. By your own admission, "you're a noob here" and you're not going to gain the competence required to sufficiently secure a website such as this overnight.

    一花一树开 2024-11-10 09:36:56

    您所描述的更改类型通常是通过 HTML 编码功能以多种语言完成的。该网站是用什么编写的。如果这是 ASP.NET 网站,本文可能会有所帮助:

    http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4- and-asp-net-mvc-2.aspx

    在 PHP 中,使用此函数来包装所有正在输出的文本:

    http://ch2.php.net/manual/en/function.htmlentities.php

    在任何地方看到 echo(...) 或 print(...) 时都可以将其替换为:

    echo(htmlentities( $whateverWasHereOriginally, ENT_COMPAT));
    

    查看页面中间的示例部分以获得其他指导。

    The type of changes you are describing are often accomplished in several languages via an HTML Encoding function. What is the site written in. If this is an ASP.NET site this article may help:

    http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx

    In PHP use this function to wrap all text being output:

    http://ch2.php.net/manual/en/function.htmlentities.php

    Anyplace you see echo(...) or print(...) you can replace it with:

    echo(htmlentities( $whateverWasHereOriginally, ENT_COMPAT));
    

    Take a look at the examples section in the middle of the page for other guidance.

    信仰 2024-11-10 09:36:56

    严格按照这些步骤操作,就可以开始了。主要的事情是确保您不会将用户提交给您的任何内容视为代码(HTML、SQL、Javascript 或其他)。如果未能正确清理输入,则会面临脚本注入的风险。

    如果您想查看此问题的一个简单示例,请

    <span style="color:red">red</span>
    

    在您的网站上进行搜索,您会看到回显的搜索词是红色的。

    Follow those steps exactly, and you're good to go. The main thing is to ensure that you don't treat anything the user submits to you as code (HTML, SQL, Javascript, or otherwise). If you fail to properly clean up the inputs, you run the risk of script injection.

    If you want to see a trivial example of this problem in action, search for

    <span style="color:red">red</span>
    

    on your site, and you'll see that the echoed search term is red.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文