SlideShare a Scribd company logo
Jarrod Overson - BSidesPDX
Why are imitation attacks such a problem?
Analysis of an OSS supply chain attack
How did millions of developers download malicious
code with no one noticing?
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
npm install [anything]
Jarrod Overson - BSidesPDX
The threat is real
And it's coming from inside
the house.
Jarrod Overson - BSidesPDX
How it happened
What it did
Where it leaves us
1
2
3
Agenda
Jarrod Overson - BSidesPDX
Who am I?
• Director at Shape Security & Google Dev Expert.
• Write/talk/record about JS reverse engineering &
breaking web apps.
• Old-school video game hacker.
• @jsoverson most everywhere
This guy
Jarrod Overson - BSidesPDX
?
Jarrod Overson - BSidesPDX
Ever heard of YKK?
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
You used Shape this week.
We're the reason you log in a lot less and see fewer
CAPTCHAs.
Jarrod Overson - BSidesPDX
How it happened
What it did
Where it leaves us
1
2
3
Agenda
Jarrod Overson - BSidesPDX
JS
It started with a package, event-stream
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
JS
event-stream was maintained by prolific
developer Dominic Tarr
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
JS
Domenic gave ownership to right9ctrl in
September of 2018
*
Jarrod Overson - BSidesPDX
Q: Why?
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
JS
right9ctrl gained trust by committing several
innocent changes.
...b550f5: upgrade dependencies
...37c105: add map and split examples
...477832: remove trailing in split example
...2c2095: better pretty.js example
...a644c5: update readme
event-stream
Jarrod Overson - BSidesPDX
JS
On Sept 9 2018 right9ctrl added a new
dependency and released version 3.3.6
JS
v3.3.6
JS v0.1.0
flatmap-stream
event-stream
Jarrod Overson - BSidesPDX
About that caret...
Jarrod Overson - BSidesPDX
Semantic Versioning (semver)
Major.Minor.Patch e.g. 3.4.9
Breaking changes
New features
Bug fixes
Increasing risk
Jarrod Overson - BSidesPDX
Semver pattern matching
Symbol Example Matches
^ ^0.1.0 0.*.*
~ ~0.1.0 0.1.*
Jarrod Overson - BSidesPDX
JS
right9ctrl then removed flatmap-stream and updated
event-stream to v4.0.0.
v4.0.0
event-stream
Jarrod Overson - BSidesPDX
Note:
Nothing malicious has emerged thus far.
Jarrod Overson - BSidesPDX
Total time between first commit and v4.0.0?
12 days
Jarrod Overson - BSidesPDX
JS
On October 5th 2018 (T+31)
flatmap-stream@0.1.1 was published.
JS
v3.3.6
v0.1.1
flatmap-stream
event-stream
JS v0.1.0
Jarrod Overson - BSidesPDX
JS
event-stream@3.3.6 installed fresh now pulls in
flatmap-stream@0.1.1 because of the ^
JS
v3.3.6
v0.1.1
flatmap-stream
event-stream
Jarrod Overson - BSidesPDX
event-stream@3.3.5 was stable for 2+ years.
JSJS v3.3.6
event-stream
Jarrod Overson - BSidesPDX
A LOT depended on event-stream^3.3.5 and would
get updated to 3.3.6 automatically.
JS
JS
JS
JS
JS
JS
JS
JS
JS
Jarrod Overson - BSidesPDX
Time between flatmap-stream@0.1.1 and exposure:
48 days
Time between malicious control and discovery:
77 days
Jarrod Overson - BSidesPDX
How it happened
What it did
Where it leaves us
1
2
3
Agenda
Jarrod Overson - BSidesPDX
First, how was it discovered?
Payload A used a method deprecated in node v11.0.0
Node v11.0.0 was released 18 days into the exploit.
Unrelated projects started getting deprecation warnings.
Finally someone started putting it together.
Jarrod Overson - BSidesPDX
So how was it discovered?
Luck.
flatmap-stream v0.1.0
flatmap-stream v0.1.1
Jarrod Overson - BSidesPDX
Payload A
The bootstrap.
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Jarrod Overson - BSidesPDX
Recap
• The script decrypts and compiles a new module.
• The key comes from a package description somewhere.
• The encrypted JS comes from testData[0].
• The compiled module exports testData[1].
Jarrod Overson - BSidesPDX
What does this mean?
The script only serves its purpose if the code runs
from an npm script in a directory that has a
package.json with a "description" field containing a
specific string that can act as the key.
Jarrod Overson - BSidesPDX
What this means for us
We need to start trolling through package.json files.
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
😂
Jarrod Overson - BSidesPDX
Strategy
• Iterate through every package.
• Decrypt testData[0].
• Run the decrypted data through a JS Parser.
• If successful then we have a winner.
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
Copay, the Secure Bitcoin Wallet.
Jarrod Overson - BSidesPDX
Payload B
The injector.
Payload B
Payload B
Jarrod Overson - BSidesPDX
npm scripts redux
npm run-script script-name
[0] [1] [2]argv:
Payload B
copay's package.json scripts
Payload B
Jarrod Overson - BSidesPDX
Recap
• Payload B noops unless run in copay's build stage.
• Decrypts payload C just like payload B.
• Injects payload C into a file used in copay's mobile app.
• Payload C is then executed in the mobile app while on a
user's mobile device.
Jarrod Overson - BSidesPDX
Payload C
The final payload.
Payload C
Jarrod Overson - BSidesPDX
Payload C in a nutshell
• Harvested private keys
• Targeted wallets with over 100 BTC or 1000 BCH
• Communicated with third party server copayapi.host
Jarrod Overson - BSidesPDX
How it happened
What it did
Where it leaves us
1
2
3
Agenda
Jarrod Overson - BSidesPDX
This is NOT node/npm specific
Any public repository of code is susceptible.
Jarrod Overson - BSidesPDX
The Good News.
Once the issue was brought to light the community
• responded rapidly
• investigated quickly
• mitigated the issue immediately
• and produced tools to help others right away.
Jarrod Overson - BSidesPDX
The Bad News.
It has happened multiple times since.
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?
The dependency problem is not ideal.
Jarrod Overson - BSidesPDX
This could have been much worse.
event-stream was depended on things like the
- azure-cli
- dozens of build tools and plugins
- Microsoft's monaco editor (the editor for VSCode)
Jarrod Overson - BSidesPDX
This will likely get much worse.
Properly addressing this problem requires rethinking
node, dependencies, and package management.
Hard things with lots of compatibility implications.
Jarrod Overson - BSidesPDX
Jarrod Overson - BSidesPDX
What can you do?
• Audit your dependencies.
• Lock your dependencies.
• Check in your dependencies.
• Think twice before adding dependencies.
Jarrod Overson - BSidesPDX
When in doubt, don't add it.
• Dependencies are risks.
• Risks are gambles.
• You gamble when cost is low and value is high.
Jarrod Overson - BSidesPDX
Why are imitation attacks such a problem?Thank You!
@jsoverson on
bit.ly/jsoverson-youtube

More Related Content

What's hot (10)

PPTX
BlueHat v17 || Scaling Incident Response - 5 Keys to Successful Defense at S...
BlueHat Security Conference
 
PPTX
Oow2013 ef final_4_3
Euegene Fedorenko
 
PDF
Станислав Семенов, Data Scientist, Kaggle top-3, «О соревновании Telstra Kagg...
Mail.ru Group
 
PPTX
Ad, mimikatz, ata and (awe)some evasion techniques
Guglielmo Scaiola
 
PPTX
BlueHat v17 || Down the Open Source Software Rabbit Hole
BlueHat Security Conference
 
PPTX
My Bro The ELK
Tripwire
 
PDF
CyberSEED: Virtual Machine Introspection to Detect and Protect
Tamas K Lengyel
 
PDF
[CB16] About the cyber grand challenge: the world’s first all-machine hacking...
CODE BLUE
 
PDF
232 md5-considered-harmful-slides
Dan Kaminsky
 
PPTX
BlueHat v17 || Wannacrypt + Smbv1.0 Vulnerability = One of the Most Damaging ...
BlueHat Security Conference
 
BlueHat v17 || Scaling Incident Response - 5 Keys to Successful Defense at S...
BlueHat Security Conference
 
Oow2013 ef final_4_3
Euegene Fedorenko
 
