use hmac in balanced preferred content
authorJoey Hess <joeyh@joeyh.name>
Sat, 10 Aug 2024 20:32:54 +0000 (16:32 -0400)
committerJoey Hess <joeyh@joeyh.name>
Sat, 10 Aug 2024 20:32:54 +0000 (16:32 -0400)
commitbd5affa362e47581eeb25e74291781eb51d5dbaa
tree3ea712f25f821d928e06df63d491f7c1035cd68d
parentbde58e6c7140a2907e0c03df8b73980bb0262ad3
use hmac in balanced preferred content

This deals with the possible security problem that someone could make an
unusually low UUID and generate keys that are all constructed to hash to
a number that, mod the number of repositories in the group, == 0.
So balanced preferred content would always put those keys in the
repository with the low UUID as long as the group contains the
number of repositories that the attacker anticipated.
Presumably the attacker than holds the data for ransom? Dunno.

Anyway, the partial solution is to use HMAC (sha256) with all the UUIDs
combined together as the "secret", and the key as the "message". Now any
change in the set of UUIDs in a group will invalidate the attacker's
constructed keys from hashing to anything in particular.

Given that there are plenty of other things someone can do if they can
write to the repository -- including modifying preferred content so only
their repository wants files, and numcopies so other repositories drom
them -- this seems like safeguard enough.

Note that, in balancedPicker, combineduuids is memoized.
Annex/Balanced.hs [new file with mode: 0644]
Crypto.hs
Limit.hs
Logs/Group.hs
Test.hs
Types/Group.hs
Utility/Hash.hs
Utility/Verifiable.hs
doc/todo/git-annex_proxies.mdwn
git-annex.cabal