理解 WebAuthn 凭据保护策略
Understanding WebAuthn credential protection policy

原始链接: https://pilcrowonpaper.com/blog/16

为了防止未经授权的用户在安全密钥上发现凭据,开发人员可以使用 **CTAP 2.1 `credentialProtectionPolicy` 扩展**。 标准的 WebAuthn 凭据通常可以通过物理持有安全密钥来发现。此扩展允许依赖方(Relying Parties)在创建凭据时强制执行更高的安全要求: * **`userVerificationOptional`**:默认设置;允许在无需验证的情况下发现凭据。 * **`userVerificationOptionalWithCredentialIDList`**:除非提供特定的凭据 ID,否则在发现凭据时需要进行用户验证。 * **`userVerificationRequired`**:强制要求在发现和使用凭据时均进行用户验证。 `enforceCredentialProtectionPolicy` 标志可确保如果验证器不支持这些策略,操作将失败;不过,这通常应仅限于漫游验证器(roaming authenticators)。 各浏览器的支持情况有所不同;Chrome 和 Firefox 支持这些扩展,而 Safari 会忽略它们。值得注意的是,Chrome 可能会根据 `residentKey` 和 `userVerification` 设置静默应用默认策略。依赖方必须保持警惕,因为该扩展仅控制验证器端的发现功能,服务器仍需独立验证返回的断言是否确实包含了所需的用户验证。

```Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 理解 WebAuthn 凭据保护策略 (pilcrowonpaper.com) 4 点积分,由 mooreds 发布于 2 小时前 | 隐藏 | 过往 | 收藏 | 讨论 | 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:```
相关文章

原文

This post assumes you're already familiar with the basics of WebAuthn.

When creating a WebAuthn credential, you can specify whether it should be discoverable using the residentKey option.

const credential = await navigator.credentials.create({
	publicKey: {
		authenticatorSelection: {
			residentKey: "required",
			// ...
		},
		// ...
	},
});

However, the relying party cannot control when or how the credential can be discovered. You may want it to become discoverable only after user verification and hide the account’s existence from snooping users. This can be especially important for security keys, where unlike devices or password managers that usually require initial authentication, physical possession alone is often sufficient to reveal registered credentials. To address this, the CTAP 2.1 specification defines a new credential protection extension, available through the credentialProtectionPolicy extension input. CTAP is the specification that defines how platforms (devices/browsers) and roaming authenticators (security keys) interact.

const credential = await navigator.credentials.create({
	publicKey: {
		extensions: {
			credentialProtectionPolicy: "userVerificationRequired",
			enforceCredentialProtectionPolicy: true,
		},
		// ...
	},
});

If the default value userVerificationOptional is used, the credential can be discovered and used without user verification. If userVerificationOptionalWithCredentialIDList is used, the credential cannot be discovered without user verification, but it can still be discovered and used without user verification if the credential ID is provided by the relying party. This matches the security of non-discoverable credentials. Finally, userVerificationRequired indicates that the credential cannot be discovered or used without user verification.

It’s important to highlight that the extension controls credential discovery within the authenticator. It is still up to the relying party to verify whether the assertion was made with user verification if they require it.

The related enforceCredentialProtectionPolicy extension input configures what should happen if the authenticator does not support credential protection policy. If set to true, the operation will fail if it cannot create a credential at the specified security level. Note that if you use a non-roaming authenticator that does not support credentialProtectionPolicy but the browser does, the request will be rejected. As such, this should only be set to true if you want to allow roaming authenticators.

As for browser support for the extension inputs, Chrome and Firefox support them, while Safari does not and will simply ignore them.

Browsers can also silently apply a default value if the relying party does not specify one, which is specifically the case in Chrome.

If residentKey is preferred or required, Chrome uses userVerificationOptionalWithCredentialIDList. As noted, this helps prevent someone with physical access to the authenticator from seeing which accounts are registered on it.

If residentKey is required and userVerification is preferred, Chrome will use userVerificationRequired instead. The confusing part is that this is not related to credential discovery, but rather serves as a safety measure to enforce user verification. Chrome assumes the credential is likely to be used as a single authentication step, since preferred is commonly used even for passkey authentication. However, because user verification is still optional and it is up to the relying party to check for it, if the server does not properly enforce user verification during authentication, someone could sign in as the user with only physical access to the authenticator.

The specific behavior is documented in the Chromium documentation.

联系我们 contact @ memedata.com