summaryrefslogtreecommitdiff
path: root/lectures/10-software-repositories.org
blob: f791f168b657c6fa1f13b83de265b2d53b956645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#+title: Software Repositories
#+date: 2026-05-25 Mon
#+author: W. Kosior
#+email: wkosior@agh.edu.pl

* Do you remember…
…the days of searching online for an installer for some piece of software?

* Common Types of Software Distribution Channels
- OS distro repository
  - e.g., repositories of Debian, RedHat, BSD Ports
  - special cases: MSYS2, MacPorts
  - third-party upstream → packages
  - LTS / Bleeding Edge
  - main threats:
    - vulnerable packages not fixed in time
    - human choosing another, less secure channel :(

* Common Types of Software Distribution Channels, Cont.
- OS distro repository
- specialized software repository
  - aka programming language-specific software repository
    - some being cross-language
  - e.g., PyPI, Maven, npm Registry
  - programming libraries
  - main threats:
    - deliberate malware uploads
    - dependency constraints blocking security updates

* Common Types of Software Distribution Channels, Cont…
- OS distro repository
- specialized software repository
- software store
  - e.g., Microsoft Store, Google Play, F-Droid
  - applications
  - rarely the builders (except F-Droid)
  - main threats:
    - bundled dependencies not updated
    - deliberate malware uploads

* Common Types of Software Distribution Channels, Cont…
- OS distro repository
- specialized software repository
- software store
- container image repository
  - e.g., DockerHub
  - special case: FlatHub (a software store at the same time)
  - main threats:
    - bundled dependencies not updates
    - deliberate malware uploads

* *Typical* Characteristics of Software Distribution Channels
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |

* *Typical* Characteristics of Software Distribution Channels, Cont.
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |

* *Typical* Characteristics of Software Distribution Channels, Cont…
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |
| source- or binary-based    | varies         | varies             | binary             |

* *Typical* Characteristics of Software Distribution Channels, Cont…
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |
| source- or binary-based    | varies         | varies             | binary             |
| anyone can publish         | no             | yes                | yes                |
| author = uploader          | rarely         | usually            | usually            |

* *Typical* Characteristics of Software Distribution Channels, Cont…
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |
| source- or binary-based    | varies         | varies             | binary             |
| anyone can publish         | no             | yes                | yes                |
| author = uploader          | rarely         | usually            | usually            |
| packages signed by         | repo           | repo               | varies             |

* *Typical* Characteristics of Software Distribution Channels, Cont…
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |
| source- or binary-based    | varies         | varies             | binary             |
| anyone can publish         | no             | yes                | yes                |
| author = uploader          | rarely         | usually            | usually            |
| packages signed by         | repo           | repo               | varies             |
| pay to publish             | no             | no                 | sometimes          |
| pay to download            | no             | no                 | sometimes          |

* *Typical* Characteristics of Software Distribution Channels, Cont…
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |
| source- or binary-based    | varies         | varies             | binary             |
| anyone can publish         | no             | yes                | yes                |
| author = uploader          | rarely         | usually            | usually            |
| packages signed by         | repo           | repo               | varies             |
| pay to publish             | no             | no                 | sometimes          |
| pay to download            | no             | no                 | sometimes          |
| security by patching (lts) | varies         | sporadically       | no                 |
| security by updating (be)  | varies         | yes                | yes                |

* *Typical* Characteristics of Software Distribution Channels
|                            | OS distro repo | specialized repo   | "store"            |
|----------------------------+​----------------+​--------------------+--------------------|
| deps are separate packages | yes            | yes                | sometimes          |
| package counts             | <= several 10k | <= several million | <= several million |
| source- or binary-based    | varies         | varies             | binary             |
| anyone can publish         | no             | yes                | yes                |
| author = uploader          | rarely         | usually            | usually            |
| packages signed by         | repo           | repo               | varies             |
| pay to publish             | no             | no                 | sometimes          |
| pay to download            | no             | no                 | sometimes          |
| security by patching (lts) | varies         | sporadically       | no                 |
| security by updating (be)  | varies         | yes                | yes                |
| targets                    | users&devs     | mostly devs        | mostly users       |

* LTS vs Bleeding Edge
- always get newest versions of software
  - "rolling release", aka "bleeding edge"
  - Arch, Fedora Rawhide, OpenSUSE Tumbleween, Debian Unstable, etc.
  - vulnerabilities → update to newer version

* LTS vs Bleeding Edge, Cont.
- always get newest versions of software
  - "rolling release", aka "bleeding edge"
  - Arch, Fedora Rawhide, OpenSUSE Tumbleween, Debian Unstable, etc.
  - vulnerabilities → update to newer version
- what about stability?
  - snapshot current software versions
  - use snapshotted version for the next X years
    - exceptions
  - "stable release", aka "LTS"
  - Debian, openSUSE Leap, Fedora
  - vulnerabilities → patch the old version
    - or use LTS updates when offered by upstream

* LTS in Debian
- Debian Unstable — bleeding edge versions
- Debian Testing
  - snapshot of Debian Unstable
  - kept for a few months to stabilize
- Debian Stable
  - made from Debian Testing
- oldstable
  - made from Stable once a new Stable kicks in
  - still receives security fixes for some time

* Patch or Update?
- updating
  - less work
  - the only viable option for, e.g., Mozilla browsers
- patching
  - number of vulnerabilities *only decreases* :)

* XZ Backdoor
- Backdoor targeting SSH daemons
  - Debian, Ubuntu, Fedora, et al
- through XZ compression library
- backdoored XZ source release tarball
  - built by distros
- detected in Debian Unstable in 2024
  - before getting to Stable
  - already included in, e.g., openSUSE Tumbleweed
- https://i.kym-cdn.com/photos/images/original/002/785/376/4db.png

* From Source to Installed software
- security guidance (OWASP et al) → SBoM
  - far from enough!
  - just what we *think* is in our system
- https://slsa.dev/spec/v1.2/threats-overview
  - decent categorization ;)
- distro software → securable (with some shortcomings)
- specialized repo software → hard to secure deps
- container images (DockerHub) → hard to secure deps

* The Bazaar Model
- "The Cathedral and the Bazaar"
  - essay by Eric S. Raymond
  - 1997
- two free/libre software development models
- "given enough eyeballs, all bugs are shallow"
  - blobs in source :(
    - distro with guidelines →
    - → higher hygiene →
    - → smaller attack surface

* Who Builds It?
- author?
  - typical npm package → hundreds dependencies
    - (including recursive and dev deps)
    - hundreds of developer PCs
    - how hard is it to compromise at least one?
- repo?
  - required distro resources
  - rebuildability → required higher packaging hygiene
    - a good thing, actually
- "trusted" third party?
  - provenance attestation
    - Github Actions
    - GitLab CI/CD
    - lock-in :(
- end machine (source-based distribution)?

* Builds by Repo — nuances
- Debian — binary uploads used sporadically (e.g., backports)
- F-Droid — developer signature or repo signature?

* Build Machine — SPOF
- SolarWinds (Sunburst) backdoor
- reproducible builds (future lecture)

* Hidden Dependencies
- build container security
  - what GitHub Actions' Ubuntu image had inside at build time?
- downloaded deps & other files
  - we downloaded a web browser as part of automated tests
    - was it not compromised?
  - remedies
    - verification with a hash?
    - mandate network-less builds?

* VCS vs Release Tarballs
- tarballs: traditional form
  - scripts pre-generated by maintainer (Autotools)
  - typically PGP-signed
  - modified tarballs
    - e.g., Debian FSDG compliance
- version control system
  - commits can be PGP-signed
  - does not include =configure= from Autoconf, etc.
    - may not be rebuildable
  - signed commits/tags possible
- XZ backdoor
  - fewer eyeballs look into tarballs
  - *please build from VCS* 🥺

* Repository → Machine
- signed package lists
  - offline search
  - not archived in, e.g., Debian
  - downgrade attack possibility?
- online querying
  - specialized (aka language-specific) repos
- repo public key used
- distributon major version update?
  - subsequent LTS public keys distributed in old

* Sample Package Formats — Debian (=control= file)
#+begin_src
Source: python-immutables
Maintainer: John Smith <js@example.org>
Section: devel
Priority: optional
Standards-Version: 4.3.0
Build-Depends: debhelper (>= 11), dh-python, python3-all-dev (>= 3.6),
 python3-setuptools (>= 45),
# also add test dependencies
 python3-pytest, python3-pytest-flake8, python3-mypy

Package: python3-immutables
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends}
X-Python3-Version: >= 3.6
Description: an immutable mapping type for Python
 This library provides an immutable alternative to Python's native 'dict'.
 The data structure used if Hash Array Mapped Trie (HAMT) which is also utilized
 by some functional languages.
#+end_src

* Sample Package Formats — Debian (=rules= file)
#+begin_src
#! /usr/bin/make -f

# Immutables debian/rules file

#export DH_VERBOSE = 1
export PYBUILD_NAME = immutables
export PYBUILD_TEST_PYTEST = 1

%:
	MYPYPATH=$$(pwd) dh $@ --with python3 --buildsystem=pybuild
#+end_src

* Extra: XZ Backdoor Presentation
- https://git.koszko.org/AGH-xz-backdoor-presentation/