Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
a84eeeb
Upgrade TFM to .NET 8, 9 and 10
vanbukin Nov 27, 2025
0262358
Migrate .sln to .slnx
vanbukin Nov 27, 2025
48111ab
Make project builable on .NET 8,9,10 tfm.
vanbukin Nov 27, 2025
b2da6f6
Apply formatting and refactor code for improved consistency and clarity.
vanbukin Nov 27, 2025
808cf28
Remove redundant Microsoft.Extensions.* package references across pro…
vanbukin Nov 27, 2025
9389038
Refactor `_credentials` field to use `ICollection` for improved flexi…
vanbukin Nov 27, 2025
23c4c0e
Refactor WebAuthn options initialization by introducing `FakeWebAuthn…
vanbukin Nov 27, 2025
cf787cb
Refactor Fido metadata background service and CborNegativeInteger cla…
vanbukin Nov 27, 2025
0bbbd61
Update README.md to replace dated WebAuthn Level 3 links with stable …
vanbukin Nov 27, 2025
5e3d298
Update README.md to replace WebAuthn specification links with stable …
vanbukin Nov 27, 2025
a619e8b
Remove unused attestation-related properties and update WebAuthn spec…
vanbukin Dec 1, 2025
9a6147a
Update WebAuthn specification links with stable references in `Authen…
vanbukin Dec 5, 2025
231802c
Update `AttestationConveyancePreference` documentation to use stable …
vanbukin Dec 5, 2025
f13809a
Update `AttestationStatementFormat` documentation to use stable WebAu…
vanbukin Dec 5, 2025
ce9c88a
Update `AuthenticatorAttachment` documentation to use stable WebAuthn…
vanbukin Dec 5, 2025
4ffccb5
Update `AuthenticatorTransport` documentation to use stable WebAuthn …
vanbukin Dec 5, 2025
3c4172b
Update `PublicKeyCredentialHints` documentation to use stable WebAuth…
vanbukin Dec 5, 2025
5f3dc80
Update `PublicKeyCredentialType` documentation to use stable WebAuthn…
vanbukin Dec 5, 2025
7b7efb0
Update `ResidentKeyRequirement` documentation to use stable WebAuthn …
vanbukin Dec 8, 2025
4cf9c53
Update `UserVerificationRequirement` documentation to use stable WebA…
vanbukin Dec 8, 2025
6ba071e
Remove attestation-related properties and unused references across au…
vanbukin Dec 8, 2025
ef543b5
Update `AuthenticationResponse` documentation to use stable WebAuthn …
vanbukin Dec 8, 2025
a071239
Update `AuthenticationResponse` documentation to use stable WebAuthn …
vanbukin Dec 8, 2025
63784d5
Update `RegistrationResponseJSON` documentation to use stable WebAuth…
vanbukin Dec 8, 2025
f52bbd3
Update `AuthenticatorAttestationResponseJSON` documentation to use st…
vanbukin Dec 9, 2025
a33c5b9
Update `AuthenticatorSelectionCriteriaJSON` documentation to use stab…
vanbukin Dec 9, 2025
4780b42
Bump .NET SDK to 10.0.101
vanbukin Dec 10, 2025
2539038
Update documentation to use stable WebAuthn specification links and i…
vanbukin Dec 10, 2025
18d7887
Update `PublicKeyCredentialDescriptorJSON` documentation to use stabl…
vanbukin Dec 17, 2025
96caddd
Refactor constructors in `PublicKeyCredentialDescriptorJSON` and enco…
vanbukin Dec 17, 2025
cde6609
Update `PublicKeyCredentialDescriptor` and `PublicKeyCredentialDescri…
vanbukin Dec 17, 2025
1968691
Update `PublicKeyCredentialDescriptor` documentation to use stable We…
vanbukin Dec 17, 2025
e90f82a
Update `AuthenticatorAttestationResponse` and `AuthenticatorAttestati…
vanbukin Dec 17, 2025
b3b071e
Update `RegistrationResponse` documentation to use stable WebAuthn sp…
vanbukin Dec 17, 2025
50dd0cb
Update `AuthenticatorSelectionCriteria` documentation to use stable W…
vanbukin Dec 17, 2025
8471371
Update `PublicKeyCredentialCreationOptions` and `PublicKeyCredentialC…
vanbukin Dec 17, 2025
36bebb9
Update `PublicKeyCredentialParameters` documentation to use stable We…
vanbukin Dec 17, 2025
bca6ee2
Update `PublicKeyCredentialRpEntity` documentation to use stable WebA…
vanbukin Dec 17, 2025
e504338
Update `PublicKeyCredentialUserEntity` documentation to use stable We…
vanbukin Dec 17, 2025
bd8fa4e
Update `X509ChainValidationOptions` to adjust chain validation polici…
vanbukin Dec 17, 2025
ba9f58d
Update package references and conditionally handle certificate loadin…
vanbukin Dec 17, 2025
ce04429
Update `AndroidKeyAttestationStatementOptions` documentation to use s…
vanbukin Dec 17, 2025
bda635d
Update `NoneAttestationOptions` documentation to use stable WebAuthn …
vanbukin Dec 17, 2025
8ced445
Update `SelfAttestationOptions` documentation to use stable WebAuthn …
vanbukin Dec 17, 2025
a91b5f1
Update `AttestationStatementOptions` documentation to use stable WebA…
vanbukin Dec 17, 2025
ec94193
Update `SelfAttestationOptions` and `AttestationTypeOptions` document…
vanbukin Dec 17, 2025
e186fd7
Update `WebAuthnOptions` documentation to use stable WebAuthn specifi…
vanbukin Dec 17, 2025
b2d457a
Update `CredentialPublicKeyRecord` documentation to use stable WebAut…
vanbukin Dec 17, 2025
e6453c0
Update `UserCredentialRecord` documentation to use stable WebAuthn sp…
vanbukin Dec 17, 2025
95fa49e
Update `CredentialRecord` documentation to use stable WebAuthn specif…
vanbukin Dec 17, 2025
ec65669
Update `CoseAlgorithm` documentation to use stable WebAuthn specifica…
vanbukin Dec 17, 2025
96d70b5
Update `DefaultCoseKeyDeserializer` to use stable WebAuthn specificat…
vanbukin Dec 17, 2025
d9e55a6
Update `IAttestationObjectDecoder` and `AttestationObject` documentat…
vanbukin Dec 17, 2025
5c6436b
Update `CredentialRecordUpdateResult` documentation to use stable Web…
vanbukin Dec 17, 2025
b9e2ba3
Update `CredentialBackupStateRecommendedAction` documentation to use …
vanbukin Dec 17, 2025
3d9bab6
Update `InMemoryUserCredentialRecord` documentation to use stable Web…
vanbukin Dec 18, 2025
46c8975
Update `MySqlPublicKeyCredentialDescriptor` and `MySqlUserCredentialR…
vanbukin Dec 18, 2025
677b343
Rename `CredentialId` to `Id` in `MySqlPublicKeyCredentialDescriptor`…
vanbukin Dec 18, 2025
c0935a8
Rename `Id` to `CredentialId` in `MySqlPublicKeyCredentialDescriptor`…
vanbukin Dec 18, 2025
ab38f83
Update `PostgreSqlPublicKeyCredentialDescriptor` documentation to use…
vanbukin Dec 18, 2025
304833d
Update `PostgreSqlUserCredentialRecord` documentation to use stable W…
vanbukin Dec 18, 2025
491363c
Update `SqlServerPublicKeyCredentialDescriptor` documentation to use …
vanbukin Dec 18, 2025
60e35f5
Update `SqlServerUserCredentialRecord` documentation to use stable We…
vanbukin Dec 18, 2025
f957a45
Remove unused attestation-related dependencies and replace WebAuthn s…
vanbukin Dec 22, 2025
9cc2516
Update `AuthenticationCeremonyIncludeCredentials` documentation to us…
vanbukin Dec 23, 2025
c874a4a
Update `AuthenticationCeremonyPublicKeyCredentialDescriptor` document…
vanbukin Dec 23, 2025
e296363
Update `BeginAuthenticationCeremonyRequest` documentation to use stab…
vanbukin Dec 23, 2025
80086b5
Update `CompleteAuthenticationCeremonyResult` documentation to use st…
vanbukin Dec 23, 2025
2962d40
Update `IAuthenticationCeremonyService` documentation to use stable W…
vanbukin Dec 23, 2025
fe8ab07
Update `IAndroidKeyAttestationStatementDecoder` documentation to use …
vanbukin Dec 23, 2025
90f61a7
Update `IAndroidSafetyNetAttestationStatementDecoder` documentation t…
vanbukin Dec 23, 2025
ee13585
Update `IAppleAnonymousAttestationStatementDecoder` documentation to …
vanbukin Dec 23, 2025
4436a76
Update `IFidoU2FAttestationStatementDecoder` documentation to use sta…
vanbukin Dec 23, 2025
1e4322f
Update `INoneAttestationStatementDecoder` documentation to use stable…
vanbukin Dec 23, 2025
3ebcb9a
Update `IPackedAttestationStatementDecoder` documentation to use stab…
vanbukin Dec 23, 2025
00ab9c9
Update `ITpmAttestationStatementDecoder` documentation to use stable …
vanbukin Dec 23, 2025
4579a66
Update `DefaultAttestationStatementDecoder` documentation to use stab…
vanbukin Dec 23, 2025
d2ef1e6
Update `AndroidKeyAttestationStatement` documentation to use stable W…
vanbukin Dec 23, 2025
0907965
Update `AndroidSafetyNetAttestationStatement` documentation to use st…
vanbukin Dec 23, 2025
50a16f2
Update `AppleAnonymousAttestationStatement` documentation to use stab…
vanbukin Dec 23, 2025
d80c548
Update `FidoU2FAttestationStatement` documentation to use stable WebA…
vanbukin Dec 23, 2025
d681161
Update `NoneAttestationStatement` documentation to use stable WebAuth…
vanbukin Dec 23, 2025
0ac81e6
Update `PackedAttestationStatement` documentation to use stable WebAu…
vanbukin Dec 23, 2025
c42ef7f
Update `TpmAttestationStatement` documentation to use stable WebAuthn…
vanbukin Dec 23, 2025
b77c97e
Update `IAndroidKeyAttestationStatementVerifier` documentation to use…
vanbukin Dec 23, 2025
b2b106c
Update `IAndroidKeyAttestationStatementVerifier` and `IAndroidSafetyN…
vanbukin Dec 23, 2025
f6a5d5a
Update `IAndroidSafetyNetAttestationStatementVerifier` documentation …
vanbukin Dec 23, 2025
d0698c6
Update `IAppleAnonymousAttestationStatementVerifier` documentation to…
vanbukin Dec 23, 2025
98e70dc
Update `IFidoU2FAttestationStatementVerifier` documentation to use st…
vanbukin Dec 23, 2025
60fe386
Update `INoneAttestationStatementVerifier` documentation to use stabl…
vanbukin Dec 23, 2025
11d66ee
Update `IPackedAttestationStatementVerifier` documentation to use sta…
vanbukin Dec 23, 2025
6d10db1
Update `ITpmAttestationStatementVerifier` documentation to use stable…
vanbukin Dec 23, 2025
24fc527
Update `AndroidKeyRoots` documentation to use stable WebAuthn specifi…
vanbukin Dec 23, 2025
ab8c122
Refactor `AndroidKey` root certificates: remove unused RSA key file, …
vanbukin Dec 23, 2025
83fcfce
Update `DefaultAndroidKeyAttestationStatementVerifier` documentation …
vanbukin Dec 23, 2025
853dbd9
Update `DefaultAndroidKeyAttestationStatementVerifier` to use stable …
vanbukin Dec 23, 2025
11d9e2f
Update `DefaultAndroidSafetyNetAttestationStatementVerifier` and `And…
vanbukin Dec 23, 2025
c29f33d
Update `AppleRoots` documentation to use stable WebAuthn specificatio…
vanbukin Dec 23, 2025
097ec50
Update `DefaultAppleAnonymousAttestationStatementVerifier` documentat…
vanbukin Dec 23, 2025
cfaf31c
Update `FidoU2FAttestationTypeResult` documentation to use stable Web…
vanbukin Dec 24, 2025
3ddd4c8
Update `AttestationType` documentation to use stable WebAuthn specifi…
vanbukin Dec 24, 2025
e1f0930
Update `DefaultFidoU2FAttestationStatementVerifier` documentation to …
vanbukin Dec 24, 2025
799e03c
Update `DefaultNoneAttestationStatementVerifier` documentation to use…
vanbukin Dec 24, 2025
ebccfd6
Update `FidoPackedAttestationTypeResult` documentation to use stable …
vanbukin Dec 24, 2025
1c232d2
Update `DefaultPackedAttestationStatementVerifier` documentation to u…
vanbukin Dec 24, 2025
5feeb30
Update `TpmRoots` documentation to use stable WebAuthn specification …
vanbukin Dec 24, 2025
00644d5
Update `DefaultTpmAttestationStatementVerifier` and `DefaultTpmCertIn…
vanbukin Dec 24, 2025
29271de
Update `DefaultAttestationStatementVerifier` documentation to use sta…
vanbukin Dec 24, 2025
87a194f
Update `DefaultAuthenticatorDataDecoder` and `DefaultAttestationTrust…
vanbukin Dec 24, 2025
0bee863
Update `AuthenticatorDataFlags` documentation to use stable WebAuthn …
vanbukin Dec 24, 2025
1a11aad
Update documentation to use stable WebAuthn specification links in `N…
vanbukin Dec 24, 2025
9aadcbd
Update `AttestedCredentialData` documentation to use stable WebAuthn …
vanbukin Dec 24, 2025
833b9f3
Remove `TokenBinding` model, related enums, and unused references whi…
vanbukin Dec 29, 2025
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: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ max_line_length = 999999999
# Xml project files
[*.csproj]
indent_size = 2
ij_formatter_enabled = false
ij_formatter_enabled = true
# Xml config files
[*.props]
indent_size = 2
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ jobs:
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup .NET SDK 6.0
uses: actions/checkout@v6
- name: Setup .NET SDK 8.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 6.0.425
dotnet-version: 8.0.402
source-url: ${{ secrets.NUGET_SOURCE }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
- name: Setup .NET SDK 8.0
- name: Setup .NET SDK 9.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.402
dotnet-version: 9.0.308
source-url: ${{ secrets.NUGET_SOURCE }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
- name: Setup .NET SDK 10.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.101
source-url: ${{ secrets.NUGET_SOURCE }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,29 @@ jobs:
environment: Production
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Setup .NET SDK 6.0
- name: Setup .NET SDK 8.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 6.0.425
dotnet-version: 8.0.402
source-url: ${{ secrets.NUGET_SOURCE }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
- name: Setup .NET SDK 8.0
- name: Setup .NET SDK 9.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.402
dotnet-version: 9.0.308
source-url: ${{ secrets.NUGET_SOURCE }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
- name: Setup .NET SDK 10.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.101
source-url: ${{ secrets.NUGET_SOURCE }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env

COPY . ./app

Expand All @@ -7,7 +7,7 @@ WORKDIR /app/demo/WebAuthn.Net.Demo.Mvc
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build-env /app/demo/WebAuthn.Net.Demo.Mvc/out .
ENTRYPOINT ["dotnet", "WebAuthn.Net.Demo.Mvc.dll"]
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WebAuthn.Net

A production-ready, easy-to-use, extensible implementation of the [WebAuthn Level 3 standard](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/), passing the [FIDO conformance test](https://fidoalliance.org/certification/functional-certification/conformance/), for the server side of web applications on .NET 6 and .NET 8.
A production-ready, easy-to-use, extensible implementation of the [WebAuthn Level 3 standard](https://www.w3.org/TR/webauthn-3), passing the [FIDO conformance test](https://fidoalliance.org/certification/functional-certification/conformance/), for the server side of web applications on .NET 8, .NET 9 and .NET 10.

<a href="https://webauthn.dodo.dev"><img src="https://img.shields.io/badge/Demo-blue"/></a>
<a href="https://www.nuget.org/packages/WebAuthn.Net/"><img src="https://img.shields.io/badge/NuGet-blue"/></a>
Expand All @@ -18,7 +18,7 @@ The documentation for each project is described in its README.md file.

## Supported features

- ✅ [Passkeys](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#passkey) are supported out of the box
- ✅ [Passkeys](https://www.w3.org/TR/webauthn-3/#passkey) are supported out of the box
- ✅ Attestation API & verification (Register and verify credentials/authenticators)
- ✅ Assertion API & verification (Authenticate users)
- ✅ 100% completion of the entire [FIDO Conformance Test](https://fidoalliance.org/certification/functional-certification/conformance/), including all optional features
Expand All @@ -27,13 +27,13 @@ The documentation for each project is described in its README.md file.
- ✅ Authenticators embedded in the device (FaceID, TouchID, Windows Hello)
- ✅ Roaming aka cross-platform authenticators (USB/NFC/BLE keys, for example Yubico)
- ✅ All current attestation statement formats
- [packed](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-packed-attestation)
- [tpm](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-tpm-attestation)
- [android-key](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-android-key-attestation)
- [android-safetynet](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-android-safetynet-attestation)
- [fido-u2f](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-fido-u2f-attestation)
- [none](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-none-attestation)
- [apple](https://www.w3.org/TR/2023/WD-webauthn-3-20230927/#sctn-apple-anonymous-attestation)
- [packed](https://www.w3.org/TR/webauthn-3/#sctn-packed-attestation)
- [tpm](https://www.w3.org/TR/webauthn-3/#sctn-tpm-attestation)
- [android-key](https://www.w3.org/TR/webauthn-3/#sctn-android-key-attestation)
- [android-safetynet](https://www.w3.org/TR/webauthn-3/#sctn-android-safetynet-attestation)
- [fido-u2f](https://www.w3.org/TR/webauthn-3/#sctn-fido-u2f-attestation)
- [none](https://www.w3.org/TR/webauthn-3/#sctn-none-attestation)
- [apple](https://www.w3.org/TR/webauthn-3/#sctn-apple-anonymous-attestation)
- ✅ All cryptographic algorithms required to pass the [FIDO Conformance Test](https://fidoalliance.org/certification/functional-certification/conformance/)
- [RS1](https://www.rfc-editor.org/rfc/rfc8812.html#section-2)
- [RS256](https://www.rfc-editor.org/rfc/rfc8812.html#section-2)
Expand Down Expand Up @@ -61,8 +61,9 @@ The documentation for each project is described in its README.md file.

### Required dependencies

- [.NET SDK 6.0.425+](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
- [.NET SDK 8.0.402+](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [.NET SDK 8.0.416+](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [.NET SDK 9.0.308+](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
- [.NET SDK 10.0.101+](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)

## Tips for Contribution

Expand Down
117 changes: 0 additions & 117 deletions WebAuthn.Net.sln

This file was deleted.

34 changes: 34 additions & 0 deletions WebAuthn.Net.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Solution>
<Folder Name="/root/">
<File Path=".editorconfig"/>
<File Path=".gitattributes"/>
<File Path=".gitignore"/>
<File Path="Directory.Build.props"/>
<File Path="global.json"/>
<File Path="NOTICE.md"/>
<File Path="README.md"/>
</Folder>
<Folder Name="/root/.config/">
<File Path=".config/dotnet-tools.json"/>
</Folder>
<Folder Name="/root/.github/"/>
<Folder Name="/root/.github/workflows/">
<File Path=".github/workflows/CI.yml"/>
<File Path=".github/workflows/Release.yml"/>
</Folder>
<Folder Name="/root/demo/">
<Project Path="demo/WebAuthn.Net.Demo.FidoConformance/WebAuthn.Net.Demo.FidoConformance.csproj"/>
<Project Path="demo/WebAuthn.Net.Demo.Mvc/WebAuthn.Net.Demo.Mvc.csproj"/>
</Folder>
<Folder Name="/root/src/">
<Project Path="src/WebAuthn.Net.OpenTelemetry/WebAuthn.Net.OpenTelemetry.csproj"/>
<Project Path="src/WebAuthn.Net.Storage.InMemory/WebAuthn.Net.Storage.InMemory.csproj"/>
<Project Path="src/WebAuthn.Net.Storage.MySql/WebAuthn.Net.Storage.MySql.csproj"/>
<Project Path="src/WebAuthn.Net.Storage.PostgreSql/WebAuthn.Net.Storage.PostgreSql.csproj"/>
<Project Path="src/WebAuthn.Net.Storage.SqlServer/WebAuthn.Net.Storage.SqlServer.csproj"/>
<Project Path="src/WebAuthn.Net/WebAuthn.Net.csproj"/>
</Folder>
<Folder Name="/root/tests/">
<Project Path="tests/WebAuthn.Net.Tests.Unit/WebAuthn.Net.Tests.Unit.csproj"/>
</Folder>
</Solution>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,19 @@
var json = Encoding.UTF8.GetString(ms.ToArray());
var element = JsonSerializer.Deserialize<JsonElement>(json);
var intendedJson = JsonSerializer.Serialize(element, _jsonSerializerOptions);
_logger.LogInformation($"Request {context.Request.Method} {context.Request.GetEncodedPathAndQuery()}{Environment.NewLine}Body:{Environment.NewLine}{intendedJson}");
_logger.LogRequestInformation(context.Request.Method, context.Request.GetEncodedPathAndQuery(), intendedJson);

Check failure

Code scanning / CodeQL

Log entries created from user input High

This log entry depends on a
user-provided value
.

Copilot Autofix

AI about 1 month ago

The best way to fix this issue is to sanitize any user-controlled values before logging them. Specifically, the HTTP method (context.Request.Method), path and query (context.Request.GetEncodedPathAndQuery()), and body (intendedJson) should be stripped of any new line or carriage return characters that could lead to log spoofing. For plain text logs, using string.Replace("\r", "") and string.Replace("\n", "") will remove line breaks. The changes should be made in the middleware, prior to logging (i.e., in InvokeAsync). Only these arguments need to be sanitized before being passed to the logger.

Thus, update the arguments on line 41 as follows:

  • Sanitize context.Request.Method
  • Sanitize context.Request.GetEncodedPathAndQuery()
  • Sanitize intendedJson

No new imports are needed; use string.Replace methods.


Suggested changeset 1
demo/WebAuthn.Net.Demo.FidoConformance/Middleware/RequestLoggingMiddleware.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/demo/WebAuthn.Net.Demo.FidoConformance/Middleware/RequestLoggingMiddleware.cs b/demo/WebAuthn.Net.Demo.FidoConformance/Middleware/RequestLoggingMiddleware.cs
--- a/demo/WebAuthn.Net.Demo.FidoConformance/Middleware/RequestLoggingMiddleware.cs
+++ b/demo/WebAuthn.Net.Demo.FidoConformance/Middleware/RequestLoggingMiddleware.cs
@@ -38,7 +38,11 @@
         var json = Encoding.UTF8.GetString(ms.ToArray());
         var element = JsonSerializer.Deserialize<JsonElement>(json);
         var intendedJson = JsonSerializer.Serialize(element, _jsonSerializerOptions);
-        _logger.LogRequestInformation(context.Request.Method, context.Request.GetEncodedPathAndQuery(), intendedJson);
+        // Sanitize user-controlled values to prevent log forging
+        string sanitizedMethod = context.Request.Method.Replace("\r", "").Replace("\n", "");
+        string sanitizedPathAndQuery = context.Request.GetEncodedPathAndQuery().Replace("\r", "").Replace("\n", "");
+        string sanitizedIntendedJson = intendedJson.Replace("\r", "").Replace("\n", "");
+        _logger.LogRequestInformation(sanitizedMethod, sanitizedPathAndQuery, sanitizedIntendedJson);
         await next(context);
     }
 }
EOF
@@ -38,7 +38,11 @@
var json = Encoding.UTF8.GetString(ms.ToArray());
var element = JsonSerializer.Deserialize<JsonElement>(json);
var intendedJson = JsonSerializer.Serialize(element, _jsonSerializerOptions);
_logger.LogRequestInformation(context.Request.Method, context.Request.GetEncodedPathAndQuery(), intendedJson);
// Sanitize user-controlled values to prevent log forging
string sanitizedMethod = context.Request.Method.Replace("\r", "").Replace("\n", "");
string sanitizedPathAndQuery = context.Request.GetEncodedPathAndQuery().Replace("\r", "").Replace("\n", "");
string sanitizedIntendedJson = intendedJson.Replace("\r", "").Replace("\n", "");
_logger.LogRequestInformation(sanitizedMethod, sanitizedPathAndQuery, sanitizedIntendedJson);
await next(context);
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
await next(context);
}
}

internal static partial class RequestLoggingMiddlewareLoggingExtensions
{
[LoggerMessage(
Level = LogLevel.Information,
Message = "Request {Method} {PathAndQuery}\nBody:\n{Body}")]
public static partial void LogRequestInformation(
this ILogger logger,
string method,
string pathAndQuery,
string body);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ public ServerAuthenticatorAssertionResponse(
string clientDataJson,
string authenticatorData,
string signature,
string userHandle,
string? attestationObject)
string userHandle)
{
ClientDataJson = clientDataJson;
AuthenticatorData = authenticatorData;
Signature = signature;
UserHandle = userHandle;
AttestationObject = attestationObject;
}

[JsonPropertyName("clientDataJSON")]
Expand All @@ -38,8 +36,4 @@ public ServerAuthenticatorAssertionResponse(
[JsonPropertyName("userHandle")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string UserHandle { get; }

[JsonPropertyName("attestationObject")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? AttestationObject { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ private static AuthenticatorAssertionResponseJSON ParseResponse(ServerAuthentica
input.ClientDataJson,
input.AuthenticatorData,
input.Signature,
input.UserHandle,
input.AttestationObject);
input.UserHandle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public bool TryToBeginCeremonyRequest([NotNullWhen(true)] out BeginAuthenticatio
AuthenticationCeremonyIncludeCredentials.AllExisting(),
userVerification,
null,
null,
null,
Extensions);
return true;
}
Expand Down
Loading
Loading