Станислав Семенов, Data Scientist, Kaggle top-3, «О соревновании Telstra Kagg...
Mail.ru Group
 
Ad, mimikatz, ata and (awe)some evasion techniques
Guglielmo Scaiola
 
BlueHat v17 || Down the Open Source Software Rabbit Hole
BlueHat Security Conference
 
My Bro The ELK
Tripwire
 
CyberSEED: Virtual Machine Introspection to Detect and Protect
Tamas K Lengyel
 
[CB16] About the cyber grand challenge: the world’s first all-machine hacking...
CODE BLUE
 
232 md5-considered-harmful-slides
Dan Kaminsky
 
BlueHat v17 || Wannacrypt + Smbv1.0 Vulnerability = One of the Most Damaging ...
BlueHat Security Conference
 

Similar to Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing? (20)

PDF
JSconf JP - Analysis of an exploited npm package. Event-stream's role in a su...
Jarrod Overson
 
PDF
Black Clouds and Silver Linings in Node.js Security - Liran Tal Snyk OWASP Gl...
Liran Tal
 
PDF
JavaScript Supply Chain Security
Adam Baldwin
 
PDF
NPM ecosystem threats
Giacomo De Liberali
 
PDF
OWASP SF - Reviewing Modern JavaScript Applications
Lewis Ardern
 
PDF
Making 'npm install' Safe
C4Media
 
PPTX
Webinar–Reviewing Modern JavaScript Applications
Synopsys Software Integrity Group
 
PDF
Node.js security tour
Giacomo De Liberali
 
PDF
Surrogate dependencies (in node js) v1.0
Dinis Cruz
 
PDF
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...
Mario Heiderich
 
PDF
All about dependencies
Ixchel Ruiz
 
PDF
Node Security: The Good, Bad & Ugly
Bishan Singh
 
PPTX
Manual JavaScript Analysis Is A Bug
Lewis Ardern
 
PDF
[OWASP Poland Day] A study of Electron security
OWASP
 
PDF
Infiltrating the Supply Chain Attack: Advanced Payload Delivery and Evasion T...
null - The Open Security Community
 
PPTX
Getting Reactive with Cycle.js and xstream
Steve Lee
 
PDF
Node JS Roadmap for Beginners By Scholarhat PDF
Scholarhat
 
PPT
(In)Security Implication in the JS Universe
Stefano Di Paola
 
PDF
How to Enterprise Node
Julián David Duque
 
PDF
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
Julia Cherniak
 
JSconf JP - Analysis of an exploited npm package. Event-stream's role in a su...
Jarrod Overson
 
Black Clouds and Silver Linings in Node.js Security - Liran Tal Snyk OWASP Gl...
Liran Tal
 
JavaScript Supply Chain Security
Adam Baldwin
 
NPM ecosystem threats
Giacomo De Liberali
 
OWASP SF - Reviewing Modern JavaScript Applications
Lewis Ardern
 
Making 'npm install' Safe
C4Media
 
Webinar–Reviewing Modern JavaScript Applications
Synopsys Software Integrity Group
 
Node.js security tour
Giacomo De Liberali
 
Surrogate dependencies (in node js) v1.0
Dinis Cruz
 
ECMAScript 6 from an Attacker's Perspective - Breaking Frameworks, Sandboxes,...
Mario Heiderich
 
All about dependencies
Ixchel Ruiz
 
Node Security: The Good, Bad & Ugly
Bishan Singh
 
Manual JavaScript Analysis Is A Bug
Lewis Ardern
 
[OWASP Poland Day] A study of Electron security
OWASP
 
Infiltrating the Supply Chain Attack: Advanced Payload Delivery and Evasion T...
null - The Open Security Community
 
Getting Reactive with Cycle.js and xstream
Steve Lee
 
