Skip to content

Instantly share code, notes, and snippets.

@timelf123
Forked from kevincennis/README.md
Created June 12, 2017 14:32
Show Gist options
  • Save timelf123/309339d7be286615139342bb580d8c67 to your computer and use it in GitHub Desktop.
Save timelf123/309339d7be286615139342bb580d8c67 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?

Analytics

// 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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment