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

Re: [PATCH] builtin/receive-pack: use constant-time comparison for HMAC value

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 10, 2020, 00:09 UTC
Message-ID
<xmqqr1wwkxqe.fsf@gitster.c.googlers.com>
In-Reply-To
<20200409233730.680612-1-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 19 quoted lines
> When we're comparing a push cert nonce, we currently do so using strcmp.
> Most implementations of strcmp short-circuit and exit as soon as they
> know whether two values are equal.  This, however, is a problem when
> we're comparing the output of HMAC, as it leaks information in the time
> taken about how much of the two values match if they do indeed differ.
>
> In our case, the nonce is used to prevent replay attacks against our
> server via the embedded timestamp and replay attacks using requests from
> a different server via the HMAC.  Push certs, which contain the nonces,
> are signed, so an attacker cannot tamper with the nonces without
> breaking validation of the signature.  They can, of course, create their
> own signatures with invalid nonces, but they can also create their own
> signatures with valid nonces, so there's nothing to be gained.  Thus,
> there is no security problem.
>
> Even though it doesn't appear that there are any negative consequences
> from the current technique, for safety and to encourage good practices,
> let's use a constant time comparison function for nonce verification.
> POSIX does not provide one, but they are easy to write.
Devil's advocate mode on.

If the HMAC plus digital signature are the real security, even though writing this patch may be a nice mental exercise, is there a merit in deliberately adding more code and making the code immesurably slower by applying it?

You just established in the previous paragraph that "for safety" is a red herring.

Previous: brian m. carlsonNext: Junio C Hamano
Message 2 of 6 in “builtin/receive-pack: use constant-time comparison for HMAC value”
  1. builtin/receive-pack: use constant-time comparison for HMAC valuebrian m. carlson, Apr 9, 2020
  2. Junio C HamanoApr 10, 2020
  3. Junio C HamanoApr 10, 2020
  4. brian m. carlsonApr 10, 2020
  5. SZEDER GáborApr 22, 2020
  6. Junio C HamanoApr 22, 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.