Stefan Monnier wrote: > > If filenames include version numbers and the version numbers are never > > reused, > > The ELPA system in general does not enforce that. But the GNU ELPA > scripts do, and other ELPA servers work in a way that should generally > make sure this is also the case. But having security rely on that makes it easier than necessary to accidentally open a window of vulnerability by failing to enforce that constraint. It's a brittle solution. >> then your solution does prevent package replay attacks. Since Emacs >> packages already include a Version header (and the package name), you could >> actually do your proposed verification using that header, without changing >> the way signatures are currently made, which is a solution I addressed in my >> original emacs-devel message. > > Indeed, I realized this just after I sent my message. > So we can fix this problem simply by changing package.el so as to check > that the name&version of the downloaded file match the name&version > contained therein. > Patch welcome. Ok, but as I explained in my original message, that solution still makes the attacker's job easier than necessary in some cases. Verifying the hash is a more robust solution than verifying the version number, so my patch below verifies the hash. This is forward compatible. You can install this now and start putting archive-contents with hashes on elpa (and melpa and marmalade), and old clients will simply ignore the hashes and operate as usual. BTW, one happy side effect of properly fixing this vulnerability is eliminating melpa's incentive to mangle package version numbers (they're mangled apparently to deal with the problem of package maintainers reusing version numbers). > It should be fairly easy to add a timestamp in there without > causing any backward incompatibility. Unfortunately, I don't see how to add timestamps to archive-contents without breaking old clients, so the metadata replay vulnerability will have to remain open until you decide how to handle the compatibility problem. My patch here only fixes the package replay vulnerability.