Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADMNAPI-989] Add read me file and fix docker file warnings #96

Merged
merged 6 commits into from
Apr 1, 2024

Conversation

CSR2017
Copy link

@CSR2017 CSR2017 commented Mar 27, 2024

No description provided.

Copy link

github-actions bot commented Mar 27, 2024

🔍 Vulnerabilities of development:latest

📦 Image Reference development:latest
digestsha256:fd28f8fa4a489326d488d9d82d1672268a6f5ea3afce90b6d4861de09ba4a364
vulnerabilitiescritical: 0 high: 1 medium: 12 low: 0 unspecified: 1
platformlinux/amd64
size85 MB
packages447
📦 Base Image alpine:3
also known as
  • 3.17
  • 3.17.3
  • latest
digestsha256:b6ca290b6b4cdcca5b3db3ffa338ee0285c11744b4a6abaa9627746ee3291d8d
vulnerabilitiescritical: 0 high: 1 medium: 8 low: 0 unspecified: 1
critical: 0 high: 1 medium: 8 low: 0 unspecified: 1openssl 3.0.8-r3 (apk)

pkg:apk/alpine/[email protected]?os_name=alpine&os_version=3.17

high : CVE--2023--5363

Affected range<3.0.12-r0
Fixed version3.0.12-r0
Description

medium : CVE--2023--6129

Affected range<3.0.12-r2
Fixed version3.0.12-r2
Description

medium : CVE--2023--2650

Affected range<3.0.9-r0
Fixed version3.0.9-r0
Description

medium : CVE--2023--1255

Affected range<3.0.8-r4
Fixed version3.0.8-r4
Description

medium : CVE--2024--0727

Affected range<3.0.12-r4
Fixed version3.0.12-r4
Description

medium : CVE--2023--5678

Affected range<3.0.12-r1
Fixed version3.0.12-r1
Description

medium : CVE--2023--3817

Affected range<3.0.10-r0
Fixed version3.0.10-r0
Description

medium : CVE--2023--3446

Affected range<3.0.9-r3
Fixed version3.0.9-r3
Description

medium : CVE--2023--2975

Affected range<3.0.9-r2
Fixed version3.0.9-r2
Description

unspecified : CVE--2023--6237

Affected range<3.0.12-r3
Fixed version3.0.12-r3
Description
critical: 0 high: 0 medium: 2 low: 0 Microsoft.IdentityModel.JsonWebTokens 6.25.1.31130 (nuget)

pkg:nuget/[email protected]

medium 6.8: GHSA--59j7--ghrg--fj52

Affected range>=6.5.0
<6.34.0
Fixed version6.34.0
CVSS Score6.8
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:N/A:H
Description

Microsoft Security Advisory CVE-2024-21319: .NET Denial of Service Vulnerability

Executive summary

Microsoft is releasing this security advisory to provide information about a vulnerability in the ASP.NET Core project templates. This advisory also provides guidance on what developers can do to update their applications to address this vulnerability.

A Denial of Service vulnerability exists in ASP.NET Core project templates which utilize JWT-based authentication tokens. This vulnerability allows an unauthenticated client to consume arbitrarily large amounts of server memory, potentially triggering an out-of-memory condition on the server and making the server no longer able to respond to legitimate requests.

Announcement

Announcement for this issue can be found at dotnet/announcements#290

Mitigation factors

This impacts only .NET Core-based projects that were created using any version of project templates listed in affected software.
Other project templates e.g., console applications, MAUI applications, Windows Forms or WPF applications, are not affected.

Affected software

This impacts only .NET Core-based projects that were created using any version of the below project templates.

  • ASP.NET Core Web App (Model-View-Controller)
  • ASP.NET Core Web API
  • ASP.NET Core Web App (Razor Pages)
  • Blazor Server App
  • Blazor WebAssembly App

Advisory FAQ

How do I know if I am affected?

If you are you using project templates listed in affected software, you may be exposed to the vulnerability.

How do I fix the issue?

For existing projects:

If you ever created any of these projects via the dotnet new command or via Visual Studio's File -> New Project gesture, and if you enabled federated authentication at project creation time, your project may be vulnerable. To remediate the vulnerability, use your package manager to update any references you may have to the Microsoft.AspNetCore.Authentication.JwtBearer, Microsoft.AspNetCore.Authentication.OpenIdConnect, and Microsoft.IdentityModel.JsonWebTokens packages to their respective latest versions.

If your project does not reference any of those three packages, you are not exposed to this vulnerability.

For new projects:

To remediate this issue please update to the latest SDK listed below. Simply installing the SDK update is not sufficient to remediate projects already-created / already-deployed projects which existed prior to this update being released.

  • To fix the issue please install the latest version of .NET 6.0 or .NET 7.0. If you have installed one or more .NET SDKs through Visual Studio, Visual Studio will prompt you to update Visual Studio, which will also update your .NET SDKs.
  • If you are using one of the affected packages, please update to the patched version listed above.
  • If you have .NET 6.0 or greater installed, you can list the versions you have installed by running the dotnet --info command. You will see output like the following;
.NET Core SDK (reflecting any global.json):

 Version:   7.0.200
 Commit:    8473146e7d

Runtime Environment:

 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.300\

Host (useful for support):

  Version: 76.0.5
  Commit:  8473146e7d

.NET Core SDKs installed:

  7.0.200 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:

  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

.NET 6.0, .NET 7.0, .NET 8.0 updates are also available from Microsoft Update. To access this either type "Check for updates" in your Windows search, or open Settings, choose Update & Security and then click Check for Updates.

Once you have installed the updated runtime or SDK, restart your apps for the update to take effect.

Additionally, if you've deployed self-contained applications targeting any of the impacted versions, these applications are also vulnerable and must be recompiled and redeployed.

Other Information

Reporting Security Issues

If you have found a potential security issue in .NET 8.0 or .NET 7.0 or .NET 6.0, please email details to [email protected]. Reports may qualify for the Microsoft .NET Core & .NET 5 Bounty. Details of the Microsoft .NET Bounty Program including terms and conditions are at https://aka.ms/corebounty.

Support

You can ask questions about this issue on GitHub in the .NET GitHub organization. The main repos are located at https://github.com/dotnet/runtime and https://github.com/dotnet/aspnet/. The Announcements repo (https://github.com/dotnet/Announcements) will contain this bulletin as an issue and will include a link to a discussion issue. You can ask questions in the linked discussion issue.

Disclaimer

The information provided in this advisory is provided "as is" without warranty of any kind. Microsoft disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Microsoft Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Microsoft Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.

Acknowledgement

Morgan Brown, Microsoft Corp.

External Links

CVE-2024-21319

Revisions

V1.0 (January 09, 2024): Advisory published.

Version 1.0

Last Updated 2024-01-09

medium 6.8: CVE--2024--21319

Affected range>=6.5.0
<6.34.0
Fixed version6.34.0
CVSS Score6.8
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:N/A:H
Description

Impact

What kind of vulnerability is it? Who is impacted?
An attacker could exploit this vulnerability by crafting a malicious JSON Web Encryption (JWE) token with a high compression ratio. This token, when processed by a server, leads to excessive memory allocation and processing time during decompression, causing a denial-of-service (DoS) condition.

It's important to note that the attacker must have access to the public encrypt key registered with the IDP(Entra ID) for successful exploitation.

According to the CVSS metric, a successful exploitation could lead to a scope change (S:C). What does this mean for this vulnerability?
A scope change (S:C) in the CVSS metric indicates that successful exploitation of this vulnerability could extend beyond the immediate processing of malicious tokens, affecting the overall availability of the system by causing a denial-of-service (DoS) condition.

Patches

Has the problem been patched? What versions should users upgrade to?
The vulnerability has been fixed. Users should update all their Microsoft.IdentityModel versions to 7.1.2 (for 7x) or higher, 6.34.0 (for 6x) or higher, and 5.7.0 (for 5x).

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?
No, users must upgrade.

References

Are there any links users can visit to find out more?
https://aka.ms/IdentityModel/Jan2024/zip

critical: 0 high: 0 medium: 2 low: 0 System.IdentityModel.Tokens.Jwt 6.24.0.31013 (nuget)

pkg:nuget/[email protected]

medium 6.8: GHSA--59j7--ghrg--fj52

Affected range>=6.5.0
<6.34.0
Fixed version6.34.0
CVSS Score6.8
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:N/A:H
Description

Microsoft Security Advisory CVE-2024-21319: .NET Denial of Service Vulnerability

Executive summary

Microsoft is releasing this security advisory to provide information about a vulnerability in the ASP.NET Core project templates. This advisory also provides guidance on what developers can do to update their applications to address this vulnerability.

A Denial of Service vulnerability exists in ASP.NET Core project templates which utilize JWT-based authentication tokens. This vulnerability allows an unauthenticated client to consume arbitrarily large amounts of server memory, potentially triggering an out-of-memory condition on the server and making the server no longer able to respond to legitimate requests.

Announcement

Announcement for this issue can be found at dotnet/announcements#290

Mitigation factors

This impacts only .NET Core-based projects that were created using any version of project templates listed in affected software.
Other project templates e.g., console applications, MAUI applications, Windows Forms or WPF applications, are not affected.

Affected software

This impacts only .NET Core-based projects that were created using any version of the below project templates.

  • ASP.NET Core Web App (Model-View-Controller)
  • ASP.NET Core Web API
  • ASP.NET Core Web App (Razor Pages)
  • Blazor Server App
  • Blazor WebAssembly App

Advisory FAQ

How do I know if I am affected?

If you are you using project templates listed in affected software, you may be exposed to the vulnerability.

How do I fix the issue?

For existing projects:

If you ever created any of these projects via the dotnet new command or via Visual Studio's File -> New Project gesture, and if you enabled federated authentication at project creation time, your project may be vulnerable. To remediate the vulnerability, use your package manager to update any references you may have to the Microsoft.AspNetCore.Authentication.JwtBearer, Microsoft.AspNetCore.Authentication.OpenIdConnect, and Microsoft.IdentityModel.JsonWebTokens packages to their respective latest versions.

If your project does not reference any of those three packages, you are not exposed to this vulnerability.

For new projects:

To remediate this issue please update to the latest SDK listed below. Simply installing the SDK update is not sufficient to remediate projects already-created / already-deployed projects which existed prior to this update being released.

  • To fix the issue please install the latest version of .NET 6.0 or .NET 7.0. If you have installed one or more .NET SDKs through Visual Studio, Visual Studio will prompt you to update Visual Studio, which will also update your .NET SDKs.
  • If you are using one of the affected packages, please update to the patched version listed above.
  • If you have .NET 6.0 or greater installed, you can list the versions you have installed by running the dotnet --info command. You will see output like the following;
.NET Core SDK (reflecting any global.json):

 Version:   7.0.200
 Commit:    8473146e7d

Runtime Environment:

 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.300\

Host (useful for support):

  Version: 76.0.5
  Commit:  8473146e7d

.NET Core SDKs installed:

  7.0.200 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:

  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

.NET 6.0, .NET 7.0, .NET 8.0 updates are also available from Microsoft Update. To access this either type "Check for updates" in your Windows search, or open Settings, choose Update & Security and then click Check for Updates.

Once you have installed the updated runtime or SDK, restart your apps for the update to take effect.

Additionally, if you've deployed self-contained applications targeting any of the impacted versions, these applications are also vulnerable and must be recompiled and redeployed.

Other Information

Reporting Security Issues

If you have found a potential security issue in .NET 8.0 or .NET 7.0 or .NET 6.0, please email details to [email protected]. Reports may qualify for the Microsoft .NET Core & .NET 5 Bounty. Details of the Microsoft .NET Bounty Program including terms and conditions are at https://aka.ms/corebounty.

Support

You can ask questions about this issue on GitHub in the .NET GitHub organization. The main repos are located at https://github.com/dotnet/runtime and https://github.com/dotnet/aspnet/. The Announcements repo (https://github.com/dotnet/Announcements) will contain this bulletin as an issue and will include a link to a discussion issue. You can ask questions in the linked discussion issue.

Disclaimer

The information provided in this advisory is provided "as is" without warranty of any kind. Microsoft disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Microsoft Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Microsoft Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.

Acknowledgement

Morgan Brown, Microsoft Corp.

External Links

CVE-2024-21319

Revisions

V1.0 (January 09, 2024): Advisory published.

Version 1.0

Last Updated 2024-01-09

medium 6.8: CVE--2024--21319

Affected range>=6.5.0
<6.34.0
Fixed version6.34.0
CVSS Score6.8
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:N/I:N/A:H
Description

Impact

What kind of vulnerability is it? Who is impacted?
An attacker could exploit this vulnerability by crafting a malicious JSON Web Encryption (JWE) token with a high compression ratio. This token, when processed by a server, leads to excessive memory allocation and processing time during decompression, causing a denial-of-service (DoS) condition.

It's important to note that the attacker must have access to the public encrypt key registered with the IDP(Entra ID) for successful exploitation.

According to the CVSS metric, a successful exploitation could lead to a scope change (S:C). What does this mean for this vulnerability?
A scope change (S:C) in the CVSS metric indicates that successful exploitation of this vulnerability could extend beyond the immediate processing of malicious tokens, affecting the overall availability of the system by causing a denial-of-service (DoS) condition.

Patches

Has the problem been patched? What versions should users upgrade to?
The vulnerability has been fixed. Users should update all their Microsoft.IdentityModel versions to 7.1.2 (for 7x) or higher, 6.34.0 (for 6x) or higher, and 5.7.0 (for 5x).

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?
No, users must upgrade.

References

Are there any links users can visit to find out more?
https://aka.ms/IdentityModel/Jan2024/zip

Copy link

@stephenfuqua stephenfuqua left a comment

Choose a reason for hiding this comment

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

I was unable to test locally, even running on my home network which usually works for Docker containers. I get an error when the container reaches the dotnet restore command. This is probably just something weird happening on my computer. Would like to see someone else test this.

 => ERROR [adminapi build 6/6] RUN dotnet restore && dotnet build -c Release                                          2.0s
------
 > [adminapi build 6/6] RUN dotnet restore && dotnet build -c Release:
0.888   Determining projects to restore...
1.967 /usr/share/dotnet/sdk/6.0.201/NuGet.targets(130,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/source/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj]
1.967 /usr/share/dotnet/sdk/6.0.201/NuGet.targets(130,5): error :   Name does not resolve (api.nuget.org:443) [/source/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj]
1.967 /usr/share/dotnet/sdk/6.0.201/NuGet.targets(130,5): error :   Name does not resolve [/source/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj]

docs/docker.md Outdated Show resolved Hide resolved
Copy link

@stephenfuqua stephenfuqua left a comment

Choose a reason for hiding this comment

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

Please also update dev.Dockerfile with the same changes that we have in https://github.com/Ed-Fi-Alliance-OSS/AdminAPI-1.x/blob/main/Docker/dev.Dockerfile

@CSR2017 CSR2017 closed this Mar 28, 2024
@CSR2017 CSR2017 reopened this Mar 28, 2024
@CSR2017
Copy link
Author

CSR2017 commented Mar 28, 2024

I was unable to test locally, even running on my home network which usually works for Docker containers. I get an error when the container reaches the dotnet restore command. This is probably just something weird happening on my computer. Would like to see someone else test this.

 => ERROR [adminapi build 6/6] RUN dotnet restore && dotnet build -c Release                                          2.0s
------
 > [adminapi build 6/6] RUN dotnet restore && dotnet build -c Release:
0.888   Determining projects to restore...
1.967 /usr/share/dotnet/sdk/6.0.201/NuGet.targets(130,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/source/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj]
1.967 /usr/share/dotnet/sdk/6.0.201/NuGet.targets(130,5): error :   Name does not resolve (api.nuget.org:443) [/source/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj]
1.967 /usr/share/dotnet/sdk/6.0.201/NuGet.targets(130,5): error :   Name does not resolve [/source/EdFi.Ods.AdminApi/EdFi.Ods.AdminApi.csproj]

@stephenfuqua I had similar issue after updating my docker desktop version. I followed this to adding the dns value temporarily dotnet/core#8048

@CSR2017
Copy link
Author

CSR2017 commented Mar 28, 2024

Please also update dev.Dockerfile with the same changes that we have in https://github.com/Ed-Fi-Alliance-OSS/AdminAPI-1.x/blob/main/Docker/dev.Dockerfile

.Net 8 migration changes will be addressed as part of #95

@stephenfuqua
Copy link

@stephenfuqua I had similar issue after updating my docker desktop version. I followed this to adding the dns value temporarily dotnet/core#8048

Thank you for this link. Another solution mentioned there is to install curl, which will update the DNS server. I tried that and it worked.

We were already installing curl on line 38. We can move that earlier in the code to occur before dotnet restore. Move all of the apk add commands earlier, so that we can cache as a base layer. End up with these layers:

  1. Base layer from Microsoft AS buildBase
  2. Install curl - new base layer for caching AS build
  3. Copy in source code - new layer AS publish
  4. Start from new Microsoft base layer AS runtimeBase
  5. Install curl and other required packages AS runtime
  6. Finally, copy the DLL's from layer 3 into layer 4.

@CSR2017
Copy link
Author

CSR2017 commented Mar 28, 2024

@stephenfuqua I had similar issue after updating my docker desktop version. I followed this to adding the dns value temporarily dotnet/core#8048

Thank you for this link. Another solution mentioned there is to install curl, which will update the DNS server. I tried that and it worked.

We were already installing curl on line 38. We can move that earlier in the code to occur before dotnet restore. Move all of the apk add commands earlier, so that we can cache as a base layer. End up with these layers:

  1. Base layer from Microsoft AS buildBase
  2. Install curl - new base layer for caching AS build
  3. Copy in source code - new layer AS publish
  4. Start from new Microsoft base layer AS runtimeBase
  5. Install curl and other required packages AS runtime
  6. Finally, copy the DLL's from layer 3 into layer 4.

I tried these steps for rearranging the commands to cache the curl. But still getting the "Unable to load the service index for source" error. I noticed that, we dont have any issue running the Admin API 1.x dev.dockerfile, the difference is - upgraded to .net 8. So I tried running the dev.dockerfile from Johnny's PR. It is working fine. Should I still try accomplish the suggested changes ?

@stephenfuqua
Copy link

I recommend re-arranging the layers anyway, as this is a better structure. Apparently the error message we are both seeing has different solutions. Moving the curl command earlier fixed it for me, without having to modify the Docker engine configuration.

FROM mcr.microsoft.com/dotnet/aspnet@sha256:201cedd60cb295b2ebea7184561a45c5c0ee337e37300ea0f25cff5a2c762538
LABEL maintainer="Ed-Fi Alliance, LLC and Contributors <[email protected]>"
ARG VERSION=latest
FROM mcr.microsoft.com/dotnet/aspnet@sha256:201cedd60cb295b2ebea7184561a45c5c0ee337e37300ea0f25cff5a2c762538 AS base

Choose a reason for hiding this comment

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

I really thought that I saw the api.nuget.org connectivity problem being resolved a few days ago when I just moved the curl command. Like you, however, this didn't work for me 😞 .

But... I did find an easy solution: just update the base image to the .NET 8 version! Even though .NET 8 upgrade isn't finished, the SDK for .NET 8 will build a project that targets .NET 6.

Changing to the following solved the problem for me. This is slightly newer than the version we have in Admin API 1 - this version must have been released just a few days ago.

FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.18@sha256:2a8dca3af111071172b1629c12eefaeca0d6c2954887c4489195771c9e90833c as buildBase

Choose a reason for hiding this comment

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

A PR into your branch: #97

@stephenfuqua stephenfuqua merged commit 71fb3fa into main Apr 1, 2024
11 checks passed
@stephenfuqua stephenfuqua deleted the ADMINAPI-989 branch April 1, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants