Skip to content

Commit 7acb2de

Browse files
committed
fix(distribution): permit fixed secret read during init
Plan: .omo/plans/baota-ai-ops-control-plane.md
1 parent a1d31ec commit 7acb2de

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

apps/daemon/src/runtime/__test__/docker-runtime-security.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ describe("Docker runtime security", () => {
114114
});
115115
const callerPathInvoked = existsSync(tracePath);
116116
await rm(fixtureDirectory, { recursive: true });
117-
const capAddBlock = /^\s{4}cap_add:\n((?:\s{6}-\s+"[A-Z]+"\n)+)/mu.exec(
117+
const capAddBlock = /^\s{4}cap_add:\n((?:\s{6}-\s+"[A-Z_]+"\n)+)/mu.exec(
118118
compose,
119119
);
120-
const startupCapabilities = capAddBlock?.[1]?.match(/[A-Z]+/gu) ?? [];
120+
const startupCapabilities = capAddBlock?.[1]?.match(/[A-Z_]+/gu) ?? [];
121121
const dockerMarkers = [
122122
"COPY scripts/container-entrypoint.sh /usr/local/bin/container-entrypoint.sh",
123123
"chmod 0755 /usr/local/bin/container-entrypoint.sh",
@@ -148,9 +148,15 @@ describe("Docker runtime security", () => {
148148
[...bootstrapMarkers].sort((left, right) => left - right),
149149
);
150150

151-
// Linux clears permitted/effective capabilities on uid 0 -> 1000;
151+
// DAC_OVERRIDE is consumed only to read Docker's root-owned file secret.
152+
// Linux then clears permitted/effective capabilities on uid 0 -> 1000;
152153
// no-new-privileges and the absence of file capabilities prevent reacquisition.
153-
expect(startupCapabilities).toEqual(["CHOWN", "SETUID", "SETGID"]);
154+
expect(startupCapabilities).toEqual([
155+
"CHOWN",
156+
"SETUID",
157+
"SETGID",
158+
"DAC_OVERRIDE",
159+
]);
154160
expect(compose).toMatch(/^\s{4}cap_drop:\n\s{6}- "ALL"$/mu);
155161
expect(compose).toMatch(
156162
/^\s{4}security_opt:\n\s{6}- "no-new-privileges:true"$/mu,

compose.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ services:
66
read_only: true
77
cap_drop:
88
- "ALL"
9-
# The fixed entrypoint consumes these only for its data-mount chown and
10-
# uid/gid transition before exec; the daemon starts with no capabilities.
9+
# The fixed entrypoint consumes DAC_OVERRIDE only to read Docker's
10+
# root-owned file secret, CHOWN for the fixed data mount, and SETUID/SETGID
11+
# for its uid/gid transition; the daemon starts with no capabilities.
1112
cap_add:
1213
- "CHOWN"
1314
- "SETUID"
1415
- "SETGID"
16+
- "DAC_OVERRIDE"
1517
security_opt:
1618
- "no-new-privileges:true"
1719
pids_limit: 256

0 commit comments

Comments
 (0)