@@ -1561,11 +1561,19 @@ export function sanitizeContainedRootlessSpec({
15611561 }
15621562 // The repository may live on a filesystem that cannot persist POSIX mode
15631563 // changes. Map the fixed non-root container identity to the already-rootless
1564- // runtime owner so read-only bind inputs remain readable without granting an
1565- // inner UID 0 mapping or widening their host permissions.
1564+ // runtime owner so read-only bind inputs remain readable without widening
1565+ // their host permissions. Runc also requires container ID 0 to be mapped to
1566+ // initialize the namespace; keep that ID isolated on the outer subordinate
1567+ // identity while the executed process remains the fixed non-root image user.
15661568 linux . namespaces . push ( { type : "user" } ) ;
1567- linux . uidMappings = [ { containerID : runtimeUser . uid , hostID : 0 , size : 1 } ] ;
1568- linux . gidMappings = [ { containerID : runtimeUser . gid , hostID : 0 , size : 1 } ] ;
1569+ linux . uidMappings = [
1570+ { containerID : 0 , hostID : 1 , size : 1 } ,
1571+ { containerID : runtimeUser . uid , hostID : 0 , size : 1 } ,
1572+ ] ;
1573+ linux . gidMappings = [
1574+ { containerID : 0 , hostID : 1 , size : 1 } ,
1575+ { containerID : runtimeUser . gid , hostID : 0 , size : 1 } ,
1576+ ] ;
15691577 // RootlessKit delegates the cgroup namespace root. Use an absolute leaf so
15701578 // runc and the independent observer resolve the same cgroup regardless of
15711579 // whether the runtime coordinator itself was evacuated to /containerd.
0 commit comments