-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(security): update sandbox Perl runtime #7504
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ea9bec0
fix(security): update sandbox Perl runtime
apurvvkumaria eafa6e6
test(security): scope base runtime assertion
apurvvkumaria 68e8f2c
ci(images): allow source base rebuilds
apurvvkumaria 99b3e4c
merge(main): refresh Perl security remediation
senthilr-nv 9ae4b1e
merge(main): refresh Perl security remediation
senthilr-nv 44e6cd4
test(security): document Perl QEMU workaround
apurvvkumaria 0a79076
merge(main): refresh Perl security remediation
senthilr-nv 16169c7
test(security): scope apt checksum harness
senthilr-nv 05266a6
test(security): keep checksum test linear
senthilr-nv c53a8bd
merge(main): refresh Perl security remediation
senthilr-nv dad76f5
merge(main): refresh Perl security remediation
senthilr-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| const dockerfile = fs.readFileSync(path.join(import.meta.dirname, "..", "Dockerfile.base"), "utf8"); | ||
| const baseImageWorkflow = fs.readFileSync( | ||
| path.join(import.meta.dirname, "..", ".github", "workflows", "base-image.yaml"), | ||
| "utf8", | ||
| ); | ||
| const fixedPerlVersion = "5.44.0"; | ||
| const fixedPerlSha256 = "505cf43912e9480495c344c70260452e32aa2a73c546a026b3f100053b23ce91"; | ||
|
|
||
| function stageNamed(name: string): string { | ||
| const start = dockerfile.indexOf(` AS ${name}`); | ||
| expect(start, `missing ${name} stage`).toBeGreaterThanOrEqual(0); | ||
| const next = dockerfile.indexOf("\nFROM ", start); | ||
| return dockerfile.slice(start, next >= 0 ? next : undefined); | ||
| } | ||
|
|
||
| function completedStage(): string { | ||
| const start = dockerfile.lastIndexOf("\nFROM "); | ||
| expect(start, "missing completed image stage").toBeGreaterThanOrEqual(0); | ||
| return dockerfile.slice(start); | ||
| } | ||
|
|
||
| function argumentDefault(name: string): string | undefined { | ||
| return dockerfile.match(new RegExp(`^ARG ${name}=([^\\s]+)$`, "mu"))?.[1]; | ||
| } | ||
|
|
||
| describe("sandbox base critical Perl CVE remediation", () => { | ||
| // source-shape-contract: security -- Exact upstream version and checksum bind the replacement runtime to the reviewed CVE fixes | ||
| it("builds the fixed upstream release from a checksum-pinned source archive (#7338)", () => { | ||
| const builder = stageNamed("perl-builder"); | ||
| const download = builder.indexOf( | ||
| '-o /tmp/perl.tar.xz "https://www.cpan.org/src/5.0/perl-${PERL_VERSION}.tar.xz"', | ||
| ); | ||
| const checksum = builder.indexOf("sha256sum -c /tmp/perl.sha256"); | ||
| const extract = builder.indexOf("tar -xJf /tmp/perl.tar.xz"); | ||
|
|
||
| expect(argumentDefault("PERL_VERSION")).toBe(fixedPerlVersion); | ||
| expect(argumentDefault("PERL_SHA256")).toBe(fixedPerlSha256); | ||
| expect(download).toBeGreaterThanOrEqual(0); | ||
| expect(checksum).toBeGreaterThan(download); | ||
| expect(extract).toBeGreaterThan(checksum); | ||
| expect(builder).toContain("-Dd_syscallproto=define"); | ||
| expect(builder).toContain("Perl Configure's d_syscallproto probe"); | ||
| expect(builder).toContain("Remove this override when the QEMU-backed multi-arch"); | ||
| expect(builder).toContain(".github/workflows/base-image.yaml"); | ||
| expect(baseImageWorkflow).toContain("docker/setup-qemu-action"); | ||
| expect(baseImageWorkflow).toContain("platforms: linux/amd64,linux/arm64"); | ||
| expect(baseImageWorkflow).toContain("dockerfile: Dockerfile.base"); | ||
| }); | ||
|
|
||
| it("runs the upstream test suite before packaging the replacement runtime (#7338)", () => { | ||
| const builder = stageNamed("perl-builder"); | ||
| const compile = builder.indexOf('make -j"$(nproc)"'); | ||
| const test = builder.indexOf("make test"); | ||
| const install = builder.indexOf("make install DESTDIR=/tmp/perl-root"); | ||
| const packageBuild = builder.indexOf("dpkg-deb --build --root-owner-group"); | ||
|
|
||
| expect(compile).toBeGreaterThanOrEqual(0); | ||
| expect(test).toBeGreaterThan(compile); | ||
| expect(install).toBeGreaterThan(test); | ||
| expect(packageBuild).toBeGreaterThan(install); | ||
| }); | ||
|
|
||
| it("replaces the vulnerable distro packages without breaking dpkg ownership (#7338)", () => { | ||
| const builder = stageNamed("perl-builder"); | ||
| const runtime = completedStage(); | ||
|
|
||
| expect(builder).toContain( | ||
| '"Provides: libperl5.40 (= ${package_version}), perl-modules-5.40 (= ${package_version})"', | ||
| ); | ||
| expect(builder).toContain("'Conflicts: libperl5.40, perl-modules-5.40'"); | ||
| expect(builder).toContain( | ||
| '"Replaces: libperl5.40, perl-modules-5.40, perl (<< ${package_version})"', | ||
| ); | ||
| expect(runtime).toContain( | ||
| "apt-get install -y --no-install-recommends /tmp/perl-base.deb /tmp/perl.deb", | ||
| ); | ||
| expect(runtime).toContain('test -z "$(dpkg --audit)"'); | ||
| }); | ||
|
|
||
| it("fails the image build unless all three critical fixes are active (#7338)", () => { | ||
| const runtime = completedStage(); | ||
|
|
||
| expect(runtime).toContain(`test "$(perl -e 'print $^V')" = "v${fixedPerlVersion}"`); | ||
| expect(runtime).toContain(`test "$(perl -MSocket -e 'print Socket->VERSION')" = "2.041"`); | ||
| expect(runtime).toContain(`test "$(perl -MStorable -e 'print Storable->VERSION')" = "3.41"`); | ||
| expect(runtime).toContain("pack_ip_mreq_source"); | ||
| expect(runtime).toContain('die "short source accepted"'); | ||
| expect(runtime).toContain('use re "Debug"'); | ||
| expect(runtime).toContain('"fnord" =~ m/(?:$x)|(?:$y)/'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| BASE_APT_SECURITY_FUNCTIONS, | ||
| dockerRunCommandBetween, | ||
| runLoggedDockerShell, | ||
| } from "./helpers/base-apt-security-functions"; | ||
|
|
||
| const ROOT = path.resolve(import.meta.dirname, ".."); | ||
| const DOCKERFILE_BASE = path.join(ROOT, "Dockerfile.base"); | ||
|
|
||
| describe("sandbox base security packages", () => { | ||
| it("rejects a sandbox security package when its expected checksum changes", () => { | ||
| const dockerfile = fs.readFileSync(DOCKERFILE_BASE, "utf-8"); | ||
| const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-base-checksum-")); | ||
| const untouchedTail = path.join(tmp, "untouched-python-link"); | ||
| const command = dockerRunCommandBetween( | ||
| dockerfile, | ||
| "ENV DEBIAN_FRONTEND=noninteractive", | ||
| "# gosu for privilege separation", | ||
| ) | ||
| .replace("df928e3a8e4da79408d4b18e8cd80a03dffa90130d0698e50041aab5e14f9397", "0".repeat(64)) | ||
| .replaceAll("/var/lib/apt/lists", tmp) | ||
| .replaceAll("/tmp/nemoclaw-debian-security", path.join(tmp, "security-debs")) | ||
| .replaceAll("/usr/local/bin/python", untouchedTail) | ||
| .replaceAll("/usr/bin/python3", path.join(tmp, "python3")); | ||
|
|
||
| try { | ||
| const result = runLoggedDockerShell(command, tmp, [ | ||
| 'apt-get() { printf "apt-get %s\\n" "$*" >> "$call_log"; }', | ||
| ...BASE_APT_SECURITY_FUNCTIONS, | ||
| ]); | ||
| expect(result.status).not.toBe(0); | ||
| expect(fs.existsSync(untouchedTail)).toBe(false); | ||
| } finally { | ||
| fs.rmSync(tmp, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.