Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions agents/hermes-01x/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,13 @@ RUN ( set -eu; \
&& check_metadata /sandbox/.venvs/sandbox-mcp-server/bin/sandbox-mcp-server 'root:root 755' ) \
# Verify the immutable security package inventory in the completed image.
&& ( set -eu; \
security_probe="$(node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON /opt/nemoclaw-security/scripts/security/security-package-inventory.mts probe hermes-compatible)"; \
security_probe="$(node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON /opt/nemoclaw-security/scripts/security/security-package-inventory.mts probe hermes-01x)"; \
sh -ec "$security_probe"; \
test "$(perl -e 'print $^V')" = "v5.44.0"; \
ldd /usr/bin/jq | grep -Eq 'libonig[.]so[.]5'; \
test "$(jq --version)" = "jq-1.8.2"; \
printf '%s\n' '{"sandbox":"healthy"}' | jq -e '.sandbox == "healthy"' >/dev/null; \
python3 -c "import pyexpat; assert pyexpat.EXPAT_VERSION == 'expat_2.8.3', pyexpat.EXPAT_VERSION"; \
python3 -c "import pyexpat; assert pyexpat.EXPAT_VERSION == 'expat_2.9.0', pyexpat.EXPAT_VERSION"; \
printf '%s %s\n' \
"4ff43a8578bda2f14686c67911b64c18e869841973722b1c623b5727491bdaf7" \
/usr/lib/python3.13/html/parser.py \
Expand Down
14 changes: 7 additions & 7 deletions agents/hermes-01x/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ RUN --mount=type=bind,source=scripts/security/security-package-inventory.mts,tar
&& arch="$(dpkg --print-architecture)" \
&& case "$arch" in \
amd64) \
libexpat_sha256="978e9d30b84893a4c8191d8dae4d1b93c9b7ecaa772ada2fdb892ae3765cab4e"; \
libexpat_sha256="feff874772cae904ae4d24e917b35664952bec4b4ae9100a4edda5a7fa746832"; \
libonig_sha256="3abee130696244050500bcc7870e3b4cb82ddd87149ece3fd55010c3d4e1d18c"; \
libjq_sha256="9a5bf964cef39ed8f0f162e20d856e31961d28a57772b5313989b42a8be7e941"; \
jq_sha256="b973a5d304f666845e8ccefab492e3850d4bc2e7aa2a1e7450862095125f2cc0"; \
vim_tiny_sha256="df2d037d405f1376d1d8025d022dba81fbfed8695f68a131b788d16d3b68cf83" \
;; \
arm64) \
libexpat_sha256="660f5f598a06aa56613a2fbf1ffbd408708175f1a6c2fac833842148f0228176"; \
libexpat_sha256="d9e1c50fcdad079fe16d77f1578adcc763be1bf7f2da7fa8adca7010b0c84c83"; \
libonig_sha256="137e708575c0622d347815d19cb471a107546b16e9602805ee27afad7bba107f"; \
libjq_sha256="eae4a828df2eb53d728f88109d9f9549e0983a90b573cf0c7fa1e4bbc7533a7e"; \
jq_sha256="c25086443abd04d1457cbb322a0837f9ba986f82b28f44670467c8dc9be1f696"; \
Expand All @@ -152,14 +152,14 @@ RUN --mount=type=bind,source=scripts/security/security-package-inventory.mts,tar
esac \
&& security_deb_dir="/tmp/nemoclaw-debian-security" \
&& snapshot_url="https://snapshot.debian.org/archive/debian/20260724T000000Z/pool/main" \
&& expat_snapshot_url="https://snapshot.debian.org/archive/debian/20260811T082421Z/pool/main" \
&& expat_snapshot_url="https://snapshot.debian.org/archive/debian/20261017T204620Z/pool/main" \
&& vim_snapshot_url="https://snapshot.debian.org/archive/debian/20260727T143429Z/pool/main" \
&& vim_common_sha256="c21aad77632ef790d2352f1c38e688069980bbd530034248dd5e1158da9c9fe3" \
&& mkdir -p "$security_deb_dir" \
&& curl --proto '=https' --tlsv1.2 -fsSL \
--retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 15 --max-time 120 \
-o "$security_deb_dir/libexpat1.deb" \
"$expat_snapshot_url/e/expat/libexpat1_2.8.3-1_${arch}.deb" \
"$expat_snapshot_url/e/expat/libexpat1_2.9.0-1~deb13u1_${arch}.deb" \
&& curl --proto '=https' --tlsv1.2 -fsSL \
--retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 15 --max-time 120 \
-o "$security_deb_dir/libonig5.deb" \
Expand Down Expand Up @@ -204,7 +204,7 @@ RUN --mount=type=bind,source=scripts/security/security-package-inventory.mts,tar
&& test "$(jq --version)" = "jq-1.8.2" \
&& ldd /usr/bin/jq | grep -Eq 'libonig[.]so[.]5' \
&& printf '%s\n' '{"sandbox":"healthy"}' | jq -e '.sandbox == "healthy"' >/dev/null \
&& python3 -c "import pyexpat; assert pyexpat.EXPAT_VERSION == 'expat_2.8.3', pyexpat.EXPAT_VERSION" \
&& python3 -c "import pyexpat; assert pyexpat.EXPAT_VERSION == 'expat_2.9.0', pyexpat.EXPAT_VERSION" \
&& printf '%s %s\n' \
"4ff43a8578bda2f14686c67911b64c18e869841973722b1c623b5727491bdaf7" \
/usr/lib/python3.13/html/parser.py \
Expand All @@ -226,11 +226,11 @@ RUN --mount=type=bind,source=scripts/security/security-package-inventory.mts,tar
&& perl -e \
'my $x = join "|", "aaa".."mzz"; my $y = join "|", "naa".."zzz"; use re "Debug"; "fnord" =~ m/(?:$x)|(?:$y)/' \
&& install -d -o root -g root -m 0755 /usr/local/share/nemoclaw \
&& node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON /tmp/nemoclaw-security/scripts/security/security-package-inventory.mts inventory shared "$(dpkg --print-architecture)" \
&& node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON /tmp/nemoclaw-security/scripts/security/security-package-inventory.mts inventory hermes-01x "$(dpkg --print-architecture)" \
> /usr/local/share/nemoclaw/security-packages.txt \
&& chown root:root /usr/local/share/nemoclaw/security-packages.txt \
&& chmod 0444 /usr/local/share/nemoclaw/security-packages.txt \
&& security_probe="$(node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON /tmp/nemoclaw-security/scripts/security/security-package-inventory.mts probe shared)" \
&& security_probe="$(node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON /tmp/nemoclaw-security/scripts/security/security-package-inventory.mts probe hermes-01x)" \
&& sh -ec "$security_probe" \
&& rm -rf /tmp/nemoclaw-native-security \
&& rm -rf "$security_deb_dir" \
Expand Down
11 changes: 10 additions & 1 deletion docs/modification/2026-11-17-hermes-tools-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ agent 在 sandbox 內處理這些工作時,不需要在執行期間下載套件
index digest 為 `sha256:89aad1dc08c0c8d7fafc49089f7351b44ed4dec6b5027df6b8d8b193af04a577`。
`agents/hermes-01x/Dockerfile.tools` 的 `BASE_IMAGE` 同時寫出 tag 與 digest;建置以 digest 為準,tag 用來產生發布 tag。

`2026.11.25` base 不能安裝 Debian trixie-security 目前提供的 LibreOffice `4:26.8.3.1-0+deb13u1`:它需要 `libexpat1 (>= 2.9.0)`,但這個 base 的受控套件是 `libexpat1 2.8.3-1`,tools 映像的 apt 步驟因此失敗(#92)。
Issue #95 讓 Hermes 0.1.x base(`agents/hermes-01x/Dockerfile.base`)改裝 `libexpat1 2.9.0-1~deb13u1`,也就是 OpenClaw base 已審過的同一個檔案,並使用 Hermes 0.1.x 專用的受控套件 profile `hermes-01x`。
OpenShell 0.0.x 的 Hermes 與 Deep Agents Code base 仍是 `2.8.3-1`。
這項修改不發布映像;合併後依序執行:

1. 以 `Images / Hermes OpenShell 0.1.x` 發布新的 Hermes 映像。
2. 把新的 tag 與 index digest 寫進 `Dockerfile.tools` 的 `BASE_IMAGE`(見第 5 節的「更新 base」)。
3. 發布 tools 映像。

只提供 OpenShell 0.1.x 版本。OpenShell 0.0.x 的 Hermes 映像(`agents/hermes/`)預定淘汰,不提供 tools 映像。

這是本 fork 的功能,不是 NVIDIA 官方支援的產品。
Expand Down Expand Up @@ -144,5 +153,5 @@ gateway 與 API runtime 由 OpenShell 啟動,要在 OpenShell 0.1.7 sandbox 中
- **新增的特權檔案**:LibreOffice 的相依套件帶入 `dbus-daemon-launch-helper`(setuid)與 `gst-ptp-helper`(file capability)。process 設定 `no_new_privs` 時兩者都不會取得額外權限;fixture 與啟動比對都在這個條件下執行,OpenShell sandbox 內的 process 也實測為 `NoNewPrivs: 1`(見下方實機驗收)。其他新增的特權檔案會讓 `check-image.sh` 失敗。
- **API profile 不受影響**:API profile 的政策拒絕 terminal 與 browser 工具,Landlock 也只開放部分路徑,新工具只在預設 profile 使用。API profile 的 `config.yaml` 由 managed policy 的受管區段產生,`tools.3` 起 `browser` 區段也帶有 `backend: "off"`,但 browser 工具仍被拒絕。
- **沒有 `config.yaml` 的具名 profile**:`tools.2` 與 `tools.3` 中,這類 profile 的 `browser.backend` 是未設定,Hermes 改用 Browser Use CLI;base 映像的 `profile-policy` 檢查若在這兩版重跑,會因此不通過。`tools.4` 起,Hermes 原始碼的預設值是 `off`(見 3.3 節),建置步驟在 tools 映像重跑 `profile-policy` 檢查,fixture 的 `hermes_profile_browser` 也確認不會呼叫 `uvx`。profile 自己設定的 `browser.backend` 仍然優先,設成 `""` 或 `browser-use` 時 Hermes 仍會改用 Browser Use CLI。base 映像(`openshell-hermes`)沒有這項修改。
- **base 的安全檢查**:Hermes base 沒有 tmux,受控的 expat 版本(`libexpat1=2.8.3-1`)也與 OpenClaw base(2.9.0)不同,所以 `base_security_checks` 只對 OpenClaw 檢查這兩項;Hermes 的 expat 版本由 `controlled_packages` 依 base 的 `security-packages.txt` 檢查。
- **base 的安全檢查**:Hermes base 沒有 tmux,`2026.11.25` base 的受控 expat 版本(`libexpat1=2.8.3-1`)也與 OpenClaw base(2.9.0)不同,所以 `base_security_checks` 只對 OpenClaw 檢查這兩項;Hermes 的 expat 版本由 `controlled_packages` 依 base 的 `security-packages.txt` 檢查。#95 之後的 Hermes base 改用 `2.9.0-1~deb13u1`。
- **實機驗收**(`tools.1`,OpenShell 0.1.7、Podman、arm64,經 ClawShell 建立):sandbox 到 `running`,API 對話與 `upload_file` 上傳下載正常;`nemoclaw-start`、Hermes gateway、API runtime 與 MCP supervisor 的 `NoNewPrivs` 皆為 1;4 個 LibreOffice 同時轉檔時 sandbox 內 process 峰值 31(#32 的上限 512)。
9 changes: 6 additions & 3 deletions scripts/security/security-package-inventory.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
// SPDX-License-Identifier: Apache-2.0

import {
HERMES_01X_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY,
OPENCLAW_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY,
PINNED_HERMES_BASE_SECURITY_PACKAGE_INVENTORY,
SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY,
securityInventoryProbe,
} from "../../src/lib/sandbox-base-image/security-package-specs.ts";

const [operation, profile, architecture] = process.argv.slice(2);
if (!["shared", "openclaw", "hermes-compatible"].includes(profile ?? "")) {
throw new Error("Expected shared, openclaw, or hermes-compatible package profile");
if (!["shared", "openclaw", "hermes-compatible", "hermes-01x"].includes(profile ?? "")) {
throw new Error("Expected shared, openclaw, hermes-compatible, or hermes-01x package profile");
}
const inventory =
profile === "openclaw"
? OPENCLAW_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY
: SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY;
: profile === "hermes-01x"
? HERMES_01X_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY
: SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY;
switch (operation) {
case "inventory":
if (architecture !== "amd64" && architecture !== "arm64") {
Expand Down
17 changes: 13 additions & 4 deletions scripts/security/standalone-security-package-inventory.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const PINNED_HERMES_BASE_SECURITY_PACKAGE_OVERRIDES: ReadonlyMap<string, string>
["libc-bin=2.41-12+deb13u5", "libc-bin=2.41-12+deb13u4"],
]);
const SHARED_LIBEXPAT_PACKAGE = "libexpat1=2.8.3-1";
// Only the OpenClaw base installs the Debian security update (#19).
// The OpenClaw (#19) and Hermes 0.1.x base images install the Debian security
// update. LibreOffice 26.8 in the Hermes tools image needs it (#95).
const OPENCLAW_LIBEXPAT_PACKAGE = "libexpat1=2.9.0-1~deb13u1";
const SHARED_ZLIB_PACKAGE = "zlib1g=1:1.3.dfsg+really1.3.1-1+b1+nemoclaw1";
// The OpenClaw base installs Debian's zlib and apt security updates, which
Expand Down Expand Up @@ -66,6 +67,12 @@ const OPENCLAW_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY = [
"libapt-pkg7.0=3.0.4",
] as const;

/** Hermes 0.1.x base: the shared inventory with the Debian expat update (#95). */
const HERMES_01X_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY =
SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY.map((packageSpec) =>
packageSpec === SHARED_LIBEXPAT_PACKAGE ? OPENCLAW_LIBEXPAT_PACKAGE : packageSpec,
);

const SECURITY_INVENTORY_PROBE_OK = "nemoclaw-security-inventory-ok";
const SANDBOX_BASE_NODE_VERSION = "24.22.1";

Expand Down Expand Up @@ -107,13 +114,15 @@ function securityInventoryProbe(
}

const [operation, profile, architecture] = process.argv.slice(2);
if (!["shared", "openclaw", "hermes-compatible"].includes(profile ?? "")) {
throw new Error("Expected shared, openclaw, or hermes-compatible package profile");
if (!["shared", "openclaw", "hermes-compatible", "hermes-01x"].includes(profile ?? "")) {
throw new Error("Expected shared, openclaw, hermes-compatible, or hermes-01x package profile");
}
const inventory =
profile === "openclaw"
? OPENCLAW_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY
: SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY;
: profile === "hermes-01x"
? HERMES_01X_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY
: SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY;
switch (operation) {
case "inventory":
if (architecture !== "amd64" && architecture !== "arm64") {
Expand Down
9 changes: 8 additions & 1 deletion src/lib/sandbox-base-image/security-package-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const PINNED_HERMES_BASE_SECURITY_PACKAGE_OVERRIDES: ReadonlyMap<string, string>
["libc-bin=2.41-12+deb13u5", "libc-bin=2.41-12+deb13u4"],
]);
const SHARED_LIBEXPAT_PACKAGE = "libexpat1=2.8.3-1";
// Only the OpenClaw base installs the Debian security update (#19).
// The OpenClaw (#19) and Hermes 0.1.x base images install the Debian security
// update. LibreOffice 26.8 in the Hermes tools image needs it (#95).
const OPENCLAW_LIBEXPAT_PACKAGE = "libexpat1=2.9.0-1~deb13u1";
const SHARED_ZLIB_PACKAGE = "zlib1g=1:1.3.dfsg+really1.3.1-1+b1+nemoclaw1";
// The OpenClaw base installs Debian's zlib and apt security updates, which
Expand Down Expand Up @@ -67,6 +68,12 @@ export const OPENCLAW_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY = [
"libapt-pkg7.0=3.0.4",
] as const;

/** Hermes 0.1.x base: the shared inventory with the Debian expat update (#95). */
export const HERMES_01X_SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY =
SANDBOX_BASE_SECURITY_PACKAGE_INVENTORY.map((packageSpec) =>
packageSpec === SHARED_LIBEXPAT_PACKAGE ? OPENCLAW_LIBEXPAT_PACKAGE : packageSpec,
);

export const SECURITY_INVENTORY_PROBE_OK = "nemoclaw-security-inventory-ok";
export const SANDBOX_BASE_NODE_VERSION = "24.22.1";

Expand Down
12 changes: 9 additions & 3 deletions test/helpers/base-apt-security-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type BaseAptLibexpatPackage = Readonly<{
sha256: Readonly<Record<DebianArchitecture, string>>;
}>;

/** Expat package that the Hermes and Deep Agents Code base images install. */
/** Expat package that the Hermes (OpenShell 0.0.x) and Deep Agents Code base images install. */
export const SHARED_LIBEXPAT_PACKAGE: BaseAptLibexpatPackage = {
debianVersion: "2.8.3-1",
expatVersion: "2.8.3",
Expand All @@ -19,7 +19,7 @@ export const SHARED_LIBEXPAT_PACKAGE: BaseAptLibexpatPackage = {
},
};

/** Expat security update that only the OpenClaw base image installs (#19). */
/** Expat security update that the OpenClaw (#19) and Hermes 0.1.x base images install. */
export const OPENCLAW_LIBEXPAT_PACKAGE: BaseAptLibexpatPackage = {
debianVersion: "2.9.0-1~deb13u1",
expatVersion: "2.9.0",
Expand Down Expand Up @@ -61,12 +61,18 @@ export type BaseAptImagePackages = Readonly<{
zlib1gVersion: string;
}>;

/** Hermes and Deep Agents Code: NemoClaw zlib backport. */
/** Hermes (OpenShell 0.0.x) and Deep Agents Code: NemoClaw zlib backport. */
export const SHARED_BASE_APT_PACKAGES: BaseAptImagePackages = {
libexpat: SHARED_LIBEXPAT_PACKAGE,
zlib1gVersion: "1:1.3.dfsg+really1.3.1-1+b1+nemoclaw1",
};

/** Hermes 0.1.x: Debian expat security update and the NemoClaw zlib backport. */
export const HERMES_01X_BASE_APT_PACKAGES: BaseAptImagePackages = {
libexpat: OPENCLAW_LIBEXPAT_PACKAGE,
zlib1gVersion: SHARED_BASE_APT_PACKAGES.zlib1gVersion,
};

/** OpenClaw: Debian expat, zlib, and apt security updates. */
export const OPENCLAW_BASE_APT_PACKAGES: BaseAptImagePackages = {
libexpat: OPENCLAW_LIBEXPAT_PACKAGE,
Expand Down
26 changes: 25 additions & 1 deletion test/helpers/dockerfile-run-shell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it } from "vitest";
import { dockerRunCommandBetween } from "./dockerfile-run-shell";
import { dockerRunCommandBetween, dockerSubshellBetween } from "./dockerfile-run-shell";

describe("Dockerfile RUN shell extraction", () => {
it("removes Docker instruction options before returning the shell command", () => {
Expand Down Expand Up @@ -32,4 +32,28 @@ describe("Dockerfile RUN shell extraction", () => {
"if true; then printf 'ready\\n'; fi",
);
});

it("returns the commands of a subshell inside a merged RUN instruction", () => {
const dockerfile = [
"RUN true \\",
" # start",
" && ( set -eu; \\",
" printf 'ready\\n'; \\",
" test -n ready ) \\",
" # end",
" && true",
].join("\n");

expect(dockerSubshellBetween(dockerfile, "# start", "# end")).toBe(
"set -eu; printf 'ready\\n'; test -n ready",
);
});

it("rejects a block that is not one subshell", () => {
const dockerfile = ["# start", "RUN printf 'ready\\n'", "# end"].join("\n");

expect(() => dockerSubshellBetween(dockerfile, "# start", "# end")).toThrow(
"Expected one && ( ... ) subshell after # start",
);
});
});
28 changes: 28 additions & 0 deletions test/helpers/dockerfile-run-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ export function dockerRunCommandBetween(
.replace(/^(?:--[a-z-]+=[^\s]+\s+)+/u, "");
}

/**
* Return the commands of a `&& ( ... )` subshell that a merged RUN instruction
* holds between two comment markers.
*/
export function dockerSubshellBetween(
dockerfile: string,
startMarker: string,
endMarker: string,
): string {
const start = dockerfile.indexOf(startMarker);
const end = dockerfile.indexOf(endMarker, start);
if (start === -1 || end === -1 || end <= start) {
throw new Error(`Expected Dockerfile block between ${startMarker} and ${endMarker}`);
}
const block = dockerfile
.slice(start, end)
.split("\n")
.filter((line) => !line.trimStart().startsWith("#"))
.join("\n")
.trim()
.replace(/\\\n\s*/g, " ");
const match = block.match(/^&& \( ([\s\S]*) \) \\$/u);
if (!match) {
throw new Error(`Expected one && ( ... ) subshell after ${startMarker}`);
}
return match[1];
}

export function shellCommandSegmentBetween(
command: string,
startMarker: string,
Expand Down
Loading
Loading