The Simplest Way to Make Fido2 and Mercurial Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair fido2 and mercurial in production to tie every code push to a hardware key. This setup stops stolen passwords from giving attackers write permissions on source control servers. Source code holds great value for any software team. Still, old password setups leave repos open to phishing attacks. Linking hardware keys with version control fixes this gap. Developers touch a physical token to prove who they are before pushing changes. This workflow keeps work fast while blocking bad actor

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair fido2 and mercurial in production to tie every code push to a hardware key. This setup stops stolen passwords from giving attackers write permissions on source control servers.

Source code holds great value for any software team. Still, old password setups leave repos open to phishing attacks. Linking hardware keys with version control fixes this gap. Developers touch a physical token to prove who they are before pushing changes. This workflow keeps work fast while blocking bad actors.

How fido2 and mercurial handle keys and permissions

First, understand how the two systems talk to each other. The version control tool does not read hardware keys on its own. Instead, it relies on the transport layer to check user identity. Teams use SSH or HTTPS to move data between local machines and remote servers. Both transport paths support modern hardware security keys.

In an SSH setup, the developer generates a key pair backed by the hardware token. The private part stays locked inside the physical device. The public part goes to the central code server or identity provider. When the developer runs a push or pull command, the transport layer asks for proof. The user touches the flashing key, and the server checks the signature.

In an HTTPS setup, the flow goes through a web login page or token helper. The developer logs in through an identity provider using the hardware token. Once checked, the identity provider issues a temporary session token for the local client. The version control client then sends this token with each read or write request. Server rules match the verified user identity to specific repo permissions.

Fixing common failure modes and scoping roles

Many teams make mistakes when they first set up hardware keys for version control. The biggest risk comes from shared service accounts. Teams often create one bot account with broad permissions for build jobs and developers. If someone steals that shared token, the attacker gets full control over every repo. Also, shared accounts ruin audit logs because you cannot tell who pushed a change.

Broad personal tokens cause similar headaches. Developers hate logging in many times a day. So, they create long-lived tokens that bypass the hardware key check after day one. If malware hits a laptop, the attacker steals the long-lived token and skips the key check.

FIDO2 / WebAuthn + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, give every human and build job a separate identity. Scope each role to the exact repos needed for daily work. Set short lifetimes on all session tokens so users touch their hardware keys once per shift. Limit network paths so only trusted corporate networks or verified endpoints reach the code server. Finally, log every read and write action with the verified user email attached.

Managing lost keys and build pipelines

Hardware keys can break or get lost during travel. If a developer only has one key registered, a lost device halts their work. Have every engineer register a backup hardware key and store it in a safe place. Identity admins should check a user on a video call before issuing a temporary recovery pass.

Automated build servers also need a clear way to pull code. Since a server cannot touch a physical button, do not force hardware keys on build bots. Instead, bind build jobs to workload identities with read-only permissions on specific branches. Keep human accounts and machine accounts in separate permission groups at all times.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can developers use one hardware key across multiple repositories?

Yes, a single hardware key works across all repos on your server. You map the public key to the user profile, and server roles control repo permissions.

How do automated build pipelines pull code without a physical touch?

Build pipelines use machine identities with scoped, short-lived tokens instead of hardware keys. Give these bot accounts read-only permissions so they cannot push unauthorized code changes.

What happens when a developer loses their registered security key?

The admin revokes the lost public key from the central identity system right away. The developer then switches to a pre-registered backup key to resume pushing code.

The query runs. The emails stay hidden.