Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Set an upper bound of allowed root rotations to 1000.
Browse files Browse the repository at this point in the history
The idea is to try to better handle the scenario where the server keeps
unceasingly providing valid metadata, which could be a sort of bizarre
attack.

Suggested-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
  • Loading branch information
pattivacek committed Jan 6, 2020
1 parent 0419df6 commit ff053f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libaktualizr/uptane/uptanerepository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool RepositoryCommon::updateRoot(INvStorage& storage, const IMetadataFetcher& f
}

// 5.4.4.3.2. Update to the latest Root metadata file.
for (int version = rootVersion() + 1;; ++version) {
for (int version = rootVersion() + 1; version < kMaxRotations; ++version) {
// 5.4.4.3.2.2. Try downloading a new version N+1 of the Root metadata file.
std::string root_raw;
if (!fetcher.fetchRole(&root_raw, kMaxRootSize, repo_type, Role::Root(), Version(version))) {
Expand Down
2 changes: 2 additions & 0 deletions src/libaktualizr/uptane/uptanerepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class RepositoryCommon {
void resetRoot();
bool updateRoot(INvStorage &storage, const IMetadataFetcher &fetcher, RepositoryType repo_type);

static const int64_t kMaxRotations = 1000;

Root root;
RepositoryType type;
};
Expand Down

0 comments on commit ff053f9

Please sign in to comment.