Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koishi-plugin-eval 漏洞整理 #58

Closed
shigma opened this issue Aug 3, 2020 · 7 comments
Closed

koishi-plugin-eval 漏洞整理 #58

shigma opened this issue Aug 3, 2020 · 7 comments
Labels
bug BUG

Comments

@shigma
Copy link
Member

shigma commented Aug 3, 2020

这个 issue 用于整理 koishi-plugin-eval 中存在的漏洞。对漏洞的定义包括:

  • 修改用户数据的行为
  • 实现沙箱逃逸的行为
  • 获取文件路径的行为
  • 导致主线程崩溃的行为

提交漏洞时请附上代码。

@shigma
Copy link
Member Author

shigma commented Aug 3, 2020

多次 log 无法决定消息的发送顺序。

Fixed in bfe718e.

@shigma shigma added the bug BUG label Aug 3, 2020
@undefined-moe
Copy link
Member

undefined-moe commented Aug 4, 2020

eval(session.message.split('>>')[1])

Fixed in 0c66d22.

@shigma
Copy link
Member Author

shigma commented Aug 5, 2020

通过 SIGINT 终止主线程时有小概率发生子线程再次重启的问题。

Fixed in aad8ece.

@shigma shigma added the plugin label Aug 6, 2020
@shigma
Copy link
Member Author

shigma commented Aug 7, 2020

部分对象的 inspect 行为不一致。

>> new Date()
Date {}
>> new String("123")
String { '0': '1', '1': '2', '2': '3' }

Related issue: patriksimek/vm2#314.

  • Date / RegExp / Error are fixed in 3aed061.
  • String / Number / Boolean are fixed in 240ed9c.

@koishijs koishijs deleted a comment from undefined-moe Aug 7, 2020
@shigma
Copy link
Member Author

shigma commented Aug 7, 2020

>> [1, 2, 3]
// 无输出

Fixed in Mrs4s/go-cqhttp@4941f0c.

@shigma shigma closed this as completed Aug 11, 2020
@takayama-lily
Copy link

从vm2的issue里跳过来的。。当初觉得vm2有很多问题就还是用了vm
对于逃逸是这么解决的

//外部
Function.prototype.constructor = new Proxy(Function, {
    apply: ()=>{
        throw Error()
    },
    constructor: ()=>{
        throw Error()
    }
})
Object.freeze(Object)
Object.freeze(Object.prototype)
Object.freeze(Function)
Object.freeze(Function.prototype)

对于爆内存好像没什么好的解决办法

@shigma
Copy link
Member Author

shigma commented Dec 15, 2020

@takayama-lily 上面的问题其实都解决了,逃逸这里跟 vm2 有点不太一样,因为 koishi-plugin-eval 是单一的环境,只要你在沙箱外部避免这些操作就没事

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug BUG
Projects
None yet
Development

No branches or pull requests

3 participants