-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial fuzzing support Stability fixes for the flaws found during the fuzzing Add missed algorithm descriptor for the authentication Use own Flexiber fork Fixes #8
- Loading branch information
Showing
8 changed files
with
162 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[package] | ||
name = "oath-authenticator-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
apdu-dispatch = { version = "0.1", optional = true } | ||
flexiber = { version = "0.1.0", features = ["derive", "heapless"] } | ||
heapless = "0.7" | ||
heapless-bytes = "0.3" | ||
hex-literal = "0.3" | ||
interchange = "0.2" | ||
iso7816 = "0.1" | ||
serde = { version = "1", default-features = false } | ||
trussed = { version = "0.1.0", features = ["virt", "verbose-tests"] } | ||
ctaphid-dispatch = { version = "0.1", optional = true } | ||
usbd-ctaphid = { git = "https://github.com/Nitrokey/nitrokey-3-firmware", optional = true } | ||
|
||
[dependencies.oath-authenticator] | ||
path = ".." | ||
|
||
[features] | ||
default = ["ctaphid-dispatch", "usbd-ctaphid", "apdu-dispatch"] | ||
|
||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[profile.release] | ||
debug = 1 | ||
|
||
[[bin]] | ||
name = "fuzz_target_1" | ||
path = "fuzz_targets/fuzz_target_1.rs" | ||
test = false | ||
doc = false | ||
|
||
|
||
[patch.crates-io] | ||
trussed = { git = "https://github.com/trussed-dev/trussed", branch = "main" } | ||
flexiber = { git = "https://github.com/Nitrokey/flexiber", branch = "oath-authenticator" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (C) 2022 Nitrokey GmbH | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
FUZZ_DURATION?="0" | ||
FUZZ_JOBS?=$(shell nproc) | ||
.NOTPARALLEL: | ||
|
||
.PHONY: check | ||
check: | ||
reuse lint | ||
|
||
.PHONY: fuzz | ||
fuzz: | ||
nice cargo +nightly fuzz run --jobs ${FUZZ_JOBS} fuzz_target_1 corpus -- -max_total_time=${FUZZ_DURATION} | ||
|
||
.PHONY: fuzz-cov | ||
fuzz-cov: | ||
cargo +nightly fuzz coverage fuzz_target_1 corpus | ||
$(MAKE) fuzz-cov-show | ||
|
||
LLVMCOV=~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov | ||
.PHONY: fuzz-cov-show | ||
fuzz-cov-show: | ||
$(LLVMCOV) show --format=html \ | ||
--instr-profile=coverage/fuzz_target_1/coverage.profdata \ | ||
${CARGO_TARGET_DIR}/x86_64-unknown-linux-gnu/release/fuzz_target_1 \ | ||
> fuzz_coverage.html | ||
|
||
.PHONY: ci | ||
ci: check | ||
|
||
.PHONY: setup | ||
setup: | ||
rustup component add clippy rustfmt && rustup toolchain install nightly | ||
rustup component add llvm-tools-preview | ||
cargo install cargo-tarpaulin cargo-fuzz --profile release | ||
python3 -m pip install reuse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
trussed::virt::with_ram_client("oath", move |client| { | ||
let mut oath = oath_authenticator::Authenticator::<_>::new(client); | ||
let mut response = heapless::Vec::<u8, { 3 * 1024 }>::new(); | ||
|
||
if let Ok(command) = iso7816::Command::<{ 10 * 255 }>::try_from(&data) { | ||
oath.respond(&command, &mut response).ok(); | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters