Skip to content

Commit

Permalink
Disable zchunk and deltarpm during template build
Browse files Browse the repository at this point in the history
This disables zchunk as well as deltarpm, reducing DNF's attack surface.
A change to core-agent-linux will do the same for the built templates
once they are installed.
  • Loading branch information
DemiMarie committed Oct 23, 2024
1 parent 099d6c1 commit a0cea5a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions dnf/bootstrap-dnf-centos-stream.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ repo_gpgcheck=1
plugins=1
installonly_limit=3
color=never
deltarpm=False
zchunk=False

reposdir=/var/empty

Expand Down
2 changes: 2 additions & 0 deletions dnf/bootstrap-dnf-fedora.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ gpgcheck=1
plugins=1
installonly_limit=3
color=never
deltarpm=False
zchunk=False

reposdir=/var/empty

Expand Down
6 changes: 3 additions & 3 deletions scripts/prepare-chroot-base
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ else
fi

DNF=dnf
DNF_OPTS+=(--releasever "$DIST_VER" --installroot="${INSTALL_DIR}" "--downloaddir=$DOWNLOAD_DIR" --downloadonly)
# Delta RPMs and zchunk are unnecessary attack surface
DNF_SEC_OPTS=(--setopt=deltarpm=False --setopt=deltarpm_percentage=0 --setopt=zchunk=0)
DNF_OPTS+=(--releasever "$DIST_VER" --installroot="${INSTALL_DIR}" "--downloaddir=$DOWNLOAD_DIR" --downloadonly "${DNF_SEC_OPTS[@]}")

# Ensure INSTALL_DIR exists
mkdir -p "$INSTALL_DIR"
Expand All @@ -61,8 +63,6 @@ if ! [ -f "${INSTALL_DIR}/tmp/.prepared_base" ]; then
echo "INFO: Initializing RPM database..."
# We want signature checks.
RPM_OPTS=('--define=_pkgverify_level all' '--define=_pkgverify_flags 0x0')
# Delta RPMs and zchunk are unnecessary attack surface
DNF_OPTS+=(--setopt=deltarpm=False --setopt=deltarpm_percentage=0 --setopt=zchunk=0)
if [ "$(getenforce || :)" = Enforcing ]; then
dbpath=$(rpm --eval '%{_dbpath}')
mkdir -p "${INSTALL_DIR}${dbpath}"
Expand Down
6 changes: 5 additions & 1 deletion template_rpm/distribution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ if [ -z "${DIST_VER}" ]; then
error "Please provide DIST_VER in environment."
fi

DNF_OPTS=(-y --releasever "${DIST_VER}")
DNF_OPTS=(-y
"--releasever=${DIST_VER}"
--setopt=deltarpm=False
--setopt=zchunk=False
--setopt=gpgcheck=1)

if [ -n "${REPO_PROXY}" ]; then
DNF_OPTS+=("--setopt=proxy=${REPO_PROXY}")
Expand Down

0 comments on commit a0cea5a

Please sign in to comment.