qd-today / qd

QD [v20240210] —— HTTP请求定时任务自动执行框架 base on HAR Editor and Tornado Server
https://qd-today.github.io/qd/
MIT License
4.46k stars 577 forks source link

[Bug] 严重漏洞,拿自己部署的QD的数据库DB文件恢复别人的QD站点,可以把别人的站点搞崩溃,我的已经被别人搞崩溃了 #493

Closed xuexiaokang closed 10 months ago

xuexiaokang commented 10 months ago

Verify steps

QD Version

20230821

Bug on OS

Windows

Bug on Platform

Docker/Linux 64位

To Reproduce

拿自己部署的QD的数据库DB文件恢复别人的QD站点,可以把别人的站点搞崩溃,我的已经被别人搞崩溃了

Describe the Bug

应该是权限漏洞,没有限制普通用户上传DB数据库,从而导致整站崩溃

QD config

No response

QD log

File "/usr/src/app/db/user.py", line 153, in encrypt
        return crypto.aes_encrypt(data, userkey)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/app/libs/mcrypto.py", line 46, in aes_encrypt
        aes = AES.new(key, mode, iv)
              ^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/Crypto/Cipher/AES.py", line 228, in new
        return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/Crypto/Cipher/__init__.py", line 79, in _create_cipher
        return modes[mode](factory, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/Crypto/Cipher/_mode_cbc.py", line 274, in _create_cbc_cipher
        cipher_state = factory._create_base_cipher(kwargs)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/Crypto/Cipher/AES.py", line 89, in _create_base_cipher
        if len(key) not in key_size:
           ^^^^^^^^
    TypeError: object of type 'int' has no len()

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.11/site-packages/tornado/web.py", line 1786, in _execute
        result = await result
                 ^^^^^^^^^^^^
      File "/usr/src/app/web/handlers/login.py", line 265, in post
        await self.send_mail(user)
      File "/usr/src/app/web/handlers/login.py", line 298, in send_mail
        verified_code = await self.db.user.encrypt(user['id'], verified_code)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/app/db/user.py", line 155, in encrypt
        raise self.UserDBException('encrypt error')
    db.user.User.UserDBException: encrypt error

Expected behavior

这是个非常严重的漏洞,修复的同时建议能增加数据库自动备份的功能

Screenshots

No response

acooler15 commented 10 months ago

经过测试,的确存在“未验证管理员权限”的问题