Details
Expected vulnerable output: the harness records a server-side HEAD request to http://127.0.0.1:65535/internal even though /cors SSRF protections are not involved.
- Confirm the conditional command-execution sink is reachable from the trusted socket-driven update path using a harmless
/tmpmarker command:
rm -f /tmp/mm-rce-marker
mkdir -p /tmp/mm-audit/modules/evil /tmp/mm-audit/defaultmodules
node -e 'const fs=require("node:fs"); const Module=require("module"); const orig=Module._load; Module._load=(r,p,m)=>{ if(r==="logger") return {log(){},error(){},warn(){},info(){},debug(){}}; if(r==="node_helper") return {create:(o)=>function(){Object.assign(this,o);this.sendSocketNotification=()=>{};}}; return orig(r,p,m); }; global.root_path="/tmp/mm-audit"; global.defaultModulesDir="defaultmodules"; fs.writeFileSync("/tmp/mm-audit/defaultmodules/defaultmodules.js","module.exports=[]"); const Helper=require("./defaultmodules/updatenotification/node_helper"); const h=new Helper(); h.gitHelper={add:async()=>{},getRepos:async()=>[{module:"evil",behind:1}],checkUpdates:()=>[{module:"evil",behind:1}]}; h.sendSocketNotification=(n,p)=>console.log("SOCKET",n,JSON.stringify(p)); (async()=>{ await h.socketNotificationReceived("CONFIG",{updates:[{evil:"printf ok > /tmp/mm-rce-marker"}],updateTimeout:5000,updateAutorestart:false,ignoreModules:[],sendUpdatesNotifications:false,updateInterval:60000,useModulesFromConfig:true}); await h.socketNotificationReceived("MODULES",["evil"]); console.log("marker=",fs.readFileSync("/tmp/mm-rce-marker","utf8")); process.exit(0); })();'
rm -f /tmp/mm-rce-marker
rm -rf /tmp/mm-audit
Observed output from the executed harness:
SOCKET REPO_STATUS {"module":"evil","behind":1}
SOCKET UPDATE_STATUS {"name":"evil","updateCommand":"printf ok > /tmp/mm-rce-marker","inProgress":true,"error":false,"updated":true,"needRestart":true}
marker= ok
Expected vulnerable output: marker= ok demonstrates the update command supplied through the trusted socket configuration path reached child_process.exec and wrote the harmless marker.
Negative/control cases:
- With the shipped committed defaults (
js/defaults.js:8-13), the server bindslocalhostandipWhitelistincludes only loopback, so a remote network attacker cannot reach either HTTP or Socket.IO unless the deployment is changed to a documented non-loopback address. - The
updatenotificationcommand execution path requires at least one non-core module update result; ifcheckUpdates()returns no third-party module withbehind > 0,update_helper.parse(...)does not execute an update command. - The explicit
/corsroute was not used for the confirmed request primitive and has separate protocol/hostname/DNS checks.
Final repro re-check: the sink search, newsfeed socket request harness, and update marker harness were re-run after drafting; the observed outputs above are from this environment. Cleanup removed /tmp/mm-rce-marker and /tmp/mm-audit.
Impact
In a documented common non-loopback deployment that relies on ipWhitelist for access control, an unauthenticated network client can bypass the intended IP allowlist for Socket.IO module namespaces. The attacker can send arbitrary module-helper notifications and payloads as if they were a trusted browser client.
Confirmed impacts include:
- Confidentiality/SSRF: server-side requests to attacker-chosen URLs through default module helpers, including loopback/internal URLs. The newsfeed PoC shows a
HEADrequest to127.0.0.1. - Integrity/availability: arbitrary manipulation of module-helper state and periodic fetch/update behavior through trusted socket messages.
- Conditional code execution: when a third-party git-managed module is considered behind by the update checker, an attacker can supply a command in the socket
CONFIGpayload and triggerchild_process.exec; the PoC safely wrote a/tmpmarker.
CVSS 3.1 rationale for the primary trust-boundary bypass with confirmed SSRF and conditional RCE variant: AV:A because MagicMirror's security policy says it is intended for trusted local/private networks and the documented non-loopback exposure is LAN-style; AC:H because default loopback settings must be changed and the RCE variant requires a pending third-party module update, though SSRF requires fewer conditions after reachability; PR:N because no application authentication is required; UI:N because the attacker connects directly to Socket.IO; S:C because the vulnerable application can cause requests/actions against other local/internal services and can execute commands in a child process in the conditional variant; C:L/I:L/A:L for confirmed internal request and helper-state/command side effects, with conservative scoring because unconditional default RCE was not shown.
Suggested remediation
Apply the same access-control decision to Socket.IO handshakes and namespaces as to Express routes. Concretely, add a Socket.IO allowRequest or io.use(...) middleware that normalizes socket.handshake.address/request IPs with the same ipAccessControl logic, and reject clients not allowed by config.ipWhitelist. Avoid relying on CORS for authorization; keep origin checks as a browser hardening layer only.
Also add module-helper authorization so arbitrary clients cannot send privileged server-side module notifications. For example, issue an unguessable per-session/module token to the served client and require it on helper messages, or separate read-only client events from privileged server-maintenance actions.
For defense in depth:
- Add SSRF protections or allowlists to calendar/newsfeed/weather helper fetch paths, not only
/cors. - Do not accept
updatenotificationupdate commands from socket payloads; use the server-loaded config only, validate module names against configured modules, and avoid shell execution where possible. - Add regression tests proving a disallowed IP receives a rejected Socket.IO handshake even when Express routes are protected, and proving
/newsfeed//calendarhelper messages from unauthenticated sockets cannot trigger server-side requests or update commands.