git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-patch-id and syntactically significant whitespace

From
Jeff King <peff@peff.net>
Date
Feb 10, 2020, 22:24 UTC
Message-ID
<20200210222443.GA623231@coredump.intra.peff.net>
In-Reply-To
<20200210164115.x4gciujyjisivfgi@chatter.i7.local>
On Mon, Feb 10, 2020 at 11:41:15AM -0500, Konstantin Ryabitsev wrote:
Show 12 quoted lines
> This mostly becomes a problem if we try to build any kind of patch 
> indexing/retrieval systems that rely on patch-id to identify patches.  
> While this is not a high-impact problem by any means, it's not a 
> theoretical concern: git-format-patch includes functionality to provide 
> patch dependencies via prerequisite-patch-id trailers [1]. An automated 
> system attempting to auto-fetch dependencies can potentially retrieve 
> and apply the malicious version of the patch.
> 
> I'm not sure what the solution here is, since changing git-patch-id to 
> not discard whitespace is obviously going to defeat its entire purpose 
> of "not ever changing". I mostly wanted to share my findings in case 
> someone has thoughts on how to best approach this.

Can't you already have malicious patch-id collisions without the whitespace thing? The patch-id also throws away line numbers, so a patch adding "return 0" in an innocent location could have the same patch-id as one adding it somewhere more dangerous. It's just a question of the context, but there's often enough boilerplate for two functions to look similar.

This is occasionally a problem for actual accidental collisions (in patch-ids, but also when merging). I can imagine it's probably not that hard for a determined attacker to make such a case intentionally.

-Peff
Previous: Konstantin Ryabitsev
Message 2 of 2 in “git-patch-id and syntactically significant whitespace”
  1. Konstantin RyabitsevFeb 10, 2020
  2. Jeff KingFeb 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.