Hash mismatch on "apt update"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libgcrypt20 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
This is a really weird bug that is happening on Ubuntu 20.04 LTS (Live ISO!!!) and Kali 2020.2, but not Debian 10 (so, it affects at least apt 2.0.2ubuntu0.1 and does not affect 1.8.2.1). It also only occurs on a single PC (as far as I know). All testing was done in Virtualbox and moving VM's to another PC fixed issue (without changing anything inside the VM).
On running "apt update", there is an error "Hash Sum mismatch" which shows that SHA1 and SHA256 hashes differ from expected (while MD5 and file size is correct). E.g.:
Hash Sum mismatch
Hashes of expected file:
- Filesize:314536 [weak]
- SHA256:
- SHA1:4f438d7e0c
- MD5Sum:
Hashes of received file:
- SHA256:
- SHA1:2839e06223
- MD5Sum:
- Filesize:314536 [weak]
I ran packet capture and extracted archives which are getting verified. All of their hashes are correct (exactly as expected).
It seems that calculating SHA1 and SHA256 the way APT does it produces wrong result, while running command line tools sha1sum and sha256sum (on the same PC inside the same VM) produces correct result.
I wrote the minimal reproducible example (hashtest.cc) that produces output such as this:
Calculating hashes same way apt does.
- MD5Sum:
- SHA1:f6901a4486
- SHA256:
- SHA512:
- Checksum-
Calculating hashes through command line tools.
- md5sum: c89b13b76197d0d
- sha1sum: f6901a4486e69a1
- sha256sum: 9075301b3961aca
- sha512sum: 7506f6f5c5d5e97
It's in the attachment alongside with an example file that causes this hash mismatch. There's also debug.log which contains various versions, etc (although as I said, it has been verified on latest Ubuntu Live ISO).
I have a suspicion that the bug is in the gcrypt library, not apt itself, but I haven't yet verified it. The libgcrypt20 version in Ubuntu is 1.8.5-5ubuntu1 (in Kali as well), while Debian 10 (which isn't affected) uses 1.8.4-5.
---
ProblemType: Bug
ApportVersion: 2.20.11-0ubuntu27
Architecture: amd64
CasperMD5CheckM
CasperMD5CheckR
CasperVersion: 1.445
DistroRelease: Ubuntu 20.04
LiveMediaBuild: Ubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200423)
NonfreeKernelMo
Package: apt 2.0.2
PackageArchitec
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
LANG=en_US.UTF-8
SHELL=/bin/bash
ProcVersionSign
Tags: focal
Uname: Linux 5.4.0-26-generic x86_64
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups:
_MarkForUpload: True
affects: | apt (Ubuntu) → libgcrypt20 (Ubuntu) |
Thank you for taking the time to report this bug and helping to make Ubuntu better. Please execute the following command only once, as it will automatically gather debugging information, in a terminal:
apport-collect 1890006
When reporting bugs in the future please use apport by using 'ubuntu-bug' and the name of the package affected. You can learn more about this functionality at https:/ /wiki.ubuntu. com/ReportingBu gs.