Skip to content

Commit

Permalink
Add ctap fuzz target
Browse files Browse the repository at this point in the history
This fuzz target sends a sequence of arbitrary CTAP1 or CTAP2 requests
to the authenticator.
  • Loading branch information
robin-nitrokey committed Jun 26, 2024
1 parent 79b05b5 commit 0a91cb7
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
31 changes: 31 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "fido-authenticator-fuzz"
version = "0.0.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
ctap-types = { version = "0.2.0", features = ["arbitrary"] }
libfuzzer-sys = "0.4"
trussed-staging = { version = "0.3.0", features = ["chunked", "hkdf", "virt"] }

[dependencies.fido-authenticator]
path = ".."

[[bin]]
name = "ctap"
path = "fuzz_targets/ctap.rs"
test = false
doc = false
bench = false

[patch.crates-io]
ctap-types = { git = "https://github.com/trussed-dev/ctap-types.git", branch = "arbitrary" }
littlefs2 = { git = "https://github.com/trussed-dev/littlefs2.git", rev = "2b45a7559ff44260c6dd693e4cb61f54ae5efc53" }
trussed = { git = "https://github.com/trussed-dev/trussed.git", rev = "b548d379dcbd67d29453d94847b7bc33ae92e673" }
trussed-chunked = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "chunked-v0.1.0" }
trussed-hkdf = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "hkdf-v0.2.0" }
trussed-staging = { git = "https://github.com/trussed-dev/trussed-staging.git", tag = "v0.3.0" }
34 changes: 34 additions & 0 deletions fuzz/fuzz_targets/ctap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#![no_main]

use ctap_types::{authenticator::Request, ctap1::Authenticator as _, ctap2::Authenticator as _};
use fido_authenticator::{Authenticator, Config, Conforming};
use trussed_staging::virt;

use libfuzzer_sys::fuzz_target;

fuzz_target!(|requests: Vec<Request<'_>>| {
virt::with_ram_client("fido", |client| {
let mut authenticator = Authenticator::new(
client,
Conforming {},
Config {
max_msg_size: 0,
skip_up_timeout: None,
max_resident_credential_count: None,
large_blobs: None,
nfc_transport: false,
},
);

for request in requests {
match request {
Request::Ctap1(request) => {
authenticator.call_ctap1(&request).ok();
}
Request::Ctap2(request) => {
authenticator.call_ctap2(&request).ok();
}
}
}
});
});

0 comments on commit 0a91cb7

Please sign in to comment.