Node JS Roadmap for Beginners By Scholarhat PDF
Scholarhat
 
(In)Security Implication in the JS Universe
Stefano Di Paola
 
How to Enterprise Node
Julián David Duque
 
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
Julia Cherniak
 
Ad

More from Jarrod Overson (20)

PDF
Practical WebAssembly with Apex, wasmRS, and nanobus
Jarrod Overson
 
PDF
AppSecCali - How Credential Stuffing is Evolving
Jarrod Overson
 
PDF
How Credential Stuffing is Evolving - PasswordsCon 2019
Jarrod Overson
 
PDF
Deepfakes - How they work and what it means for the future
Jarrod Overson
 
PDF
The State of Credential Stuffing and the Future of Account Takeovers.
Jarrod Overson
 
PDF
How to Reverse Engineer Web Applications
Jarrod Overson
 
PDF
The life of breached data and the attack lifecycle
Jarrod Overson
 
PDF
The Life of Breached Data & The Dark Side of Security
Jarrod Overson
 
PDF
Shape Security @ WaffleJS October 16
Jarrod Overson
 
PDF
Graphics Programming for Web Developers
Jarrod Overson
 
PDF
The Dark Side of Security
Jarrod Overson
 
PDF
JavaScript and the AST
Jarrod Overson
 
PDF
ES2015 workflows
Jarrod Overson
 
PDF
Maintainability SFJS Sept 4 2014
Jarrod Overson
 
PDF
Idiot proofing your code
Jarrod Overson
 
PDF
Riot on the web - Kenote @ QCon Sao Paulo 2014
Jarrod Overson
 
PDF
Managing JavaScript Complexity in Teams - Fluent
Jarrod Overson
 
PDF
Real World Web components
Jarrod Overson
 
PDF
Managing JavaScript Complexity
Jarrod Overson
 
PDF
Continuous Delivery for the Web Platform
Jarrod Overson
 
Practical WebAssembly with Apex, wasmRS, and nanobus
Jarrod Overson
 
AppSecCali - How Credential Stuffing is Evolving
Jarrod Overson
 
How Credential Stuffing is Evolving - PasswordsCon 2019
Jarrod Overson
 
Deepfakes - How they work and what it means for the future
Jarrod Overson
 
The State of Credential Stuffing and the Future of Account Takeovers.
Jarrod Overson
 
How to Reverse Engineer Web Applications
Jarrod Overson
 
The life of breached data and the attack lifecycle
Jarrod Overson
 
The Life of Breached Data & The Dark Side of Security
Jarrod Overson
 
Shape Security @ WaffleJS October 16
Jarrod Overson
 
Graphics Programming for Web Developers
Jarrod Overson
 
The Dark Side of Security
Jarrod Overson
 
JavaScript and the AST
Jarrod Overson
 
ES2015 workflows
Jarrod Overson
 
Maintainability SFJS Sept 4 2014
Jarrod Overson
 
Idiot proofing your code
Jarrod Overson
 
Riot on the web - Kenote @ QCon Sao Paulo 2014
Jarrod Overson
 
Managing JavaScript Complexity in Teams - Fluent
Jarrod Overson
 
Real World Web components
Jarrod Overson
 
Managing JavaScript Complexity
Jarrod Overson
 
Continuous Delivery for the Web Platform
Jarrod Overson
 
Ad

Recently uploaded (20)

PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
Bitcoin+ Escalando sin concesiones - Parte 1
Fernando Paredes García
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
HydITEx corporation Booklet 2025 English
Георгий Феодориди
 
PDF
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
PDF
Upskill to Agentic Automation 2025 - Kickoff Meeting
DianaGray10
 
PDF
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
PDF
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
Bitcoin+ Escalando sin concesiones - Parte 1
Fernando Paredes García
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
HydITEx corporation Booklet 2025 English
Георгий Феодориди
 
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
Upskill to Agentic Automation 2025 - Kickoff Meeting
DianaGray10
 
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 

Analysis of an OSS supply chain attack - How did 8 millions developers download an exploit with no one noticing?