【问题标题】:Prevent "ssi_function=something" from bypassing normal control flow防止“ssi_function=something”绕过正常的控制流
【发布时间】:2017-09-30 07:45:02
【问题描述】:

如果您熟悉 SMF,这就是您通常使用其服务器端的方式包括:

//foo.php at http://example/foo.php
<?php
require('./SSI.php'); //assuming we're at SMF's root

//...
?>

但是对于未经训练的人来说,访问http://example/foo.php?ssi_function=something will cause ssi_something to be called inside SSI.php 是隐藏的,有效地绕过了foo.php 的正常行为。

我可以在 require 之前添加它,但我可以避免重定向:

if(isset($_GET['ssi_function']))
{
    unset($_GET['ssi_function']);
    return header('Location: ?' . http_build_query($_GET));
}

我已经打开了issue on GitHub,但我还有什么其他办法可以对付这种滋扰?

【问题讨论】:

    标签: php smf-forum


    【解决方案1】:

    正如您所提到的,这是 SMF 中依赖于实现的行为。在这种情况下,您不需要进行重定向,因为 $_GET 超全局是可变的,只需删除 ssi_function 参数就足够了。

    【讨论】:

    • 我一开始也是这么想的。在require 之前的unset($_GET['ssi_function']); 确实删除了ssi_function,但仅从foo.php 的范围内删除。它仍然存在于SSI.php 中。
    • 请记住,如果不需要,您仍然可以修改 SMF 以删除此行为。
    • 我知道,但我不会这样做。如果我必须修改 SMF 只是为了防止这种滋扰,而我只想访问用户系统,那我会被诅咒的。
    • 有时您无法解决设计不佳的系统,如果 SMF 公开此功能而没有禁用它的方法,您将不得不修改 SMF。这不完全是 PHP 本身的问题。
    【解决方案2】:

    此错误已在#4038 中修复。

    @@ -177,6 +177,9 @@
     // Have the ability to easily add functions to SSI.
     call_integration_hook('integrate_SSI');
    
    +// Ignore a call to ssi_* functions if we are not using SSI.php
    +if (empty($modSettings['allow_ssi_functions_anywhere']) && isset($_GET['ssi_function']) && basename($_SERVER['PHP_SELF']) !== 'SSI.php')
    +   unset($_GET['ssi_function']);
     // Call a function passed by GET.
     if (isset($_GET['ssi_function']) && function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
     {
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-08
      • 2017-03-31
      • 2021-08-25
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      • 2015-07-10
      • 2023-04-08
      相关资源
      最近更新 更多