Rust implementation of The Update Framework (TUF)

Overview

rust-tuf

A Rust implementation of The Update Framework (TUF).

Full documentation is hosted at docs.rs.

Warning: Beta Software

This is under active development and may not suitable for production use. Further, the API is unstable and you should be prepared to refactor on even patch releases.

Contributing

Please make all pull requests to the develop branch.

Bugs

This project has a full disclosure policy on security related errors. Please treat these errors like all other bugs and file a public issue. Errors communicated via other channels will be immediately made public.

Legal

License

This work is dual licensed under the MIT and Apache-2.0 licenses. See LICENSE-MIT and LICENSE-APACHE for details.

Comments
  • Make fields length and hashes mandatory on MetadataDescription

    Make fields length and hashes mandatory on MetadataDescription

    The spec says they can be left out at times, but we might as well include them and bolt them down to be required and match in all cases. This would add a small amount of additional security during checks, but it would add additional security to the internals of the lib by preventing misusing the struct to not include fields when it should.

    I can't think of a reason not to do this (other than saving bytes in transit). @trishankkarthik, any thoughts?

    Priority :: Low Feature :: Improvement Flag :: Research 
    opened by heartsucker 14
  • Correctly implement the `Deserialize` trait

    Correctly implement the `Deserialize` trait

    Right now we do some hackiness where everything is assumed to be JSON coming in. While this is always the case in TUF, it's still doesn't feel right. And it also might be less efficient. Use the Visitor and other jazz from serde.

    Feature :: Specification Feature :: API Priority :: Low Feature :: Improvement 
    opened by heartsucker 14
  • Minimal working example

    Minimal working example

    I'm looking into tuf/rust-tuf for some update procedures.

    For now I'm failing to create a minimal working example and I'm not sure if it's just me or if there is a bug in the documentation that needs fixing. rust-tuf's src/lib.rs contains an example with a function get_original_root() that simply is unimplemented!(). I'm trying to fill the gap here.

    First, I have followed the TUF documentation to generate a directory structure to be served according to the documentation in https://github.com/theupdateframework/tuf/blob/develop/tuf/README.md. In a nutshell, the steps are:

    1. Generate RSA keys (root, targets, snapshot, timestamp);
    2. Create repository metadata;
    3. Create the actual repository.

    Step 1. is trivial, simply calling tuf.repository_tool.generate_and_write_rsa_keypair() for each key. Step 2. uses create_new_repository() and adds the keys to the repo. Step 3. walks the repository directory and signs files using add_targets().

    The problem I am facing comes from the call to rust-tuf's tuf::interchange::JsonDataInterchange::from_reader(). Since the get_original_root() function in unimplemented!(), I had to adapt it. It's returning a File, so I let it return File::open("repository/metadata/root.json").unwrap() where the json file was created by step 3 above. The from_reader() call fails though with a deserialization error:

    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Encoding("JSON: ErrorImpl { code: Message(\"missing field `key_id`\"), line: 7, column: 3 }")', src/libcore/result.rs:859
    

    I checked the files generated by tuf.repository_tool, and none contains the string key_id. The rust-tuf struct Signature seems to have one such field and is Deserialize so maybe this is where the error comes from?

    I might be loading the improper file in tuf::interchange::JsonDataInterchange::from_reader(), but then there is no file that contains the key_id field in tuf's generated files. Am I following the proper guide to initialize a repository (https://github.com/theupdateframework/tuf/blob/develop/tuf/README.md)?

    Note that I'm using rust-tuf c3321bf1295be66df46dcfb0440df491f2cf583f (branch develop) and tuf 904fa9b8df8ab8c632a210a2b05fd741e366788a (branch develop).

    Thanks!

    Priority :: Medium Feature :: Improvement 
    opened by nbigaouette-eai 12
  • Refactor delegation logic to only download delegations on-demand

    Refactor delegation logic to only download delegations on-demand

    Currently it recursively grabs everything to prevent future replays of old metadata in the event of a snapshot key compromise. This is going to be waaaaay too much metadata even in the simple static.rust-lang.org case because older targets would be relegated to an archive type delegation whichi would necessitate frequently updating many delegated roles.

    This is bad for local storage and bad for lots of requests / network IO.

    Priority :: Medium Feature :: Improvement 
    opened by heartsucker 11
  • repository/http: add a custom pre-send hook

    repository/http: add a custom pre-send hook

    This adds an optional user-provided boxed closure to HttpRepository which can be triggered to customize an HTTP request before sending it.

    Closes https://github.com/heartsucker/rust-tuf/issues/99

    opened by lucab 11
  • Serious, comprehensive docs on everything

    Serious, comprehensive docs on everything

    Right now there's just come cursory stuff, but since TUF is complex, all functions that deal with TUF things really need to explain what and why better. This lib tries to prevent someone from being able to do Bad Things, but I've probably lost perspective on what constitutes a simple mistake because I'm in this too deep. Thus. Way more docs.

    Priority :: Medium Feature :: Docs 
    opened by heartsucker 9
  • Current root metadata update scheme doesn't support post-compromise rollbacks

    Current root metadata update scheme doesn't support post-compromise rollbacks

    In the event of bad metadata, the client needs to rebuild the chain back from scratch. Imagine this

    Good keys: A -> B -> C --------------------> D
    Bad keys:            | -> D' -> E' -> F'
    

    Metadata/keys D could never be reached because the client can't hop from F' to D. Client need to know how to roll back and untrust metadata.

    Feature :: Specification Bug :: Medium Priority :: Medium Flag :: Research 
    opened by heartsucker 9
  • Convert Client::_fetch_target's lookup fn into a method

    Convert Client::_fetch_target's lookup fn into a method

    This is a minor simplification of Client::_fetch_target to factor out the interior lookup function in order to cut out on a number of variables being passed in as arguments.

    opened by erickt 7
  • bump dependencies

    bump dependencies

    This updates the dependencies the following dependencies to the latest version: derp, itoa, log, tempfile, lazy_static, maplit

    The only remaining outdated dependencies are on hyper (which is going to be a doozy to update) and untrusted, which is blocked on ring 0.13's release.

    opened by erickt 7
  • Client aborts on root key rotation when either the old key set or new key set has an unmet threshold

    Client aborts on root key rotation when either the old key set or new key set has an unmet threshold

    This was partially covered by #32, but I don't think the current test case is good enough.

    TODO

    Case 1:

    • 1.root.json has threshold 3 and keys 1, 2, and 3
    • 2.root.json has threshold 3 and keys 4, 5, 6
    • 2.root.json is signed with 1, 2, 4, 5, 6
    • client aborts

    Case 2:

    • 1.root.json has threshold 3 and keys 1, 2, and 3
    • 2.root.json has threshold 3 and keys 4, 5, 6
    • 2.root.json is signed with 1, 2, 3, 5, 6
    • client aborts

    Case 3:

    • 1.root.json has threshold 3 and keys 1, 2, and 3
    • 2.root.json has threshold 3 and keys 1, 2, and 4
    • 2.root.json is signed with 1, 2, 3
    • client aborts

    Case 4:

    • 1.root.json has threshold 3 and keys 1, 2, and 3
    • 2.root.json has threshold 3 and keys 1, 2, and 4
    • 2.root.json is signed with 1, 2, 4
    • client aborts

    Case 5:

    • 1.root.json has threshold 3 and keys 1, 2, and 3
    • 2.root.json has threshold 2 and keys 3, 4, and 5
    • 2.root.json is signed with 1, 2, 3, 4, 5
    • client continues
    Feature :: Specification Priority :: Medium Feature :: Test Case 
    opened by heartsucker 7
  • Convert Repository types to use interior mutability

    Convert Repository types to use interior mutability

    This changes Repository to use interior mutability in order to store state. At the moment, EphemeralRepository is the only repository type that stores state. By switching over to internally using Arc<Mutex<...>>> to wrap the state, it allows repositories to be used concurrently across threads. This trait will be especially important as we transition over to using asynchronous io with Hyper 0.11+.

    Another approach could be to wrap the repositories in Client with Arc<Mutex<...>>, but I'm worried that might lead to deadlocks with asynchronous use of the repositories.

    opened by erickt 6
  • Add handling of additional fields

    Add handling of additional fields

    From the TUF spec:

    All of the formats described below include the ability to add more attribute-value fields to objects for backwards-compatible format changes. Implementers who encounter undefined attribute-value pairs in the format must include the data when calculating hashes or verifying signatures and must preserve the data when re-serializing.

    This adjust the primary metadata structs to include an additional_fields member that collects any unknown top-level keys. Those fields are then available to users of the library as well as present when the struct is re-serialized to JSON.

    opened by lukesteensen 0
  • rust-tuf doesn't support diamond delegations

    rust-tuf doesn't support diamond delegations

    While writing a delegation builder, I noticed that while we have a test for diamond delegations, it doesn't actually work. Consider this delegation tree:

     targets
     /     \
    A       B
     \     /
        D
    

    Where D is signed correctly by B, but not signed correctly by A.

    Both Client::lookup_target_description and Client::target_description_with_start_time will visit:

    • targets
    • A
    • D (error, A did not sign D. marking as visited)
    • B
    • skip D since it was already visited.

    We need to update these delegations as visited only if we decided the delegation is trusted.

    opened by erickt 0
  • Create a security policy

    Create a security policy

    Description of issue or feature request:

    Similar to go-tuf, we should create a security policy so that researchers can properly disclose security issues.

    opened by trishankatdatadog 3
  • Tweaks to better interop with go-tuf

    Tweaks to better interop with go-tuf

    👋 I've been working on integrating the Vector project with Datadog's TUF/Uptane implementation, and this PR contains the handful of tweaks I've had to make to get everything interoperating happily:

    1. A spec_version of "1.0" is not actually valid according to SemVer. It should probably be "1.0.0" everywhere, but I've kept a check for the old value so that it continues to work with existing metadata.
    2. The datetime parsing was overly strict relative to the spec, which only specifies ISO8601. Here it's adjusted to use a full RFC3339 parser that handles the slightly differing format that go-tuf can emit.
    3. Allowing * in paths, which is legal according to the spec and used somewhat heavily when specifying delegations.
    4. Adding a couple of Send bounds, which isn't related to interop but made the library easier to use.

    The spec_version change does seem to break the interop tests, but I wanted to make sure we want to move forward with the change before doing the work of regenerating the test data.

    If any these seem undesirable or warrant more discussion, I'd be happy to split them into separate PRs.

    /cc @zenithar @cedricvanrompay-datadog

    opened by lukesteensen 11
  • TUF specification has a new version - v1.0.30

    TUF specification has a new version - v1.0.30

    opened by github-actions[bot] 0
