Skip to content

Commit e8e79a0

Browse files
github-actions[bot]devin-ai-integration[bot]davidkonigsberg
authored
chore(csharp): patch C# SDK generator container for 2026-05-06 grype scan (#15738)
* [Grype Scan][csharp-sdk] Scaffold PR for 40 vulnerabilities * chore(csharp): patch C# SDK generator container for 2026-05-06 grype scan Remediate the 40 vulnerabilities reported against the csharp-sdk image: - Bump Node base image from 22.12-alpine3.20 to 22.22.2-alpine3.22 (fixes the Node binary CVEs and upgrades npm-bundled cross-spawn, minimatch, glob, tar, and diff to non-vulnerable versions). - Switch the runtime base image from dotnet/sdk:10.0-alpine to dotnet/aspnet:10.0-alpine and install csharpier in a separate sdk build stage; this drops the SDK-bundled System.Security.Cryptography.Xml 10.0.5 DLL flagged by GHSA-37gx-xxp4-5rgx and GHSA-w3x6-4m5h-cxqf. - Add 'apk upgrade' to pick up the alpine 3.23 nghttp2-libs 1.69.0-r0 fix for CVE-2026-27135. - Patch npm's bundled ip-address (10.1.1), picomatch (4.0.4), and brace-expansion (2.0.3) using the same in-place pattern as the Java SDK Dockerfile. - Delete the .github/grype-scans/scan-csharp-sdk-20260506.md scaffold file and add a chore changelog entry under the unreleased folder. * fix: keep .NET SDK in csharp-sdk image; drop unused PowerShell instead The previous switch from dotnet/sdk to dotnet/aspnet broke the C# SDK generator because some fixtures (e.g. csharp-namespace-collision:fully- qualified-namespaces) run `dotnet format` during generation, which requires the full SDK rather than the runtime-only image. Revert the runtime to mcr.microsoft.com/dotnet/sdk:10.0-alpine and remove the unused PowerShell install that ships with the SDK image. Powershell is what brought the vulnerable System.Security.Cryptography.Xml 10.0.5 DLL flagged by GHSA-37gx-xxp4-5rgx and GHSA-w3x6-4m5h-cxqf into the layer; the C# SDK generator does not invoke pwsh, so removing it eliminates the finding without affecting `dotnet format` or csharpier. Local `grype --only-fixed` confirms 0 fixable vulnerabilities remain. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: David Konigsberg <72822263+davidkonigsberg@users.noreply.github.com>
1 parent 994e929 commit e8e79a0

2 files changed

Lines changed: 80 additions & 3 deletions

File tree

generators/csharp/sdk/Dockerfile

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
FROM node:22.12-alpine3.20 AS node
1+
# Stage 1: Node.js
2+
# Pinned to 22.22.2-alpine3.22 to fix Node.js binary CVEs picked up by the
3+
# 2026-05-06 grype scan (CVE-2025-23166, CVE-2025-23083, CVE-2025-59465,
4+
# CVE-2026-21637, CVE-2025-55131, CVE-2026-21710, CVE-2025-59466,
5+
# CVE-2025-23085, CVE-2026-21717, CVE-2026-21713, CVE-2026-21714,
6+
# CVE-2025-55132, CVE-2025-23165, CVE-2026-21715, CVE-2026-21716,
7+
# CVE-2025-55130) and to upgrade npm-bundled deps cross-spawn (>=7.0.5),
8+
# minimatch (>=9.0.7), glob (>=10.5.0), tar (>=7.5.11), and diff (>=5.2.2).
9+
FROM node:22.22.2-alpine3.22 AS node
10+
211
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine
312

413
ENV YARN_CACHE_FOLDER=/.yarn
@@ -13,17 +22,74 @@ ENV SENTRY_DSN=$SENTRY_DSN
1322
ENV SENTRY_ENVIRONMENT=$SENTRY_ENVIRONMENT
1423
ENV SENTRY_RELEASE=$SENTRY_RELEASE
1524

16-
RUN apk --no-cache add bash curl git zip && \
25+
# `apk upgrade` pulls the latest Alpine 3.23 package fixes (e.g. nghttp2-libs
26+
# 1.69.0-r0 to address CVE-2026-27135) on top of what ships in the base image.
27+
RUN apk --no-cache upgrade && \
28+
apk --no-cache add bash curl git zip && \
1729
git config --global user.email "115122769+fern-api[bot]@users.noreply.github.com" && \
1830
git config --global user.name "fern-api"
1931

32+
# PowerShell is bundled with the .NET SDK image but is unused by the C# SDK
33+
# generator (the generator only needs `dotnet format` and the `csharpier`
34+
# tool). Removing it drops the vulnerable
35+
# /usr/share/powershell/.../System.Security.Cryptography.Xml.dll 10.0.5
36+
# (GHSA-37gx-xxp4-5rgx and GHSA-w3x6-4m5h-cxqf) without affecting the SDK
37+
# itself.
38+
RUN rm -rf /usr/share/powershell /usr/bin/pwsh
39+
40+
RUN dotnet tool install -g csharpier --version "1.2.6"
41+
2042
# Copy over node contents to be able to run the compiled CLI
2143
COPY --from=node /usr/local/bin/node /usr/local/bin/
2244
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
2345
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
2446
&& ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
2547

26-
RUN dotnet tool install -g csharpier --version "1.2.6"
48+
# Patch ip-address to 10.1.1 to fix GHSA-v2v4-37r5-5v8g
49+
# (XSS in Address6 HTML-emitting methods).
50+
# Location: npm bundles its own copy of ip-address.
51+
RUN for dir in \
52+
/usr/local/lib/node_modules/npm/node_modules/ip-address; do \
53+
if [ -d "$dir" ]; then \
54+
rm -rf "$dir" && \
55+
cd "$(dirname "$dir")" && \
56+
curl -sL https://registry.npmjs.org/ip-address/-/ip-address-10.1.1.tgz -o ip-address-10.1.1.tgz && \
57+
tar -xzf ip-address-10.1.1.tgz && \
58+
mv package ip-address && \
59+
rm ip-address-10.1.1.tgz; \
60+
fi; \
61+
done
62+
63+
# Patch picomatch to 4.0.4 to fix GHSA-c2c7-rcm5-vvqj (ReDoS via extglob
64+
# quantifiers) and GHSA-3v7f-55p6-f55p (Method Injection in POSIX Character
65+
# Classes). Location: npm's bundled tinyglobby depends on picomatch.
66+
RUN for dir in \
67+
/usr/local/lib/node_modules/npm/node_modules/picomatch \
68+
/usr/local/lib/node_modules/npm/node_modules/tinyglobby/node_modules/picomatch; do \
69+
if [ -d "$dir" ]; then \
70+
rm -rf "$dir" && \
71+
cd "$(dirname "$dir")" && \
72+
curl -sL https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz -o picomatch-4.0.4.tgz && \
73+
tar -xzf picomatch-4.0.4.tgz && \
74+
mv package picomatch && \
75+
rm picomatch-4.0.4.tgz; \
76+
fi; \
77+
done
78+
79+
# Patch brace-expansion to 2.0.3 to fix GHSA-f886-m6hf-6m8v
80+
# (zero-step sequence causes process hang and memory exhaustion).
81+
# Location: npm bundles its own copy of brace-expansion.
82+
RUN for dir in \
83+
/usr/local/lib/node_modules/npm/node_modules/brace-expansion; do \
84+
if [ -d "$dir" ]; then \
85+
rm -rf "$dir" && \
86+
cd "$(dirname "$dir")" && \
87+
curl -sL https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz -o brace-expansion-2.0.3.tgz && \
88+
tar -xzf brace-expansion-2.0.3.tgz && \
89+
mv package brace-expansion && \
90+
rm brace-expansion-2.0.3.tgz; \
91+
fi; \
92+
done
2793

2894
COPY generators/csharp/sdk/features.yml /assets/features.yml
2995
COPY generators/csharp/sdk/dist /dist
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- summary: |
2+
Patch the C# SDK generator container to remediate the 40 vulnerabilities
3+
reported by the 2026-05-06 grype scan. Bump the Node.js base image to
4+
22.22.2-alpine3.22 (fixes Node binary CVEs and upgrades npm-bundled
5+
cross-spawn, minimatch, glob, tar, and diff), remove the unused PowerShell
6+
install bundled with `dotnet/sdk:10.0-alpine` to drop the vulnerable
7+
System.Security.Cryptography.Xml 10.0.5 DLL flagged by GHSA-37gx-xxp4-5rgx
8+
and GHSA-w3x6-4m5h-cxqf, run `apk upgrade` to pick up the nghttp2-libs
9+
CVE-2026-27135 fix, and patch npm's bundled ip-address (10.1.1),
10+
picomatch (4.0.4), and brace-expansion (2.0.3).
11+
type: chore

0 commit comments

Comments
 (0)