erc721m icon indicating copy to clipboard operation
erc721m copied to clipboard

🐛 Patched/Fix Bug : Arbitrary remote code execution within `wrangler dev` Workers sandbox

Open JOJOBET-DALTONLAR opened this issue 1 year ago • 0 comments

Update 👾 Describe The Sumarry:

Affected of this project magicoss/erc721m are vulnerable to Improper Handling of Insufficient Privileges via the wrangler dev server configuration. An attacker on the local network can connect to the inspector and execute arbitrary code. Additionally, without proper validation of Origin/Host headers, an attacker could exploit this to run code by convincing a user.

PoCs By IAP lamrecognitions:

$ lsof -nPiTCP -sTCP:LISTEN
COMMAND   PID USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
node    51399  pwu   33u  IPv6 0xe8478a1f17ba37f      0t0  TCP *:9229 (LISTEN)
node    51399  pwu   37u  IPv4 0xe8478b51682305f      0t0  TCP *:56781 (LISTEN)
node    51399  pwu   38u  IPv6 0xe8478a1f17bab7f      0t0  TCP *:6284 (LISTEN)
workerd 51401  pwu   11u  IPv4 0xe8478b515f2f98f      0t0  TCP 127.0.0.1:56779 (LISTEN)
workerd 51401  pwu   12u  IPv6 0xe8478a1f17bb37f      0t0  TCP [::1]:56779 (LISTEN)
workerd 51401  pwu   14u  IPv4 0xe8478b5166e64ff      0t0  TCP *:8787 (LISTEN)

With wrangler dev --ip localhost, this improves such that workerd is no longer listening on the wildcard address:

$ lsof -nPiTCP -sTCP:LISTEN
COMMAND   PID USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
node    51416  pwu   36u  IPv6 0xe8478a1e7bdd37f      0t0  TCP *:9229 (LISTEN)
node    51416  pwu   37u  IPv6 0xe8478a1f161c37f      0t0  TCP [::1]:56788 (LISTEN)
node    51416  pwu   38u  IPv6 0xe8478a1e7bddb7f      0t0  TCP *:6284 (LISTEN)
workerd 51418  pwu   11u  IPv4 0xe8478b515f2f98f      0t0  TCP 127.0.0.1:56786 (LISTEN)
workerd 51418  pwu   12u  IPv6 0xe8478a1f17f5b7f      0t0  TCP [::1]:56786 (LISTEN)
workerd 51418  pwu   14u  IPv4 0xe8478b51682305f      0t0  TCP 127.0.0.1:8787 (LISTEN)
workerd 51418  pwu   15u  IPv6 0xe8478a1f17f537f      0t0  TCP [::1]:8787 (LISTEN)
 export const DEFAULT_LOCAL_PORT = 8787; 
 export const DEFAULT_INSPECTOR_PORT = 9229; 
 export const openInspector = async ( 
 	inspectorPort: number, 
 	worker: string | undefined 
 ) => { 
 	const query = new URLSearchParams(); 
 	query.set("theme", "systemPreferred"); 
 	query.set("ws", `localhost:${inspectorPort}/ws`); 
 server = http.createServer(app); 
 terminator = createHttpTerminator({ server }); 
 server.listen(DEV_REGISTRY_PORT); 

🥷 According CVeScores:

The V8 inspector intentionally allows arbitrary code execution within the Workers sandbox for debugging. wrangler dev would previously start an inspector server listening on all network interfaces. This would allow an attacker on the local network to connect to the inspector and run arbitrary code. Additionally, the inspector server did not validate Origin/Host headers, granting an attacker that can trick any user on the local network into opening a malicious website the ability to run code. If wrangler dev --remote was being used, an attacker could access production resources if they were bound to the worker.

CVE-2023-7080 CWE-269 CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N

JOJOBET-DALTONLAR avatar Feb 09 '24 21:02 JOJOBET-DALTONLAR