link is a command and control framework written in rust

link link is a command and control framework written in rust. Currently in alpha. Table of Contents Introduction Features Feedback Build Process Ackno

null 427 Dec 24, 2022
A fuzzer framework built in Rust

lain This crate provides functionality one may find useful while developing a fuzzer. A recent nightly Rust build is required for the specialization f

Microsoft 469 Dec 9, 2022
Binary Analysis Framework in Rust

Welcome to Falcon Falcon is a formal binary analysis framework in Rust. Expression-based IL with strong influences from RREIL and Binary Ninja's LLIL.

Falcon Binary Analysis Framework 489 Dec 18, 2022
Semi-automatic OSINT framework and package manager

sn0int sn0int (pronounced /snoɪnt/) is a semi-automatic OSINT framework and package manager. It was built for IT security professionals and bug hunter

null 1.4k Dec 31, 2022
Bindings to the macOS Security.framework

macOS/iOS Security framework for Rust Documentation Bindings to the Apple's Security.framework. Allows use of TLS and Keychain from Rust. License Lice

Kornel 172 Jan 2, 2023
Record and Replay Framework

Overview rr is a lightweight tool for recording, replaying and debugging execution of applications (trees of processes and threads). Debugging extends

null 7.6k Jan 1, 2023
Lightweight slowloris (HTTP DoS) implementation in Rust.

