Skip to content

Instantly share code, notes, and snippets.

@fernandotakai
Forked from kevincennis/README.md
Last active June 14, 2017 21:46
Show Gist options
  • Save fernandotakai/4a4359fa2942ef5f5d649b3199af82ff to your computer and use it in GitHub Desktop.
Save fernandotakai/4a4359fa2942ef5f5d649b3199af82ff to your computer and use it in GitHub Desktop.

What if a package did something like this, but instead of logging to the console, they sent it back to a server?

Have you actually reviewed every dependency and every child dependency in every app you deploy?

Why are people not more scared of this?

// intercept and log every single http request on this server
const { IncomingMessage } = require('http');
const push = IncomingMessage.prototype.push;
IncomingMessage.prototype.push = function( chunk, encoding, done ) {
const result = push.call( this, chunk, encoding, done );
if ( chunk === null ) {
return;
}
const decoded = chunk instanceof Buffer ? chunk.toString( encoding ) : chunk;
console.log( `I spied on a user that sent: ${ decoded }` );
return result;
};
@fernandotakai
Copy link
Author

there was a analytics link on the original gist. ffs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment