Skip to content

Commit 51d068a

Browse files
osguard-ci: Add Code Integrity variant of OS Guard (microsoft#14505)
Add new image configuration definition for OS Guard that enables code integrity enhancements. To enable code integrity checking for containers, this image activates the containerd erofs-snapshotter with an updated /etc/containerd/config.toml configuration, and also configures cni appropriately for pod networking. Additionally this image enables SELinux in enforcing mode for another important security layer. Finally, update the OS Guard generation script to handle generating OS Guard image configurations using different delta files, and simplify the process of adding new delta configurations by creating the GEN_JOBS array, where each entry follows the schema: <base-template>|<delta-template>|<output> Also update the test function to check all entries of GEN_JOBS for diffs. Signed-off-by: Chris Co <[email protected]>
1 parent b9f003c commit 51d068a

File tree

4 files changed

+423
-32
lines changed

4 files changed

+423
-32
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version = 2
2+
# Explicitly defining no adjustment to Linux OOM Killer
3+
oom_score = 0
4+
[plugins."io.containerd.grpc.v1.cri"]
5+
# Enable SELinux labeling support for pods and containers
6+
enable_selinux = true
7+
# Use same infra container image as AKS does for pod sandboxes
8+
sandbox_image = "mcr.microsoft.com/oss/kubernetes/pause:3.6"
9+
[plugins."io.containerd.grpc.v1.cri".containerd]
10+
# Set default snapshotter to erofs-snapshotter
11+
snapshotter = "erofs"
12+
# Allow snapshot annotations
13+
disable_snapshot_annotations = false
14+
# Explicitly define using runc for runtime
15+
default_runtime_name = "runc"
16+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
17+
# Set default snapshotter to erofs for this runtime
18+
snapshotter = "erofs"
19+
# Explicitly define using runc v2 shim
20+
runtime_type = "io.containerd.runc.v2"
21+
# Section is configured by AKS but not strictly required in general
22+
# [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
23+
# BinaryName = "/usr/bin/runc"
24+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.untrusted]
25+
# Explicitly define using runc v2 shim for runtime named "untrusted"
26+
runtime_type = "io.containerd.runc.v2"
27+
# Section is configured in AKS but not strictly required in general
28+
# [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.untrusted.options]
29+
# BinaryName = "/usr/bin/runc"
30+
# Section is configured in AKS but not strictly required in general
31+
# [plugins."io.containerd.grpc.v1.cri".registry]
32+
# config_path = "/etc/containerd/certs.d"
33+
# Section is configured in AKS but not strictly required in general
34+
# [plugins."io.containerd.grpc.v1.cri".registry.headers]
35+
# X-Meta-Source-Client = ["azure/aks"]
36+
[plugins."io.containerd.grpc.v1.cri".cni]
37+
# Set default locations for cni binary and config files
38+
bin_dir = "/usr/libexec/cni"
39+
conf_dir = "/etc/cni/net.d"
40+
conf_template = ""
41+
# Section is configured in AKS but not strictly required in general
42+
# [metrics]
43+
# address = "0.0.0.0:10257"
44+
45+
[plugins."io.containerd.snapshotter.v1.erofs"]
46+
# Optional: Additional mount options for overlayfs
47+
ovl_mount_options = []
48+
# Enable dm-verity integrity verification in erofs layers
49+
enable_dmverity = true
50+
51+
[plugins."io.containerd.service.v1.diff-service"]
52+
default = ["erofs"]
53+
54+
[plugins."io.containerd.differ.v1.erofs"]
55+
# Using well-known UUID for reproducibility of erofs container layers
56+
mkfs_options = ["--sort=none", "-T 0", "--mkfs-time", "-Uc1b9d5a2-f162-11cf-9ece-0020afc76f16"]
57+
# Enable use of tar index to more efficiently handle OCI image layers
58+
enable_tar_index = true
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# This file was automatically generated by merge_yaml.py
2+
# Sources: base=templates/osguard-base.yaml delta=templates/osguard-ci-delta.yaml
3+
4+
storage:
5+
bootType: efi
6+
disks:
7+
- partitionTableType: gpt
8+
maxSize: 40G
9+
partitions:
10+
- id: esp
11+
type: esp
12+
label: esp
13+
size: 512M
14+
- id: boot-a
15+
type: linux-generic
16+
label: boot-a
17+
size: 100M
18+
- id: usr-a
19+
type: linux-generic
20+
size: 1G
21+
- id: usr-hash-a
22+
type: usr-verity
23+
size: 128M
24+
- id: root-a
25+
type: root
26+
label: root-a
27+
size: 12G
28+
verity:
29+
- id: usrverity
30+
name: usr
31+
dataDeviceId: usr-a
32+
hashDeviceId: usr-hash-a
33+
dataDeviceMountIdType: uuid
34+
hashDeviceMountIdType: uuid
35+
hashSignaturePath: /boot/usr.hash.sig
36+
filesystems:
37+
- deviceId: esp
38+
type: fat32
39+
mountPoint:
40+
idType: part-label
41+
path: /boot/efi
42+
options: nodev,noexec,umask=0077
43+
- deviceId: boot-a
44+
type: ext4
45+
mountPoint:
46+
idType: uuid
47+
path: /boot
48+
options: nodev,noexec,nosuid
49+
- deviceId: usrverity
50+
type: ext4
51+
mountPoint:
52+
path: /usr
53+
options: nodev,ro
54+
- deviceId: root-a
55+
type: ext4
56+
mountPoint:
57+
path: /
58+
options: nodev,nosuid,x-systemd.growfs,x-initrd.mount
59+
os:
60+
bootloader:
61+
resetType: hard-reset
62+
hostname: azure-linux-os-guard
63+
selinux:
64+
mode: enforcing
65+
uki:
66+
kernels: auto
67+
kernelCommandLine:
68+
extraCommandLine:
69+
- console=tty0
70+
- console=tty1
71+
- console=ttyS0
72+
- rd.luks=0
73+
- rd.hostonly=0
74+
- fips=1
75+
- net.ifnames=1
76+
- dm_verity.require_signatures=1
77+
packages:
78+
remove:
79+
- dracut-hostonly
80+
- grub2-efi-binary
81+
- kernel
82+
install:
83+
- syslog
84+
- WALinuxAgent
85+
- device-mapper
86+
- kernel-ipe
87+
- cni
88+
- containerd2
89+
- cri-tools
90+
- systemd-boot
91+
- dracut-hyperv
92+
- hyperv-daemons
93+
- cloud-init
94+
- checkpolicy
95+
- libselinux
96+
- policycoreutils-python-utils
97+
- secilc
98+
- selinux-policy
99+
- selinux-policy-ci
100+
- selinux-policy-modules
101+
- setools-console
102+
- systemd-ukify
103+
- systemd-boot
104+
- efibootmgr
105+
- lvm2
106+
- veritysetup
107+
- selinux-policy
108+
- selinux-policy-modules
109+
- gptfdisk
110+
- curl
111+
- bind-utils
112+
- tar
113+
- wget
114+
- blobfuse2
115+
- ca-certificates
116+
- chrony
117+
- cifs-utils
118+
- cloud-init-azure-kvp
119+
- conntrack-tools
120+
- cracklib
121+
- ebtables
122+
- ethtool
123+
- fuse
124+
- inotify-tools
125+
- iotop
126+
- iproute
127+
- ipset
128+
- iptables
129+
- iscsi-initiator-utils
130+
- jq
131+
- logrotate
132+
- lsof
133+
- netplan
134+
- nftables
135+
- nmap-ncat
136+
- nfs-utils
137+
- oras
138+
- pam
139+
- psmisc
140+
- rsyslog
141+
- socat
142+
- sysstat
143+
- traceroute
144+
- util-linux
145+
- xz
146+
- zip
147+
- erofs-utils
148+
additionalDirs:
149+
- source: files/osguard/repart.d
150+
destination: /etc/repart.d
151+
childFilePermissions: 644
152+
additionalFiles:
153+
- source: files/osguard/selinux-ci-uki.semanage
154+
destination: /etc/selinux/targeted/selinux-ci.semanage
155+
- source: files/osguard/cloud.cfg
156+
destination: /etc/cloud/cloud.cfg
157+
permissions: '644'
158+
- source: files/osguard/10-repart.conf
159+
destination: /etc/dracut.conf.d/10-repart.conf
160+
permissions: '644'
161+
- source: files/osguard/chrony.conf
162+
destination: /etc/chrony.conf
163+
permissions: '644'
164+
- source: files/osguard/resolv-uplink-override.service
165+
destination: /etc/systemd/system/resolv-uplink-override.service
166+
permissions: '600'
167+
- source: files/osguard-ci/config.toml
168+
destination: /etc/containerd/config.toml
169+
permissions: '644'
170+
services:
171+
disable:
172+
- sshd
173+
enable:
174+
- systemd-networkd
175+
- systemd-resolved
176+
modules:
177+
- name: iptable_nat
178+
loadMode: always
179+
- name: erofs
180+
loadMode: always
181+
scripts:
182+
postCustomization:
183+
- path: scripts/common/performance-tuning.sh
184+
- path: scripts/common/azlinuxagentconfig.sh
185+
- path: scripts/common/selinux-ci-config.py
186+
interpreter: /usr/bin/python3
187+
- path: scripts/common/cleanup-machineid.sh
188+
- path: scripts/common/prepare_trusted_cni_plugins.sh
189+
- path: scripts/common/move-iptables-scripts-to-usr.sh
190+
- path: scripts/common/tmp-no-exec.sh
191+
- path: scripts/common/remove-getty-import-credential.sh
192+
- path: scripts/osguard/create-empty-certs-dir.sh
193+
- path: scripts/set_os_release_variant_entries.sh
194+
arguments:
195+
- --variant-id
196+
- osguard-ci
197+
- --variant
198+
- OS Guard Code Integrity Image
199+
output:
200+
artifacts:
201+
items:
202+
- verity-hash
203+
- ukis
204+
path: ./output
205+
image:
206+
format: vhdx
207+
previewFeatures:
208+
- output-artifacts
209+
- uki
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# The OS Guard Code Integrity image variant extends code integrity features
2+
# beyond the host binaries, to include container images and their layers. This
3+
# is achieved through configuring containerd to use erofs-snapshotter with
4+
# dm-verity support and requiring dm-verity signature verification. On container
5+
# execution, IPE will only allow the execution of containers that are dm-verity
6+
# verified.
7+
#
8+
# This file defines the delta (differences) to apply to the osguard-base.yaml
9+
# template in order to generate the OS Guard Code Integrity (CI) image variant.
10+
# This template is merged with the base template by the
11+
# generate-osguard-imageconfigs.sh script to produce osguard-ci-amd64.yaml
12+
# Only settings that differ from the base should be included here.
13+
os:
14+
# Ensure SELinux is in Enforcing Mode for OS Guard Code Integrity image.
15+
selinux:
16+
mode: enforcing
17+
kernelCommandLine:
18+
extraCommandLine:
19+
# Enforce signatures for all dm-verity volumes on the system. This
20+
# verification is needed in conjunction with our dm-verity-enabled
21+
# erofs-snapshotter to ensure erofs container layers, which are
22+
# dm-verity volumes, are signed by a trusted entity
23+
- dm_verity.require_signatures=1
24+
packages:
25+
install:
26+
# For containerd erofs-snapshotter to function, supply its userland
27+
# utilities
28+
- erofs-utils
29+
modules:
30+
# Ensure the erofs kernel module is always loaded so containerd
31+
# erofs-snapshotter can use it.
32+
- name: erofs
33+
loadMode: always
34+
additionalFiles:
35+
# Place custom containerd config that configures erofs-snapshotter as the
36+
# default snapshotter when setting up container images
37+
- source: files/osguard-ci/config.toml
38+
destination: /etc/containerd/config.toml
39+
permissions: "644"
40+
scripts:
41+
postCustomization:
42+
# Tag this image variant with its specific variant-id
43+
- path: scripts/set_os_release_variant_entries.sh
44+
arguments:
45+
- --variant-id
46+
- osguard-ci
47+
- --variant
48+
- OS Guard Code Integrity Image

0 commit comments

Comments
 (0)