Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Demo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public void ConfigureServices(IServiceCollection services)
options.Origins = Configuration.GetSection("fido2:origins").Get<HashSet<string>>();
options.TimestampDriftTolerance = Configuration.GetValue<int>("fido2:timestampDriftTolerance");
options.MDSCacheDirPath = Configuration["fido2:MDSCacheDirPath"];
options.AllowBackupEligibleCredential = Configuration.GetValue<bool>("fido2:allowBackupEligibleCredential");

@rudiv rudiv Feb 19, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would argue that these be allowed by default to support a happier upgrade path. Some RPs may not care about these statuses at all, and so their existing configuration would break?

I know this comment is against the Demo project, but the Configuration default would also be false if this wasn't decided / set at startup.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I would argue that these be allowed by default to support a happier upgrade path. Some RPs may not care about these statuses at all, and so their existing configuration would break?

I know this comment is against the Demo project, but the Configuration default would also be false if this wasn't decided / set at startup.

I hear ya. This is a enterprise vs consumer setting in my eyes, and I personally am enterprise focused. When this PR is in a release it will be part of a major update, and we are expecting that will contain some breaking changes. Regardless of which way it goes by default, there will be notes to help guide implementers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree, I think my main concern is that this may block typical use cases.

For an example (even thinking enterprise), you may wish for your users to have a passkey that's backed up and set this setting. However, they would then be unable to add a physical key (Yubikey et al). I know this is the whole point of "Passkeys" to not need it, but I feel that it's more of a per-key decision than one that should be set globally for the RP?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@aseigler I agree that we should default to true. Given that the average developer might not know what this option do (and should be True for them), while I think we can expect enterprise developers have more knowledge and know to turn it off because of their own research/policy for deploying fido2.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They would actually be able to register a typical security key with this setting true or false, as those do not set BE flag. Currently only certain platform authenticators do. It's undefined how the platform is protecting those BE keys and where they are going to be restored to. That's why in a situation where the RP cares (enterprise), they might wish to restrict BE keys from being registered at all on the platform, or maybe allow some blessed authenticators but not others (would require additional work to support this). I guess there might be a reason an RP would only want to allow BE keys? That's not the result or intent of this implementation, at least currently.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understand the Enterprise point of view.

From a more consumer-focused point of view (ie. specifically the well marketed "Passkeys" aspect) we may want to accept only Passkeys at first, to ensure that users are not able to lose access very easily. Whilst it's not perfect and most authenticators don't give on where the keys are from / stored, knowing that they're backed up allows it to be reasonably assumed that the key is durable and isn't going to disappear like in the case of a physical key loss. For example, we explicitly advise the user to register with a backed up authenticator (specifically iCloud backed Passkeys or their Android phone).

I might be wrong in assuming that this is where this library is going to see most of its use in the short-mid term, but that's my 2c on why this default would be the wrong one.

@aseigler aseigler Mar 6, 2023 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

From a more consumer-focused point of view (ie. specifically the well marketed "Passkeys" aspect) we may want to accept only Passkeys at first

First thing: https://shouldicapitalizepasskey.com

Sounds crazy to me, but if that's what people want to do with this it's easy enough to switch the logic for BE and BS so instead of true/false the policy can be allow/disallow/require for both registration and authentication flows with the defaults being the most "normal" allow but giving the RP admin the ability to ability for more strict control.

options.AllowBackedUpCredential = Configuration.GetValue<bool>("fido2:allowBackedUpCredential");
})
.AddCachedMetadataService(config =>
{
Expand Down
4 changes: 3 additions & 1 deletion Demo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"fido2": {
"serverDomain": "localhost",
"origins": [ "https://localhost:44329" ],
"timestampDriftTolerance": 300000
"timestampDriftTolerance": 300000,
"allowBackupEligibleCredential": true,
"allowBackedUpCredential": true
},
"Logging": {
"IncludeScopes": false,
Expand Down
10 changes: 10 additions & 0 deletions Src/Fido2.Models/Fido2Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,14 @@ public ISet<string> FullyQualifiedOrigins
AuthenticatorStatus.USER_KEY_PHYSICAL_COMPROMISE,
AuthenticatorStatus.REVOKED
};

/// <summary>
/// Whether or not to accept a backup eligible credential
/// </summary>
public bool AllowBackupEligibleCredential { get; set; }

/// <summary>
/// Whether or not to accept a backed up credential
/// </summary>
public bool AllowBackedUpCredential { get; set; }
}
9 changes: 7 additions & 2 deletions Src/Fido2/AuthenticatorAssertionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public static AuthenticatorAssertionResponse Parse(AuthenticatorAssertionRawResp
/// <param name="cancellationToken"></param>
public async Task<AssertionVerificationResult> VerifyAsync(
AssertionOptions options,
ISet<string> fullyQualifiedExpectedOrigins,
Fido2Configuration config,
byte[] storedPublicKey,
List<byte[]> storedDevicePublicKeys,
uint storedSignatureCounter,
IsUserHandleOwnerOfCredentialIdAsync isUserHandleOwnerOfCredId,
byte[] requestTokenBindingId,
CancellationToken cancellationToken = default)
{
BaseVerify(fullyQualifiedExpectedOrigins, options.Challenge, requestTokenBindingId);
BaseVerify(config.FullyQualifiedOrigins, options.Challenge, requestTokenBindingId);

if (Raw.Type != PublicKeyCredentialType.PublicKey)
throw new Fido2VerificationException(Fido2ErrorCode.InvalidAssertionResponse, "AssertionResponse type must be public-key");
Expand Down Expand Up @@ -159,6 +159,11 @@ public async Task<AssertionVerificationResult> VerifyAsync(

// 16. If the credential backup state is used as part of Relying Party business logic or policy, let currentBe and currentBs be the values of the BE and BS bits, respectively, of the flags in authData.
// Compare currentBe and currentBs with credentialRecord.BE and credentialRecord.BS and apply Relying Party policy, if any.
if (authData.IsBackupEligible && !config.AllowBackupEligibleCredential)
throw new Fido2VerificationException(Fido2ErrorCode.BackupEligibilityRequirementNotMet, Fido2ErrorMessages.BackupEligibilityRequirementNotMet);

if (authData.BackupState && !config.AllowBackedUpCredential)
throw new Fido2VerificationException(Fido2ErrorCode.BackupStateRequirementNotMet, Fido2ErrorMessages.BackupStateRequirementNotMet);

// 14. Verify that the values of the client extension outputs in clientExtensionResults and the authenticator extension outputs in the extensions in authData are as expected, considering the client extension input values that were given as the extensions option in the get() call.In particular, any extension identifier values in the clientExtensionResults and the extensions in authData MUST be also be present as extension identifier values in the extensions member of options, i.e., no extensions are present that were not requested. In the general case, the meaning of "are as expected" is specific to the Relying Party and which extensions are in use.
// todo: Verify this (and implement extensions on options)
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2/AuthenticatorAttestationResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public async Task<AttestationVerificationSuccess> VerifyAsync(
throw new Fido2VerificationException(Fido2ErrorCode.UserVerificationRequirementNotMet, Fido2ErrorMessages.UserVerificationRequirementNotMet);

// 15. If the Relying Party uses the credential's backup eligibility to inform its user experience flows and/or policies, evaluate the BE bit of the flags in authData.
if (authData.IsBackupEligible)
if (authData.IsBackupEligible && !config.AllowBackupEligibleCredential)
throw new Fido2VerificationException(Fido2ErrorCode.BackupEligibilityRequirementNotMet, Fido2ErrorMessages.BackupEligibilityRequirementNotMet);

if (!authData.HasAttestedCredentialData)
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2/Fido2NetLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public async Task<AssertionVerificationResult> MakeAssertionAsync(
var parsedResponse = AuthenticatorAssertionResponse.Parse(assertionResponse);

var result = await parsedResponse.VerifyAsync(originalOptions,
_config.FullyQualifiedOrigins,
_config,
storedPublicKey,
storedDevicePublicKeys,
storedSignatureCounter,
Expand Down