Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Keeping JavaScript safe
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
C J Silverio
October 04, 2017
Programming
3
470
Keeping JavaScript safe
Security & the npm registry. Presented at Node Interactive 2017 in Vancouver.
C J Silverio
October 04, 2017
Tweet
Share
More Decks by C J Silverio
See All by C J Silverio
The economics of package management
ceejbot
4
1.6k
The future of (javascript) modules (in node)
ceejbot
1
300
ceej's how to solve it
ceejbot
6
770
work-life balance at npm
ceejbot
5
790
hash functions and you!
ceejbot
2
360
The accidental noder
ceejbot
2
160
Design Patterns & Modularity in the npm Registry
ceejbot
3
200
Monitoring on a budget
ceejbot
2
300
Cheating Gall's Law: MediterraneaJS edition
ceejbot
4
340
Other Decks in Programming
See All in Programming
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
120
CSC307 Lecture 05
javiergs
PRO
0
490
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
630
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
0
100
Apache Iceberg V3 and migration to V3
tomtanaka
0
120
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
7
1k
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
370
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
820
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
260
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
950
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
220
Rails Girls Zürich Keynote
gr2m
96
14k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
61
49k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
150
Design in an AI World
tapps
0
140
Building an army of robots
kneath
306
46k
Why Our Code Smells
bkeepers
PRO
340
58k
For a Future-Friendly Web
brad_frost
182
10k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
230
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
Transcript
keeping javascript safe
keeping javascript safe security & the npm registry
C J Silverio CTO @ npm, @ceejbot
using node since 2011 node has grown up!
running npm's registry since 2014 npm has grown up too!
the story of the npm registry mirrors the story of
node
npm is infrastructure for millions of developers
npm dependably serves node packages 24/7 around the world
Fortune 100 companies depend on npm & node
3 billion downloads/week 9 million users 156K package authors (1.7%)
npm has as many users as the New York City
it didn't start that way
in 2009, node & npm's users knew each other by
name
the npm registry is now too large to depend on
community policing
but you need that policing
you rely on the packages you install
questions you ask 1. Is the registry secure? 2. Does
this package have vulnerabilities? 3. Is this package malware? 4. Who published this package?
1. Is the registry secure?
What does secure mean? registry systems can't be broken into
data can't be tampered with
we don't try to do this alone ongoing contract with
^Li!
this guy, Adam Baldwin (he'll come up again) & his
colleagues
periodic pen testing ongoing code reviews
good security practices are on-going work
2. Does this package have vulnerabilities?
our friends at ^Li! again as the Node Security Platform
NSP reviews popular packages, reports vulnerabilities, & handles reports
h!ps://nodesecurity.io
early access NSP data is integrated into npm enterprise
newsflash! npm is a company that sells services!
npm enterprise is a registry inside your firewall
NSP keeps us informed we keep them informed in turn
3. Is this package malware?
malware doesn't advertise
malware comes in flavors: spam & poison
spammers found the registry in 2016
two kinds of spam: spam content & js spam support
npm + cdns built on top == trivial hosting for
GA clickjacking
now using machine learning to catch spam thanks to the
Smyte service
spam speedbumps: validated email to publish disallow throwaway addresses
we seem to have made a dent but this war
will never end
poison-flavored malware: typosqua!ing
publishing packages with names that are very close to real
names
Historically this was competitive: authors would try to steal traffic
to pump their download numbers
somebody typosqua!ed moment.js with another date-forma!ing package
also accidental JSONStream vs jsonstream
recently it's been nefarious: typosquat of cross-env as crossenv with
a env var stealer
typosquat of bluebird wrapping bluebird with a cryptocoin miner
Adam Baldwin typosqua!ed coffee-script early on
it took days for the community to notice
now it takes weeks if the community notices at all
as spiderman said, with great popularity comes great annoyance
automated similarity checker
None
this war will never end so long as there is
$ to be made
4. Who published this package?
What happens if somebody steals JDD's auth token & posts
malware as lodash?
Well, that's scary. npm auth tokens are sensitive.
new! tools in the npm cli to help you control
auth tokens
new command: npm token control your auth tokens
npm token create --readonly
read-only auth tokens the principle of least power
give your CI system a read-only token
npm token create --cidr=[10.0.0.1/32]
CIDR-bound tokens bind tokens to IP ranges
further limit your tokens by controlling where they can be
used
npm token list npm token delete <tokenKey>
None
new command: npm profile
set your profile data like your email or ...
None
well that's boring
None
that's not boring
npm profile enable-2fa two-factor authentication is here
require regular password plus a one-time password
npm profile enable-2fa auth-only
auth-only: any time you log in or manipulate tokens
npm profile enable-2fa auth-and-writes
None
writes: your package publications pass the --otp flag
npm publish --otp=123456 pass it on the command line!
use a TOTP code generation app Google Authenticator, Authy, etc
npm install -g npm@next try it now!
code: github.com/npm/npm-profile api docs: github.com/npm/registry
one more thing
coming a!raction! protect a package with 2FA
require an OTP any time that package is published by
anybody
protect packages with many maintainers next cli minor release 5.6.0
coming soon! 2fa for your npm organization
coming soon! npm ci 3x speed for your CI installs
but what about package signing? we think we've figured out
how
coming soon! even more
questions? help se!ing this up? come see me & puppies
at the npm booth
npm wants you to develop in confidence
npm loves you