Skip to content

Commit c860dca

Browse files
ericktlukpueh
authored andcommitted
Checking version after verifying signatures
In section 5.3.1 and section 5.4.1 of the spec, the first part of verifying a new snapshot, targets, and delegated targets role requires checking the new role's version number before we've checked that these new roles were signed by the root role. This exposes TUF clients to potential parser bugs which allows an attacker to potentially compromise the system. For example, consider a man-in-the-middle attacker that has a parser bug which allows for executing arbitrary code, such as [CVE-2017-18349]. An attacker could exploit this in a few manners: 1. [POUF-1] inlines the metadata signatures in with the role JSON metadata file. While snapshot, targets, and delegated targets can have their hashes listed in trusted metadata (and thus be validated before parsing), the timestamp role must be parsed in order to verify it was signed by the trusted root role. 2. TUF-1.0.5 Section 5.3.1 of the workflow states the snapshot should be verified by hash and version number before checking the signature. While we could verify the hash before parsing, the spec doesn't state that the hash should be checked first. It's possible then for a conformant TUF client to check the version number before hash, which would expose the client to the parser bug. 3. TUF-1.0.5 Section 4.4 and 5.4.1 make it optional for the snapshot role to contain the hashes of the targets and any delegated targets role. If left out, we need to still parse these files to check the version number before validating the signatures. This patch addresses (2) and (3) by moving the verification of the version number to after we've verified a role was properly signed by the trusted root role. This would enable a future POUF that's addressed (1) to avoid future parser exploits. [POUF-1]: https://github.com/theupdateframework/taps/blob/master/POUFs/reference-POUF/pouf1.md [CVE-2017-18349]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-18349
1 parent d821e90 commit c860dca

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

tuf-spec.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Last modified: **30 September 2020**
44

5-
Version: **1.0.9**
5+
Version: **1.0.10**
66

77
We strive to make the specification easy to implement, so if you come across
88
any inconsistencies or experience any difficulty, do let us know by sending an
@@ -1191,19 +1191,25 @@ of the form VERSION_NUMBER.FILENAME.EXT (e.g., 42.snapshot.json), where
11911191
VERSION_NUMBER is the version number of the snapshot metadata file listed in
11921192
the timestamp metadata file.
11931193

1194-
* **5.3.1**. **Check against timestamp metadata.** The hashes and version
1195-
number of the new snapshot metadata file MUST match the hashes, if any, and
1196-
version number listed in the trusted timestamp metadata. If hashes and
1197-
version do not match, discard the new snapshot metadata, abort the update
1198-
cycle, and report the failure.
1194+
* **5.3.1**. **Check against timestamp role's snapshot hash.** The hashes
1195+
of the new snapshot metadata file MUST match the hashes, if any, listed in
1196+
the trusted timestamp metadata. This is done, in part, to prevent a
1197+
mix-and-match attack by man-in-the-middle attackers. If the hashes do not
1198+
match, discard the new snapshot metadata, abort the update cycle, and report
1199+
the failure.
11991200

12001201
* **5.3.2**. **Check for an arbitrary software attack.** The new snapshot
12011202
metadata file MUST have been signed by a threshold of keys specified in the
12021203
trusted root metadata file. If the new snapshot metadata file is not signed
12031204
as required, discard it, abort the update cycle, and report the signature
12041205
failure.
12051206

1206-
* **5.3.3**. **Check for a rollback attack.** The version number of the targets
1207+
* **5.3.3**. **Check against timestamp role's snapshot version.** The version
1208+
number of the new snapshot metadata file MUST match the version number listed
1209+
in the trusted timestamp metadata. If the versions do not match, discard the
1210+
new snapshot metadata, abort the update cycle, and report the failure.
1211+
1212+
* **5.3.4**. **Check for a rollback attack.** The version number of the targets
12071213
metadata file, and all delegated targets metadata files, if any, in the
12081214
trusted snapshot metadata file, if any, MUST be less than or equal to its
12091215
version number in the new snapshot metadata file. Furthermore, any targets
@@ -1212,13 +1218,14 @@ the timestamp metadata file.
12121218
these conditions are not met, discard the new snapshot metadata file, abort
12131219
the update cycle, and report the failure.
12141220

1215-
* **5.3.4**. **Check for a freeze attack.** The latest known time MUST be
1221+
* **5.3.5**. **Check for a freeze attack.** The latest known time MUST be
12161222
lower than the expiration timestamp in the new snapshot metadata file. If
12171223
so, the new snapshot metadata file becomes the trusted snapshot metadata
12181224
file. If the new snapshot metadata file is expired, discard it, abort the
12191225
update cycle, and report the potential freeze attack.
12201226