slowlorust Lightweight slowloris (HTTP DoS) implementation in Rust. Slowloris is a denial-of-service attack program which allows an attacker to overwh

Michael Van Leeuwen 6 Sep 29, 2022
A paseto implementation in rust.

Paseto Rust Paseto is everything you love about JOSE (JWT, JWE, JWS) without any of the many design deficits that plague the JOSE standards. This is d

Instructure, Inc. 145 Nov 7, 2022
OpenSK is an open-source implementation for security keys written in Rust that supports both FIDO U2F and FIDO2 standards.

OpenSK This repository contains a Rust implementation of a FIDO2 authenticator. We developed OpenSK as a Tock OS application. We intend to bring a ful

Google 2.4k Jan 7, 2023
Userspace WireGuard® Implementation in Rust

BoringTun BoringTun is an implementation of the WireGuard® protocol designed for portability and speed. BoringTun is successfully deployed on millions

Cloudflare 4.8k Jan 4, 2023
A pure-Rust implementation of various threshold secret sharing schemes

Threshold Secret Sharing Efficient pure-Rust library for secret sharing, offering efficient share generation and reconstruction for both traditional S

Snips 137 Dec 29, 2022
A Rust implementation of the Message Layer Security group messaging protocol

Molasses An extremely early implementation of the Message Layer Security group messaging protocol. This repo is based on draft 4 of the MLS protocol s

Trail of Bits 109 Dec 13, 2022
Rust implementation of the H3 geospatial indexing system.

h3o Rust implementation of the H3 geospatial indexing system. Design This is not a binding of the reference implementation, but a reimplementation fro

Hydronium Labs 196 Jan 31, 2023
Fast, Concurrent, Rust based Tidal-Media-Downloader implementation.

tdl tdl is a rust implementation of the Python Script Tidal-Media-Downloader. Overview tdl offers significant performance improvements over the origin

null 42 Mar 18, 2023
An implementation of webauthn components for Rustlang servers

Webauthn-rs Webauthn is a modern approach to hardware based authentication, consisting of a user with an authenticator device, a browser or client tha

Kanidm 226 Dec 28, 2022
A simple port sniffer(scanner) implementation with 🦀

A simple port sniffer(scanner) implementation with ?? Install from crates.io crago install ports-sniffer From aur: yay -S ports-sniffer Arguments Argu

Anas Elgarhy 8 Oct 10, 2022
A Trojan implementation from SSPanel-Uim group

TrojanX A Trojan-based proxy implementation. Attention Early Version This is an early version. Security, features, and potential bugs may be insuffici

SSPanel-Uim 56 Apr 26, 2023
Detects usage of unsafe Rust in a Rust crate and its dependencies.

cargo-geiger ☢️ Looking for maintainer: https://github.com/rust-secure-code/cargo-geiger/issues/210 A program that lists statistics related to the usa

Rust Secure Code Working Group 1.1k Jan 4, 2023
An esoteric language/compiler written with Rust and Rust LLVM bindings

MeidoLang (メイドラング) A not so useful and esoteric language. The goal of this project was to contain some quirky or novel syntax in a stack-style program

null 0 Dec 24, 2021