Skip to content

feat(coderd): add FIDO2/WebAuthn hardware key authentication for workspace connections#22077

Draft
illera88 wants to merge 2 commits intocoder:mainfrom
illera88:feat/webauthn-connect
Draft

feat(coderd): add FIDO2/WebAuthn hardware key authentication for workspace connections#22077
illera88 wants to merge 2 commits intocoder:mainfrom
illera88:feat/webauthn-connect

Conversation

@illera88
Copy link

@illera88 illera88 commented Feb 12, 2026

Summary

Add FIDO2/WebAuthn hardware security key authentication for sensitive workspace operations (SSH, port forwarding). When enabled via --require-fido2-connect, users must physically touch their security key before connecting to workspaces.

Architecture

Why a separate coder-fido2 helper binary?

FIDO2 authentication requires communicating with USB HID devices (YubiKeys, etc.) via the operating system's USB stack. This requires libfido2, a C library, which means CGo. The main coder binary is pure Go and must stay that way for cross-compilation and distribution. To solve this:

  • cmd/coder-fido2/ is a separate Go module with its own go.mod. It uses CGo + libfido2 for USB HID communication. It's a small standalone binary (~300 lines) that handles register and assert CTAP2 operations.
  • cli/fido2/ in the main module contains pure Go shell-out wrappers (RunRegister, RunAssert) that execute the helper binary, passing JSON on stdin and reading JSON on stdout. Exit codes signal touch timeout (2) or PIN required (3).
  • The main coder CLI stays pure Go. It calls the helper only when a FIDO2 security key is needed.

There are emerging pure-Go FIDO2 libraries (e.g., mohammadv184/go-fido2 using purego for CGo-free USB HID) that could eliminate the helper binary in the future. This is tracked as a follow-up.

Server-side

  • WebAuthn registration/assertion endpoints under /api/v2/users/{user}/webauthn/
  • Short-lived connection JWTs issued after successful key verification
  • JTI replay cache prevents token reuse in single-use mode (--fido2-token-duration=0)
  • Enforcement at the coordination endpoint (SSH, port-forward, VS Code Remote)
  • Database migration for webauthn_credentials table

Client-side

  • coder webauthn register/list/delete CLI commands
  • ConnectionAuthProvider interface for extensibility (future: biometrics, OS keychain)
  • Transparent FIDO2 flow in coder ssh and coder port-forward

Server flags

Flag Default Description
--require-fido2-connect false Require FIDO2 for all workspace connections
--fido2-token-duration 5m JWT validity window (0s = single-use)
--require-fido2-user-verification false Require PIN/biometric in addition to touch

Security properties

  • Physical presence guarantee via FIDO2 hardware key touch
  • Replay protection via JTI cache (single-use mode) or time-based expiry
  • Session TTL on ceremony data (5min), body size limits (64KB), credential name validation
  • Workspace proxy auth bypasses FIDO2 (infrastructure, not end users)
  • Non-connection operations (list workspaces, create templates) are unaffected

Known limitations

  • Web terminal and workspace apps are not behind FIDO2 enforcement
  • Single-use JTI cache is per-process (not shared across HA replicas)
  • The coder-fido2 helper must be built and installed separately

…rkspace connections

Add server-side WebAuthn credential management and JWT-based connection
authentication using FIDO2 hardware security keys (YubiKey, etc.).

Server:
- WebAuthn registration/assertion endpoints under /api/v2/users/{user}/webauthn/
- Short-lived connection JWTs issued after successful key verification
- JTI replay cache prevents token reuse (single-use with --fido2-token-duration=0)
- Enforcement at coordination endpoint (SSH, port-forward, VS Code Remote)
- Three server flags: --require-fido2-connect, --fido2-token-duration,
  --require-fido2-user-verification
- Database migration for webauthn_credentials table + webauthn_connect crypto key

Client:
- coder webauthn register/list/delete CLI commands
- coder-fido2 helper binary (separate Go module, CGo + libfido2)
- ConnectionAuthProvider interface for extensibility (future: biometrics, keychain)
- Transparent FIDO2 flow in coder ssh and coder port-forward

Security:
- Session TTL (5min) prevents ceremony session exhaustion
- Body size limits (64KB) on finish/verify endpoints
- Credential name length validation (128 chars)
- Origin canonicalization (scheme://host[:port] only)
- Proxy auth bypass (workspace proxies skip FIDO2 enforcement)
- RBAC enforcement on all credential operations
@illera88 illera88 requested a review from Emyrk as a code owner February 12, 2026 21:48
@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Feb 12, 2026
@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@illera88 illera88 marked this pull request as draft February 12, 2026 21:48
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7195cfa2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@illera88 illera88 changed the title feat(security): add FIDO2/WebAuthn hardware key authentication for workspace connections feat(coderd): add FIDO2/WebAuthn hardware key authentication for workspace connections Feb 12, 2026
…s in list, clean up

- Only enforce JTI replay cache when --fido2-token-duration=0 (single-use).
  Tokens with positive duration are reusable within their validity window.
- Return 403 instead of 500 for authorization errors in list credentials.
- Remove verbose comments from deployment struct fields.
- Remove PRD from docs.
- Document HA limitation for single-use JTI replay cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant