Archive URL generated archives changed (but their content remains identical) #1366
Labels
No labels
accessibility
bug
bug
infrastructure
Codeberg
contributions welcome
docs
duplicate
enhancement
infrastructure
legal
licence / ToS
please chill
we are volunteers
public relations
question
question
user support
s/Forgejo
s/Pages
s/Weblate
s/Woodpecker
security
service
upstream
wontfix
No milestone
No project
No assignees
9 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Codeberg/Community#1366
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Comment
hi,
it seems that recently the compressor for .tar.gz archive URLs changed.
the above shows that compressed content differs while decompressed
content remains identical.
(dls/foot-1.16.2.tar.gz is downloaded from the gentoo master distfiles mirror, containing old versions of these files,
/var/cache/distfiles/foot-1.16.2.tar.gz is fetched from codeberg at
around two in the morning last night)
was this intended? what is the stability guarantee on these endpoints?
EDIT: both of the archives were fetched from https://codeberg.org/dnkl/foot/archive/1.16.2.tar.gz but at differentt times (a few weeks back vs. today) - apologies for the lack of context.
see also: https://lwn.net/Articles/921787/
If the checksum changed that's a huge problem, if you want to package Software from Codeberg. Many formats e.g. AUR or Flatpak rely on checksums. I fortunately never faced this problem myself. It looks like you can config how git craetes archivs, so this should maybe be done on Codeberg.
@fnetX Might be worth pinging you over this.
Wouldn't a change now potentially break recently generated archives, too? Is this problem "small enough"?
unsure - i don't have stats on which packages from codeberg were affected.
We have applied a change to Codeberg that uses the old way to generate archives for all commits that are older than November 12th 2023, which is the date when we deployed the new Git version.
It is only a heuristic, but probably good enough. Please give us feedback if this solves your problem.
Also note that this is best-effort. We still do not make explicit guarantees about archive checksum stability, and recommend that tooling relies e.g. on checksum of content rather than archive.
Thanks
That's a big problem. Most things use the archive checksum with no way to use the content checksum. If checksum stability is not guaranteed, that's a really big problem for OpenSource projects when packages randomly do not work anymore.
checking contents requires decompressing. if decompressor inputs aren't checked, decompressors are subject to possible exploitation (e.g. zip bombs or more)
In my opinion, the checksum stability should be guaranteed within Git, since we only use the standard way of compressing archives.
Our patch also leads to inconsistencies across platforms. For example, a Git archive downloaded on GitHub is now different from a archive downloaded on Codeberg in most cases, old Git archives downloaded from arbitrary Forgejo instances are now also different from Git archives downloaded on Codeberg.
I would expect that when I mirror a source code on three forges, that they all have the same checksum, because there is a standard way for Git to create these archives.
It's hard to make guarantees for something that is in control of upstream projects. Unlike GitHub, we don't have the human power to operate a fork of Git itself.
My offer is that you follow the announcements regarding new Forgejo releases and test-drive them e.g. on https://next.forgejo.org (or work with us on our environments). If you report that checksums are changing between the releases, it will be considered a bug and blocking a release until it is resolved. This likely works out.
But I doubt that we have enough human resources for a proper fix on our scale. Maybe you have a simple proposal about how we could guarantee for checksum stability, though?
There needs to be a new regression test that verifies the stability of these checksums. https://code.forgejo.org/forgejo/end-to-end already has that kind of tests. But not this one specifically.
I have found a changed checksum in one of my repos. The Checksum of https://codeberg.org/JakobDev/jdMinecraftLauncher/archive/5.2.tar.gz changed from
0f63819ad0c7ed27b0e4e486f3550031d12986ac4160d34ba1932c97393208dbtoa434bd1db63276ca3d50cf668952629d6914b5e5fc053fd43832393a1197191f.Can you say to when the checkpoint changed? The commit this tag references is old and it should have chosen the old checksum implementation in this case 😕
When was the 0f… checksum generated?
The of checksum was from the day I created the release. I don't know when the checksum changed. I updated the Flatpak of the Program today, so I found out it has been changed.
I found another one: https://codeberg.org/JakobDev/minecraft-launcher-lib/archive/6.4.tar.gz changed from
78456049ad624337eb00595279363f0215743b427abb62bac620ed1e4fb6c854to0e9e6248f514caffd282f9597f48f4eac131c23c15b1034f724e4a66ea235a93.That's a huge problem for me. I create AUR packages for my Software. If the Checksum just randomly change, the package breaks and can no longer be installed.
@JakobDev Can you see something obviously wrong with
53ee27c8f8? I am wondering, because our testing confirmed that the patch was working as desired (we compared the hashes with and without the patch, and confirmed that those after the specified timestamp are using the new, and older ones the external gzip method).The only thing I can currently think of is that we actually need to specify it for the tgz format, too (although I understand the Git docs that this should only be necessary when the file name is actually .tgz).
Reading the patch again,
if commit.Author.When.After(gitVersionAbove2_38_0) {sounds wrong. Mustn't it be "Before" this specific timestamp that we want to use the gzip command? Could we have screwed up our testing?CC @Gusted
Weirdly enough yeah that should be, I must've read it the other way around, working with time sucks.
7b60917310The linked archives don't have the old checksum back. Maybe the generated archive is cached somewhere on the Server.
@Gusted The wrong check was there for 2 weeks. By fixing it you most likely break the checksum of all Archives from this time.
As far as I'm aware it's not deployed, given we still need to decide what we should do here.
I'm of opinion that we should drop the special check all together as that would fix what my broken check unfortunately has caused and all the 'old' archives are not relying that heavily on this checksum given that it took a whole month to even notice the checksum changed.
I won't say that nobody noticed. Man Users don't write a bug report when something breaks. But if Codeberg can now guarantee the Checksum will not change any further, I'm happy with it.
Fair, but if it's breaking such as people relying it for packages I would've assumed some noise about this sooner.
The problem is that the current deployed code is not 'correct' and IMO still needs fixing either by removing the fix or reversing the check so it's stable for old archives again (which are now breaking w.r.t. their checksum).
All archives created for commits prior to 23.00 UTC today will use the old checksum algorithm now, which is consistent with the behaviour of the past (before the broken patch was applied) and consistent with how the checksums are created now.
Starting with commits created tonight, we'll use the new Git default.
Choosing a time in the future ensures that a commit only has one way the archive is generated.
Last but not least, this likely needs an integration test in Forgejo to prevent the same from happening again in future Git versions - in case the algorithm is modified again. I still fear this is out of scope for the Codeberg Issue Tracker, contributions are welcome, though.
I opened an issue on the Forgejo tracker so this doesn't get lost: https://code.forgejo.org/forgejo/end-to-end/issues/83
External issue apparently caused by this problem, leaving here for posterity: https://github.com/microsoft/vcpkg/pull/35898
CC: @generic-pers0n
Looks like this is happening again: https://github.com/gentoo/guru/pull/138
seems that it is indeed wise for maintainers to run
make distcheckgiven how many problems of this sort happenedThere has been no further change on our end. This issue is not actionable without a detailed description of which checksum changed between which values. And it's especially interesting to learn when the checksum was created.
Sorry about that. I will pass on what you mentioned to the upstream PR.
So the situation likely looks like this:
So the problem only affects archive checksums which were generated or compared between Nov 12 and Jan 12. Because the behaviour during this time is a little complicated and depends on when a checksum was created, there is not much we can do about it.
For example:
@fnetX Your analysis seems to be correct. The newest checksum "fix" commit is basically just reverting back to the old one:
a26b4c839e8b748050a2OK. So it looks like you attempted to fix the problem on your end on Jan 5 using the "wrong" checksum for the archive (which was the version generated by Codeberg on that day). The problem came from both sides trying to fix the same problem which made it incompatible again.
I apologize for all the trouble this has caused. We didn't initially pay much attention to the change in Git's defaults for archive generation, but should have.
This issue was reported to MacPorts yesterday and upon investigation I see that 4 of our 8 ports that get their source code from Codeberg are affected because they were last updated between November 12 2023 and January 12 2024.
It took awhile for me to find this issue tracker to find this issue. I had originally thought it might be mentioned in your blog but I did not find anything about it there. When GitHub had this problem, they had writeups about it on their blog, both before they deployed the change that caused the problem and after they reverted it.
Reasons I can think of why it was not noticed sooner: