Skip to content

daemon: add optional in-memory test authenticator - #259

Open
kpanuragh wants to merge 1 commit into
linux-credentials:mainfrom
kpanuragh:test-authenticator
Open

kpanuragh wants to merge 1 commit into
linux-credentials:mainfrom
kpanuragh:test-authenticator

Conversation

@kpanuragh

Copy link
Copy Markdown
Contributor

Closes #107.

Adds an optional in-memory authenticator so credentialsd can be tested without a security key, following the plan in #107 (comment).

What it is

credentialsd/src/credential_service/test_authenticator.rs: a small CTAP2 authenticator (getInfo, makeCredential, getAssertion, getNextAssertion; ES256 only, "none" attestation, no PIN). It is plugged into the existing USB flow as a libwebauthn virtual HID device (virt feature: HidPipeBackend + virtual_device()), so device selection, credential selection and the UI work the same as with a real key. Keys only live in memory and are gone when credentialsd exits. Its Debug output is hand-written so key material never reaches the logs.

Guardrails

It is only offered when all of these hold:

  1. Built with the test-authenticator cargo feature. The meson option -Dtest_authenticator=true enables it and errors unless -Dprofile=development. Off by default.
  2. CREDSD_TEST_AUTHENTICATOR=1 is set when credentialsd starts handling the request.
  3. The request comes from https://webauthn.io or https://demo.yubico.com (exact origin match).

Without the feature, the USB device list is unchanged.

Questions still open from the issue

  • Build feature + env var, or would you prefer a setting in the config file?
  • Hard-coded origin allow-list (what this PR does), or configurable?

Happy to change either before merge.

Known limitations (documented in BUILDING.md / code comments)

  • On the allowed test sites, the test authenticator answers the device-selection probe instantly, so a real key plugged in at the same time can't be picked there.
  • libwebauthn's HidPipeBackend::recv() doesn't say which channel it is for, so replies assume one ceremony at a time, which is how credentialsd runs them.
  • This touches the USB device list (one extra_device parameter in process_idle_waiting), so it may need a small rebase around Make security key selection more flexible #256.

Testing

  • 14 new unit tests at the CTAPHID/CBOR level (signatures verified with ring, discoverable credentials and getNextAssertion, exclude list, empty-pinUvAuthParam touch probe, origin gating) plus one through libwebauthn's real channel (blink_and_wait_for_user_presence selects the virtual device).
  • cargo test --bins --features test-authenticator: 52 passed; without the feature: 38 passed (unchanged). cargo fmt --check and cargo clippy clean both ways.
  • Manually: registered and signed in on https://webauthn.io in Brave through the web extension and the patched xdg-desktop-portal, with CREDSD_TEST_AUTHENTICATOR=1.

Lets credentialsd be tested without a security key (linux-credentials#107). The
authenticator is a small CTAP2 implementation (getInfo, makeCredential,
getAssertion, getNextAssertion; ES256, "none" attestation) plugged into
the USB flow as a libwebauthn virtual HID device, so device selection
and the UI work as with a real key. Keys live in memory only.

It is offered only when all of these hold:
- built with the `test-authenticator` cargo feature (meson:
  -Dtest_authenticator=true, which requires -Dprofile=development);
- CREDSD_TEST_AUTHENTICATOR=1 is set;
- the request comes from https://webauthn.io or https://demo.yubico.com.

Without the feature the USB device list is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test authenticator to make testing easy without any specific hardware

1 participant