Verify FILE_CKSUM (sha256) in pkg_summary(5) on download.#141
Verify FILE_CKSUM (sha256) in pkg_summary(5) on download.#141riastradh wants to merge 2 commits intoNetBSDfr:masterfrom
Conversation
Rather than having to craft a new CHECK_DB_LATEST that fails with all old schema versions and works with the new schema version every time we make a schema change, we can just change the user_version number.
da916e1 to
263c235
Compare
This is important for detecting version rollback attacks -- verifying a signature on the package itself doesn't help, because the old one also has a valid signature.
263c235 to
204174b
Compare
|
I have a couple of issues with this. Firstly it breaks builds outside of pkgsrc: I've put a reasonable amount of effort into making pkgin build separately from pkgsrc, and would like to retain that. There are some options for pulling in a compat sha2 if the system doesn't provide one but they either use a different API or end up pulling in quite a lot more code. I'd need to investigate this further. Secondly I'm not keen on sha256 being hardcoded in a bunch of places, and have an aversion to spaces in column names. Given the pkg_summary format allows for arbitrary hashes, I think I'd prefer a separate table where these are stored along with an associated hash per entry for extensibility. I'm happy to work on this, but just wanted to post something to say that I am looking at this, as I need to cut a new pkgin release now for the pkgtools upgrade issue and this will have to be deferred until later. I have added initial |
Sorry -- I didn't test it, but I did add a libnbcompat fallback, and I'm a little surprised that didn't work because there are already libnbcompat fallbacks for other things in pkgin. Will investigate when I have a chance. If nothing else, we can just pull in a portable C SHA-256 from NetBSD libc. Not perfect but enough to get it working and able to be improved later, costing around only 12 KiB of text (probably half that if we strip out SHA-512 and SHA-384 too).
I appreciate the concern for hash agility, but does the perfect need to be the enemy of the good here and hold up a security measure? Here's the considerations that went into the choices I made:
That said, the patch at the very least already identifies all the places where you will need to substitute "hash" for "sha256" in order to do (5) if desired later, making it easy to do that change if you want. |
This is important for detecting version rollback attacks -- verifying a signature on the package itself doesn't help, because the old one also has a valid signature.
Relies on patch proposed for pkg_install to make
pkg_info -Xgenerate the FILE_CKSUM lines: https://mail-index.NetBSD.org/tech-pkg/2026/01/06/msg031853.html(Based on #140 to make schema changes easier and more reliable.)