The Simplest Way to Make Lambda and Webauthn Work Like They Should
Teams pair lambda and webauthn to run serverless passkey checks without dedicated login servers. This setup lets users log in with hardware keys while functions check cryptographic proofs on demand. Serverless functions handle short tasks very well. Passkey logins need quick checks that run only when a user signs in. Putting these two tools together saves money and shrinks your attack surface. You do not need idle machines waiting for login requests. How lambda and webauthn handle keys and da
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 lambda and webauthn to run serverless passkey checks without dedicated login servers. This setup lets users log in with hardware keys while functions check cryptographic proofs on demand.
Serverless functions handle short tasks very well. Passkey logins need quick checks that run only when a user signs in. Putting these two tools together saves money and shrinks your attack surface. You do not need idle machines waiting for login requests.
How lambda and webauthn handle keys and data flow
The login flow starts in the user browser. The browser asks your serverless backend for a fresh login challenge. A function runs, makes a random string, and stores it for a short time. The function sends this challenge back to the browser.
Next, the browser talks to the user passkey or security key. The hardware key signs the challenge with its private key. The browser sends this signed proof back to a second function. That function reads the user public key from a data store. It checks the signature against the stored challenge and origin name.
If the check passes, the function issues a session token for the app. Each step needs clear role limits. The first function only needs permission to write temporary challenge data. The second function needs permission to read public keys and update key counters. Neither function needs broad rights across your whole cloud account.
Common failure modes and how to scope roles
Many teams make mistakes with state and permissions in this setup. Functions do not keep data in memory between runs. If a team stores the random challenge in local memory, the next run will fail. You must store challenges in an external store with a short timer.
Shared service roles are another big risk. Teams often give all login functions one wide role with full database rights. If an attacker finds a bug in one function, they can read all user data. Give each function its own tiny role instead. Separate the registration role from the daily login role.
FIDO2 / WebAuthn + Lambda Execution Roles: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged database queries also create blind spots during an audit. When a function reads public keys or writes new passkeys, you need clear logs. Tie each function run to the specific user request ID. Also check that your data store masks sensitive fields like emails or phone numbers in query results. Masking rewrites matched fields in results so debug logs stay safe.
Network paths and origin checks in serverless logins
Passkey security relies on strict domain name checks. The browser binds every key to a specific web origin. Your serverless functions must check this origin string on every single request. Never pull the expected origin name from an untrusted request header. Set the allowed origin in a locked config variable that code cannot change.
Network paths between your functions and your key store also need tight rules. Place your data store in a private network zone. Allow traffic only from the specific security group attached to your login functions. Block all public internet routes from the check function. It only needs to talk to your internal key table and logging service.
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
Where should serverless functions store passkey challenges?
Store challenges in a fast key-value store that supports automatic expiration timers. Set each challenge to delete itself after sixty seconds so attackers cannot reuse old login attempts.
Why do passkey sign-in counters fail in serverless apps?
Sign-in counters fail when two login requests run at the exact same time. Use atomic write operations in your database so the counter updates in strict order.
How should teams handle lost hardware keys in this workflow?
Let users register more than one passkey on their account from the start. Keep a separate recovery function with strict rate limits and full audit logs for account resets.
Related guides
In this post