1221-
* **5.3.5**. **Persist snapshot metadata.** The client MUST write the file to
1227+
1228+
* **5.3.6**. **Persist snapshot metadata.** The client MUST write the file to
12221229
non-volatile storage as FILENAME.EXT (e.g. snapshot.json).
12231230

12241231
**5.4**. **Download the top-level targets metadata file**, up to either the
@@ -1231,51 +1238,56 @@ of the form VERSION_NUMBER.FILENAME.EXT (e.g., 42.targets.json), where
12311238
VERSION_NUMBER is the version number of the targets metadata file listed in the
12321239
snapshot metadata file.
12331240

1234-
* **5.4.1**. **Check against snapshot metadata.** The hashes and version
1235-
number of the new targets metadata file MUST match the hashes, if any, and
1236-
version number listed in the trusted snapshot metadata. This is done, in
1237-
part, to prevent a mix-and-match attack by man-in-the-middle attackers. If
1238-
the new targets metadata file does not match, discard it, abort the update
1239-
cycle, and report the failure.
1241+
* **5.4.1**. **Check against snapshot role's targets hash.** The hashes
1242+
of the new targets metadata file MUST match the hashes, if any, listed in the
1243+
trusted snapshot metadata. This is done, in part, to prevent a mix-and-match
1244+
attack by man-in-the-middle attackers. If the new targets metadata file does
1245+
not match, discard the new target metadata, abort the update cycle, and
1246+
report the failure.
12401247

12411248
* **5.4.2**. **Check for an arbitrary software attack.** The new targets
12421249
metadata file MUST have been signed by a threshold of keys specified in the
12431250
trusted root metadata file. If the new targets metadata file is not signed
12441251
as required, discard it, abort the update cycle, and report the failure.
12451252

1246-
* **5.4.3**. **Check for a freeze attack.** The latest known time MUST be
1253+
* **5.4.3**. **Check against snapshot role's targets version.** The version
1254+
number of the new targets metadata file MUST match the version number listed
1255+
in the trusted snapshot metadata. If the versions do not match, discard it,
1256+
abort the update cycle, and report the failure.
1257+
1258+
* **5.4.4**. **Check for a freeze attack.** The latest known time MUST be
12471259
lower than the expiration timestamp in the new targets metadata file. If so,
12481260
the new targets metadata file becomes the trusted targets metadata file. If
12491261
the new targets metadata file is expired, discard it, abort the update cycle,
12501262
and report the potential freeze attack.
12511263

1252-
* **5.4.4**. **Persist targets metadata.** The client MUST write the file to
1264+
* **5.4.5**. **Persist targets metadata.** The client MUST write the file to
12531265
non-volatile storage as FILENAME.EXT (e.g. targets.json).
12541266

1255-
* **5.4.5**. **Perform a pre-order depth-first search for metadata about the
1267+
* **5.4.6**. **Perform a pre-order depth-first search for metadata about the
12561268
desired target, beginning with the top-level targets role.** Note: If
1257-
any metadata requested in steps 5.4.5.1 - 5.4.5.2 cannot be downloaded nor
1269+
any metadata requested in steps 5.4.6.1 - 5.4.6.2 cannot be downloaded nor
12581270
validated, end the search and report that the target cannot be found.
12591271

1260-
* **5.4.5.1**. If this role has been visited before, then skip this role
1272+
* **5.4.6.1**. If this role has been visited before, then skip this role
12611273
(so that cycles in the delegation graph are avoided). Otherwise, if an
12621274
application-specific maximum number of roles have been visited, then go to
12631275
step 5.5 (so that attackers cannot cause the client to waste excessive
12641276
bandwidth or time). Otherwise, if this role contains metadata about the
12651277
desired target, then go to step 5.5.
12661278

1267-
* **5.4.5.2**. Otherwise, recursively search the list of delegations in
1279+
* **5.4.6.2**. Otherwise, recursively search the list of delegations in
12681280
order of appearance.
12691281

1270-
* **5.4.5.2.1**. If the current delegation is a multi-role delegation,
1282+
* **5.4.6.2.1**. If the current delegation is a multi-role delegation,
12711283
recursively visit each role, and check that each has signed exactly the
12721284
same non-custom metadata (i.e., length and hashes) about the target (or
12731285
the lack of any such metadata).
12741286

1275-
* **5.4.5.2.2**. If the current delegation is a terminating delegation,
1287+
* **5.4.6.2.2**. If the current delegation is a terminating delegation,
12761288
then jump to step 5.5.
12771289

1278-
* **5.4.5.2.3**. Otherwise, if the current delegation is a
1290+
* **5.4.6.2.3**. Otherwise, if the current delegation is a
12791291
non-terminating delegation, continue processing the next delegation, if
12801292
any. Stop the search, and jump to step 5.5 as soon as a delegation
12811293
returns a result.

0 commit comments

Comments
 (0)