(4) NuGet Version
fixed: 1.2.3
range: (,1.2.3]
floating: 1.2.*
26
Slide 27
Slide 27 text
Who in this room…
… changed a nuget.config file?
27
Slide 28
Slide 28 text
(5) NuGet Package Source
feed
central storage
28
Slide 29
Slide 29 text
Who in this room…
… uses both public (nuget.org) and
private package sources?
29
Slide 30
Slide 30 text
(6) NuGet Package Resolution
My Code
NuGet
.exe
or
dotnet
restore
build machine
30
Slide 31
Slide 31 text
(6) NuGet Package Resolution
My Code
build machine
31
Nu
Get
.exe
Slide 32
Slide 32 text
(6) NuGet Package Resolution
SOURCE 2
SOURCE 1
Foo
5.3.0
Foo
5.3.1
build machine network calls
32
My Code
Nu
Get
.exe
Slide 33
Slide 33 text
SOURCE 2
SOURCE 1
Give me:
- Foo
5.3.*
Foo
5.3.0
Foo
5.3.1
33
(6) NuGet Package Resolution
My Code
Nu
Get
.exe
Slide 34
Slide 34 text
Nu
Get
.exe
Foo
5.3.1
Best match
from ALL
sources is:
- Foo 5.3.1
Foo
5.3.0
SOURCE 1
SOURCE 2
34
(6) NuGet Package Resolution
My Code
Slide 35
Slide 35 text
SOURCE 1
Foo
5.3.1
Foo
5.3.1
Give me:
- Foo 5.3.*
Give me:
- Foo
5.3.1 SOURCE 2
35
(6) NuGet Package Resolution
My Code
Nu
Get
.exe
Slide 36
Slide 36 text
Nu
Get
.exe
SOURCE 1
Foo
5.3.1
Foo
5.3.1
SOURCE 2
36
(6) NuGet Package Resolution
My Code
Slide 37
Slide 37 text
Plan (2/3)
typosquatting
substitution attack
37
Slide 38
Slide 38 text
Attacks
Mr. Evil HACKER
30.08.2022
38
Slide 39
Slide 39 text
Why
39
Slide 40
Slide 40 text
Typosquatting
40
Slide 41
Slide 41 text
Typosquatting
My Code
Google.Protobuf
5.3.2
Give me:
Gogle.Protobuf
5.3.2
NUGET.ORG
Nu
Get
.exe
41
Slide 42
Slide 42 text
Typosquatting
My Code
Google.Protobuf
5.3.2
Give me:
Gogle.Protobuf
5.3.2
NUGET.ORG
Nu
Get
.exe
42
Slide 43
Slide 43 text
Typosquatting
My Code
Google.Protobuf
5.3.2 Gogle.Protobuf
5.3.2
Give me:
Gogle.Protobuf
5.3.2
NUGET.ORG
Nu
Get
.exe
43
Slide 44
Slide 44 text
Nu
Get
.exe
Typosquatting
My Code
Here you are:
Gogle.Protobuf
5.3.2
Gogle.Protobuf
5.3.2
NUGET.ORG
44
Slide 45
Slide 45 text
Demo 0
45
Slide 46
Slide 46 text
Substitution attack
46
Slide 47
Slide 47 text
PRIVATE SOURCE
Substitution attack
My Code
Corporate.Private.Library
5.3.1
Give me:
- Foo 5.3.*
Give me:
Corporate.Private.Library
5.3.1
NUGET.ORG
Nu
Get
.exe
47
Slide 48
Slide 48 text
PRIVATE SOURCE
Substitution attack
NUGET.ORG
My Code
Give me:
Corporate.Private.Library
5.3.1
Corporate.Private.Library
5.3.1
Nu
Get
.exe
48
Slide 49
Slide 49 text
PRIVATE SOURCE
Substitution attack
Corporate.Private.Library
5.3.1
NUGET.ORG
My Code
Give me:
Corporate.Private.Library
5.3.1
Corporate.Private.Library
5.3.1
Nu
Get
.exe
49
Slide 50
Slide 50 text
PRIVATE SOURCE
Substitution attack
NUGET.ORG
My Code
Corporate.Private.Library
5.3.1
Corporate.Private.Library
5.3.1
Nu
Get
.exe
50
Slide 51
Slide 51 text
PRIVATE SOURCE
Substitution attack
Give me:
- Foo 5.3.*
Give me:
Corporate.Private.Library
5.3.* NUGET.ORG
My Code
Corporate.Private.Library
5.3.1 Corporate.Private.Library
5.3.2
Nu
Get
.exe
51
Slide 52
Slide 52 text
PRIVATE SOURCE
Substitution attack
NUGET.ORG
My Code
Corporate.Private.Library
5.3.1 Corporate.Private.Library
5.3.2
Give me:
Corporate.Private.Library
5.3.*
Corporate.Private.Library
5.3.999
Nu
Get
.exe
52
Slide 53
Slide 53 text
Nu
Get
.exe
PRIVATE SOURCE
Substitution attack
Here you are:
Corporate.Private.Library
5.3.999
NUGET.ORG
My Code
Corporate.Private.Library
5.3.1 Corporate.Private.Library
5.3.2
Corporate.Private.Library
5.3.999
53
Slide 54
Slide 54 text
Demo 1
54
Slide 55
Slide 55 text
Plan (3/3)
Protect when
- Consuming
- Publishing
55
Credits
In 2020, security researcher Alex Bîrsan used
substitution attack to hack into:
78
Slide 79
Slide 79 text
Credits
79
● Microsoft
● Apple
● Shopify
● Paypal
● … and another 31 big companies …
In 2020, security researcher Alex Bîrsan used
substitution attack to hack into:
Slide 80
Slide 80 text
Credits
80
● Microsoft $ 40K
● Apple $ 30K
● Shopify $ 30K
● Paypal $ 30K
● … and another 31 big companies …
Bug
bounties
In 2020, security researcher Alex Bîrsan used
substitution attack to hack into:
Slide 81
Slide 81 text
1. Package Source Mapping
2.
3. Reserve prefixes on nuget.org
81
Do not let win!
Slide 82
Slide 82 text
📄🔗
andreiepure.ro
82
Slide 83
Slide 83 text
Extra slides
83
Slide 84
Slide 84 text
Deterministic Builds
This allows mapping of a package to a specific
commit: increase transparency and allow
consumers to audit open-source code.
84
Slide 85
Slide 85 text
Fixed Versions
- it is safer to use fixed versions
(have full knowledge and control over the
supply chain)
85
Slide 86
Slide 86 text
packages.lock.json
- have control over all dependencies (direct
and transitive)
- extra mile: verify checksums
(have full knowledge and control over the
supply chain)
86