Weaponize your package


@naugtur, The Hack Summit 2024

Who's that guy?

https://naugtur.pl



πŸ“¦πŸ‘Œ




So you want to attack someone with a malicious package
npm logo gobble
In general, disguise it as one of these
## Prototype poisoning # πŸ§ͺ🍏 ![]() ```js const a = {}; Object.prototype.toString = ()=>'πŸ‘»'; console.log(`scary object: ${a}`); ``` ``` scary object: πŸ‘» ```
### JS can be tweaked and it's no accident - designed in 10 days - humbly assuming there's room for improvement
## polyfills #### and ## prototype poisoning #### are the same thing #### with different intentions
# βš”οΈ ## a weapon ```js Object.defineProperty(Object.prototype, "Authorization", { set(value) { console.log(`stolen: ${value}`); }, }); ``` ```js const headers = {}; if( authorized ) { headers.Authorization = `Bearer ${token}`; } ```
## attack examples [repo](https://github.com/naugtur/js-training-examples/tree/master/websec101/attacking)

@naugtur   naugtur.pl

naugtur.pl/training