From: Jeff King Date: Sat, 11 Jul 2026 07:33:20 GMT Subject: Re: [PATCH] object-file: fix closing object stream twice Message-ID: <20260711073320.GA1457061@coredump.intra.peff.net> In-Reply-To: <20260710-pks-odb-stream-double-close-v1-1-d5fa233a37c7@pks.im> On Fri, Jul 10, 2026 at 04:54:16PM +0200, Patrick Steinhardt wrote: > And while the mentioned commit did drop one call that closed the stream, > there's a second such call that was missed when reading from the stream > fails. The consequence of this can be a double free of the stream. > > Fix the bug by dropping that leftover call to `odb_read_stream_close()`. Thanks, both the patch and the new test look good to me. > Note that it was originally discussed whether this should be treated as > a security vulnerability. But there are only two callers: once via > `parse_object_with_flags()`, and once via `verify_packfile()`. Neither > of these callers plays any role on the transport layer, so this issue is > only relevant for objects that are already available via the local > object database. Furthermore, a packfile that is corrupted in this way > would be detected when receiving the packfile, so it's not easy for an > adversary to plant such a packfile, either. Consequently, we decided > that this is not covered as part of our threat model. I think this case probably would violate our "it is OK to clone from the local untrusted .git repo" goal (since you could perhaps get to this code path via upload-pack/pack-objects, though I didn't try it myself). But the text in git(1)'s SECURITY section is pretty clear that it is more goal than promise, and that this scenario carries extra risk exactly because of the increased attack surface. And that you can mitigate by serving from an untrusted user. -Peff