** Description changed:

+ 
  [ Impact ]
  
  On Ubuntu 26.04, apt 3.2.0 uses OpenSSL both for TLS (methods/http) and for
  hashing (libapt-pkg). When OpenSSL is configured for FIPS-only operation
  (FIPS provider + `default_properties = fips=yes`), every HTTPS download fails:
  
-   W: Failed to fetch 
https://ports.ubuntu.com/ubuntu-ports/dists/resolute/InRelease
-      OpenSSL error: error:0308010C:digital envelope routines::unsupported
-      Error reading from server - read (5: Input/output error) [IP: ... 443]
+   W: Failed to fetch 
https://ports.ubuntu.com/ubuntu-ports/dists/resolute/InRelease
+      OpenSSL error: error:0308010C:digital envelope routines::unsupported
+      Error reading from server - read (5: Input/output error) [IP: ... 443]
  
  TLS itself works (openssl s_client and curl succeed with the same config).
  The failure sequence:
  
-  1. After the response headers arrive, Hashes::Hashes() initializes all
-     supported digests, including MD5.
-  2. EVP_MD_fetch("MD5") fails under fips=yes and leaves 0x0308010C on the
-     thread's OpenSSL error queue. apt tolerates the missing digest but never
-     clears the error.
-  3. The next non-blocking SSL_read() returns -1 (normally 
SSL_ERROR_WANT_READ),
-     but SSL_get_error() finds the stale error on the queue and returns
-     SSL_ERROR_SSL. apt treats the transfer as failed.
+  1. After the response headers arrive, Hashes::Hashes() initializes all
+     supported digests, including MD5.
+  2. EVP_MD_fetch("MD5") fails under fips=yes and leaves 0x0308010C on the
+     thread's OpenSSL error queue. apt tolerates the missing digest but never
+     clears the error.
+  3. The next non-blocking SSL_read() returns -1 (normally 
SSL_ERROR_WANT_READ),
+     but SSL_get_error() finds the stale error on the queue and returns
+     SSL_ERROR_SSL. apt treats the transfer as failed.
  
  Plain http:// sources are unaffected because no SSL_get_error() call
  inspects the queue. As a result, apt cannot use HTTPS sources at all on
  FIPS-configured 26.04 systems, including the Ubuntu archive over HTTPS and
  third-party HTTPS-only repositories.
  
  This is fixed upstream in apt 3.3.2 (Debian #1140227) by:
  
-  - dfeecf7f "hashes: Fix lingering OpenSSL error"
-    (ERR_set_mark()/ERR_pop_to_mark() around PrivateHashes::Enable())
-  - d714c12f "hashes: don't crash on an unavailable digest"
-    (guards HexDigest()/GetHashString() against a digest whose init failed;
-    avoids a crash or garbage digest when MD5 is requested explicitly,
-    e.g. apt-cdrom ident)
+  - dfeecf7f "hashes: Fix lingering OpenSSL error"
+    (ERR_set_mark()/ERR_pop_to_mark() around PrivateHashes::Enable())
+  - d714c12f "hashes: don't crash on an unavailable digest"
+    (guards HexDigest()/GetHashString() against a digest whose init failed;
+    avoids a crash or garbage digest when MD5 is requested explicitly,
+    e.g. apt-cdrom ident)
  
  Both cherry-pick cleanly onto 3.2.0
  
- [ How to reproduce ]
+ [ Test Plan ]
  
- Build an (unvalidated) OpenSSL FIPS provider from the pristine openssl source
- in the archive and run apt with it in FIPS-only mode:
+ The steps build an unvalidated OpenSSL FIPS provider from the openssl
+ source in the archive and run apt in FIPS-only mode, where MD5 is
+ unavailable. All commands run as root in a fresh resolute container, for
+ example one made with "lxc launch ubuntu:26.04 apt-fips".
  
-   # in a clean resolute container/VM, as root
-   sed -i 's/^Types: deb$/Types: deb deb-src/' 
/etc/apt/sources.list.d/ubuntu.sources
-   apt-get update && apt-get install -y openssl ca-certificates dpkg-dev 
build-essential perl
-   cd /tmp && apt-get source --download-only openssl
-   dpkg-source -x --skip-patches openssl_*.dsc src && cd src
-   ./Configure enable-fips no-docs && make -j"$(nproc)" build_generated && 
make -j"$(nproc)" providers/fips.so
-   MOD=$(openssl version -m | sed -E 's/.*"(.*)"/\1/'); cp providers/fips.so 
"$MOD"/
-   openssl fipsinstall -module "$MOD"/fips.so -out /etc/ssl/fipsmodule.cnf
-   cat > /etc/ssl/fips.cnf <<'EOF'
-   openssl_conf = openssl_init
-   .include /etc/ssl/fipsmodule.cnf
-   [openssl_init]
-   providers = provider_sect
-   alg_section = algorithm_sect
-   [provider_sect]
-   fips = fips_sect
-   base = base_sect
-   [base_sect]
-   activate = 1
-   [algorithm_sect]
-   default_properties = fips=yes
-   EOF
-   sed -i 's#http://#https://#' /etc/apt/sources.list.d/ubuntu.sources
+ * Reproduce the bug:
  
-   # Lists must be empty: with cached lists the server answers 304, no body
-   # is hashed, and the bug does not trigger.
-   rm -rf /var/lib/apt/lists/*
-   OPENSSL_CONF=/etc/ssl/fips.cnf apt-get update
+ 1. Install the tools and the apt version in resolute-updates,
+ 3.2.1ubuntu0.1 at the time of writing:
  
- Expected with 3.2.0: "W: Failed to fetch https://... OpenSSL error:
- error:0308010C ... Error reading from server" for every InRelease.
- Expected with the fixed package: all indexes fetched, no warnings.
+     sed -i 's/^Types: deb$/Types: deb deb-src/' 
/etc/apt/sources.list.d/ubuntu.sources
+     apt update
+     apt install -y apt apt-utils openssl ca-certificates dpkg-dev 
build-essential perl hello
  
- Regression check: run `apt-get update` and `apt-get install <pkg>` over both
- http:// and https:// without OPENSSL_CONF set (non-FIPS default), and confirm
- the behavior is unchanged.
+ 2. Build the FIPS provider and write a FIPS-only OpenSSL config:
+ 
+     mkdir /root/openssl && cd /root/openssl
+     apt source --download-only openssl
+     dpkg-source -x --skip-patches openssl_*.dsc src && cd src
+     ./Configure enable-fips no-docs && make -j"$(nproc)" build_generated && 
make -j"$(nproc)" providers/fips.so
+     MOD=$(openssl version -m | sed -E 's/.*"(.*)"/\1/'); cp providers/fips.so 
"$MOD"/
+     openssl fipsinstall -module "$MOD"/fips.so -out /etc/ssl/fipsmodule.cnf
+     printf '%s\n' 'openssl_conf = openssl_init' '.include 
/etc/ssl/fipsmodule.cnf' '[openssl_init]' 'providers = provider_sect' 
'alg_section = algorithm_sect' '[provider_sect]' 'fips = fips_sect' 'base = 
base_sect' '[base_sect]' 'activate = 1' '[algorithm_sect]' 'default_properties 
= fips=yes' > /etc/ssl/fips.cnf
+ 
+ 3. Switch the sources to https, empty the lists and update in FIPS-only
+ mode. The lists must be empty, because an index that has not changed is
+ not downloaded and so not hashed:
+ 
+     sed -i 's#http://#https://#' /etc/apt/sources.list.d/ubuntu.sources
+     rm -rf /var/lib/apt/lists/*
+     OPENSSL_CONF=/etc/ssl/fips.cnf apt update
+ 
+ Assert that the InRelease files fail to download, after several "Ign:"
+ retries, with "OpenSSL error: error:0308010C:digital envelope
+ routines::unsupported Error reading from server - read (5: Input/output
+ error)".
+ 
+ 4. Fetch the lists again without the FIPS config, put a package into a
+ directory and generate its Packages entry in FIPS-only mode:
+ 
+     apt update
+     mkdir -p /tmp/repo/pool; cd /tmp; apt download hello; mv hello_*.deb 
/tmp/repo/pool/; cd /tmp/repo
+     OPENSSL_CONF=/etc/ssl/fips.cnf apt-ftparchive -o 
APT::FTPArchive::LongDescription=false packages pool | grep ^Description-md5
+ 
+ Assert a Description-md5 line whose value changes each time the last
+ command is run. apt could not compute MD5 and printed uninitialised
+ memory.
+ 
+ * Test the fix:
+ 
+ 1. Install apt from resolute-proposed:
+ 
+     printf '%s\n' 'Types: deb' 'URIs: http://archive.ubuntu.com/ubuntu' 
'Suites: resolute-proposed' 'Components: main universe' 'Signed-By: 
/usr/share/keyrings/ubuntu-archive-keyring.gpg' > 
/etc/apt/sources.list.d/proposed.sources
+     apt update
+     apt install -y -t resolute-proposed apt libapt-pkg7.0 apt-utils
+ 
+ 2. Repeat step 3 of "Reproduce the bug". Assert that all index files are
+ fetched, with no "Ign:" or "Err:" lines and no OpenSSL error.
+ 
+ 3. Generate the Packages entry again in FIPS-only mode:
+ 
+     cd /tmp/repo
+     OPENSSL_CONF=/etc/ssl/fips.cnf apt-ftparchive -o 
APT::FTPArchive::LongDescription=false packages pool | grep ^Description-md5
+ 
+ Assert that it prints nothing: no Description-md5 line is written.
+ 
+ 4. Check that normal use still works without the FIPS config, over https
+ and then over http:
+ 
+     rm -rf /var/lib/apt/lists/*; apt update && apt install -y --reinstall 
hello
+     sed -i 's#https://#http://#' /etc/apt/sources.list.d/ubuntu.sources
+     rm -rf /var/lib/apt/lists/*; apt update && apt install -y --reinstall 
hello
+ 
+ Assert that both updates and both installs finish with no error.
+ 
+ Verified on 2026-11-05 in a fresh LXD resolute container: apt 3.2.1ubuntu0.1 
shows every result under "Reproduce the bug", and a build of the merge request 
against 3.2.y shows every result under "Test the fix":
+ https://salsa.debian.org/apt-team/apt/-/merge_requests/647
+ 
+ [ Where problems could occur ]
+ 
+ The fixes change the hashing code in libapt-pkg, which every download
+ and verification goes through. With OpenSSL's default provider every
+ digest is available, so neither fix should change anything there. A
+ regression would show as "Hash Sum mismatch" or a missing hash during
+ apt update or apt install, or as hash fields missing from apt-ftparchive
+ output, on a system with nothing unusual configured.
+ 
+ The first fix discards the errors OpenSSL records while apt sets up a
+ digest. The reason a digest is unavailable is therefore no longer on
+ OpenSSL's error stack, which could make such a setup harder to diagnose.
+ 
+ The second fix returns an empty digest where apt used to crash or print
+ garbage for an unavailable digest. Code that asks for one specific
+ digest now gets an empty result. On a FIPS-only system apt-ftparchive no
+ longer writes a Description-md5 field, and apt-cdrom, which identifies
+ discs by MD5, is affected in the same way. Scripts that expect that
+ field will notice.
+ 
+ No public header or library ABI changes. Other programs that use libapt-
+ pkg, such as python-apt, aptitude and PackageKit, get the same changes
+ in behaviour.
  
  [ Other Info ]
  
-  - Upstream: apt 3.3.2 (released 2026-07-30), commits dfeecf7f and d714c12f.
-  - Debian: #1140227 (found in 3.0.3, fixed in 3.3.2).
-  - The development series already has apt 3.3.3, which includes the fix.
-  - The upstream 3.2.y branch has no commits since 3.2.0, so this would be an
-    Ubuntu-specific cherry-pick unless upstream cuts 3.2.1.
+  - Upstream: apt 3.3.2 (released 2026-07-30), commits dfeecf7f and d714c12f.
+  - Debian: #1140227 (found in 3.0.3, fixed in 3.3.2).
+  - The development series already has apt 3.3.3, which includes the fix.
+  - The upstream 3.2.y branch has no commits since 3.2.0, so this would be an
+    Ubuntu-specific cherry-pick unless upstream cuts 3.2.1.

** Description changed:

+ [ Note, 2026-11-05 ]
+ 
+ Since this description was first written, apt 3.2.1 was released to resolute 
through the security pocket, as 3.2.1ubuntu0.1. The fixes are now cherry-picked 
from upstream main onto the 3.2.y branch on top of 3.2.1, to ship in the 3.2.2 
point release:
+ https://salsa.debian.org/apt-team/apt/-/merge_requests/647
+ The Test Plan and "Where problems could occur" sections were written and 
verified against 3.2.1ubuntu0.1. The Impact and Other Info sections are from 
the original report and still refer to 3.2.0.
  
  [ Impact ]
  
  On Ubuntu 26.04, apt 3.2.0 uses OpenSSL both for TLS (methods/http) and for
  hashing (libapt-pkg). When OpenSSL is configured for FIPS-only operation
  (FIPS provider + `default_properties = fips=yes`), every HTTPS download fails:
  
    W: Failed to fetch 
https://ports.ubuntu.com/ubuntu-ports/dists/resolute/InRelease
       OpenSSL error: error:0308010C:digital envelope routines::unsupported
       Error reading from server - read (5: Input/output error) [IP: ... 443]
  
  TLS itself works (openssl s_client and curl succeed with the same config).
  The failure sequence:
  
   1. After the response headers arrive, Hashes::Hashes() initializes all
      supported digests, including MD5.
   2. EVP_MD_fetch("MD5") fails under fips=yes and leaves 0x0308010C on the
      thread's OpenSSL error queue. apt tolerates the missing digest but never
      clears the error.
   3. The next non-blocking SSL_read() returns -1 (normally 
SSL_ERROR_WANT_READ),
      but SSL_get_error() finds the stale error on the queue and returns
      SSL_ERROR_SSL. apt treats the transfer as failed.
  
  Plain http:// sources are unaffected because no SSL_get_error() call
  inspects the queue. As a result, apt cannot use HTTPS sources at all on
  FIPS-configured 26.04 systems, including the Ubuntu archive over HTTPS and
  third-party HTTPS-only repositories.
  
  This is fixed upstream in apt 3.3.2 (Debian #1140227) by:
  
   - dfeecf7f "hashes: Fix lingering OpenSSL error"
     (ERR_set_mark()/ERR_pop_to_mark() around PrivateHashes::Enable())
   - d714c12f "hashes: don't crash on an unavailable digest"
     (guards HexDigest()/GetHashString() against a digest whose init failed;
     avoids a crash or garbage digest when MD5 is requested explicitly,
     e.g. apt-cdrom ident)
  
  Both cherry-pick cleanly onto 3.2.0
  
  [ Test Plan ]
  
  The steps build an unvalidated OpenSSL FIPS provider from the openssl
  source in the archive and run apt in FIPS-only mode, where MD5 is
  unavailable. All commands run as root in a fresh resolute container, for
  example one made with "lxc launch ubuntu:26.04 apt-fips".
  
  * Reproduce the bug:
  
  1. Install the tools and the apt version in resolute-updates,
  3.2.1ubuntu0.1 at the time of writing:
  
-     sed -i 's/^Types: deb$/Types: deb deb-src/' 
/etc/apt/sources.list.d/ubuntu.sources
-     apt update
-     apt install -y apt apt-utils openssl ca-certificates dpkg-dev 
build-essential perl hello
+     sed -i 's/^Types: deb$/Types: deb deb-src/' 
/etc/apt/sources.list.d/ubuntu.sources
+     apt update
+     apt install -y apt apt-utils openssl ca-certificates dpkg-dev 
build-essential perl hello
  
  2. Build the FIPS provider and write a FIPS-only OpenSSL config:
  
-     mkdir /root/openssl && cd /root/openssl
-     apt source --download-only openssl
-     dpkg-source -x --skip-patches openssl_*.dsc src && cd src
-     ./Configure enable-fips no-docs && make -j"$(nproc)" build_generated && 
make -j"$(nproc)" providers/fips.so
-     MOD=$(openssl version -m | sed -E 's/.*"(.*)"/\1/'); cp providers/fips.so 
"$MOD"/
-     openssl fipsinstall -module "$MOD"/fips.so -out /etc/ssl/fipsmodule.cnf
-     printf '%s\n' 'openssl_conf = openssl_init' '.include 
/etc/ssl/fipsmodule.cnf' '[openssl_init]' 'providers = provider_sect' 
'alg_section = algorithm_sect' '[provider_sect]' 'fips = fips_sect' 'base = 
base_sect' '[base_sect]' 'activate = 1' '[algorithm_sect]' 'default_properties 
= fips=yes' > /etc/ssl/fips.cnf
+     mkdir /root/openssl && cd /root/openssl
+     apt source --download-only openssl
+     dpkg-source -x --skip-patches openssl_*.dsc src && cd src
+     ./Configure enable-fips no-docs && make -j"$(nproc)" build_generated && 
make -j"$(nproc)" providers/fips.so
+     MOD=$(openssl version -m | sed -E 's/.*"(.*)"/\1/'); cp providers/fips.so 
"$MOD"/
+     openssl fipsinstall -module "$MOD"/fips.so -out /etc/ssl/fipsmodule.cnf
+     printf '%s\n' 'openssl_conf = openssl_init' '.include 
/etc/ssl/fipsmodule.cnf' '[openssl_init]' 'providers = provider_sect' 
'alg_section = algorithm_sect' '[provider_sect]' 'fips = fips_sect' 'base = 
base_sect' '[base_sect]' 'activate = 1' '[algorithm_sect]' 'default_properties 
= fips=yes' > /etc/ssl/fips.cnf
  
  3. Switch the sources to https, empty the lists and update in FIPS-only
  mode. The lists must be empty, because an index that has not changed is
  not downloaded and so not hashed:
  
-     sed -i 's#http://#https://#' /etc/apt/sources.list.d/ubuntu.sources
-     rm -rf /var/lib/apt/lists/*
-     OPENSSL_CONF=/etc/ssl/fips.cnf apt update
+     sed -i 's#http://#https://#' /etc/apt/sources.list.d/ubuntu.sources
+     rm -rf /var/lib/apt/lists/*
+     OPENSSL_CONF=/etc/ssl/fips.cnf apt update
  
  Assert that the InRelease files fail to download, after several "Ign:"
  retries, with "OpenSSL error: error:0308010C:digital envelope
  routines::unsupported Error reading from server - read (5: Input/output
  error)".
  
  4. Fetch the lists again without the FIPS config, put a package into a
  directory and generate its Packages entry in FIPS-only mode:
  
-     apt update
-     mkdir -p /tmp/repo/pool; cd /tmp; apt download hello; mv hello_*.deb 
/tmp/repo/pool/; cd /tmp/repo
-     OPENSSL_CONF=/etc/ssl/fips.cnf apt-ftparchive -o 
APT::FTPArchive::LongDescription=false packages pool | grep ^Description-md5
+     apt update
+     mkdir -p /tmp/repo/pool; cd /tmp; apt download hello; mv hello_*.deb 
/tmp/repo/pool/; cd /tmp/repo
+     OPENSSL_CONF=/etc/ssl/fips.cnf apt-ftparchive -o 
APT::FTPArchive::LongDescription=false packages pool | grep ^Description-md5
  
  Assert a Description-md5 line whose value changes each time the last
  command is run. apt could not compute MD5 and printed uninitialised
  memory.
  
  * Test the fix:
  
  1. Install apt from resolute-proposed:
  
-     printf '%s\n' 'Types: deb' 'URIs: http://archive.ubuntu.com/ubuntu' 
'Suites: resolute-proposed' 'Components: main universe' 'Signed-By: 
/usr/share/keyrings/ubuntu-archive-keyring.gpg' > 
/etc/apt/sources.list.d/proposed.sources
-     apt update
-     apt install -y -t resolute-proposed apt libapt-pkg7.0 apt-utils
+     printf '%s\n' 'Types: deb' 'URIs: http://archive.ubuntu.com/ubuntu' 
'Suites: resolute-proposed' 'Components: main universe' 'Signed-By: 
/usr/share/keyrings/ubuntu-archive-keyring.gpg' > 
/etc/apt/sources.list.d/proposed.sources
+     apt update
+     apt install -y -t resolute-proposed apt libapt-pkg7.0 apt-utils
  
  2. Repeat step 3 of "Reproduce the bug". Assert that all index files are
  fetched, with no "Ign:" or "Err:" lines and no OpenSSL error.
  
  3. Generate the Packages entry again in FIPS-only mode:
  
-     cd /tmp/repo
-     OPENSSL_CONF=/etc/ssl/fips.cnf apt-ftparchive -o 
APT::FTPArchive::LongDescription=false packages pool | grep ^Description-md5
+     cd /tmp/repo
+     OPENSSL_CONF=/etc/ssl/fips.cnf apt-ftparchive -o 
APT::FTPArchive::LongDescription=false packages pool | grep ^Description-md5
  
  Assert that it prints nothing: no Description-md5 line is written.
  
  4. Check that normal use still works without the FIPS config, over https
  and then over http:
  
-     rm -rf /var/lib/apt/lists/*; apt update && apt install -y --reinstall 
hello
-     sed -i 's#https://#http://#' /etc/apt/sources.list.d/ubuntu.sources
-     rm -rf /var/lib/apt/lists/*; apt update && apt install -y --reinstall 
hello
+     rm -rf /var/lib/apt/lists/*; apt update && apt install -y --reinstall 
hello
+     sed -i 's#https://#http://#' /etc/apt/sources.list.d/ubuntu.sources
+     rm -rf /var/lib/apt/lists/*; apt update && apt install -y --reinstall 
hello
  
  Assert that both updates and both installs finish with no error.
  
  Verified on 2026-11-05 in a fresh LXD resolute container: apt 3.2.1ubuntu0.1 
shows every result under "Reproduce the bug", and a build of the merge request 
against 3.2.y shows every result under "Test the fix":
  https://salsa.debian.org/apt-team/apt/-/merge_requests/647
  
  [ Where problems could occur ]
  
  The fixes change the hashing code in libapt-pkg, which every download
  and verification goes through. With OpenSSL's default provider every
  digest is available, so neither fix should change anything there. A
  regression would show as "Hash Sum mismatch" or a missing hash during
  apt update or apt install, or as hash fields missing from apt-ftparchive
  output, on a system with nothing unusual configured.
  
  The first fix discards the errors OpenSSL records while apt sets up a
  digest. The reason a digest is unavailable is therefore no longer on
  OpenSSL's error stack, which could make such a setup harder to diagnose.
  
  The second fix returns an empty digest where apt used to crash or print
  garbage for an unavailable digest. Code that asks for one specific
  digest now gets an empty result. On a FIPS-only system apt-ftparchive no
  longer writes a Description-md5 field, and apt-cdrom, which identifies
  discs by MD5, is affected in the same way. Scripts that expect that
  field will notice.
  
  No public header or library ABI changes. Other programs that use libapt-
  pkg, such as python-apt, aptitude and PackageKit, get the same changes
  in behaviour.
  
  [ Other Info ]
  
   - Upstream: apt 3.3.2 (released 2026-07-30), commits dfeecf7f and d714c12f.
   - Debian: #1140227 (found in 3.0.3, fixed in 3.3.2).
   - The development series already has apt 3.3.3, which includes the fix.
   - The upstream 3.2.y branch has no commits since 3.2.0, so this would be an
     Ubuntu-specific cherry-pick unless upstream cuts 3.2.1.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2171346

Title:
  [SRU] apt fails all HTTPS fetches when OpenSSL is in FIPS-only mode
  (stale OpenSSL error from MD5 init)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt/+bug/2171346/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to