From: Dave Borowitz <dborowitz@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Shawn Pearce <spearce@spearce.org>, git <git@vger.kernel.org>
Subject: Re: [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required
Date: Mon, 6 Jul 2015 13:18:02 -0400 [thread overview]
Message-ID: <CAD0k6qQW3TbgXDsc2Wzid8RNyugumUbSu4KTzO21euO3y_OWGw@mail.gmail.com> (raw)
In-Reply-To: <CAD0k6qT8=xQb6MRcLkyvZBm0MRdQ0Z-8ojqghovdgeJQ2EBNEA@mail.gmail.com>
On Mon, Jul 6, 2015 at 1:11 PM, Dave Borowitz <dborowitz@google.com> wrote:
> On Mon, Jul 6, 2015 at 12:57 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Dave Borowitz <dborowitz@google.com> writes:
>>
>>> The server can munge pkt-lines and reinsert LFs, but it _must_ have
>>> some way of reconstructing the payload that the client signed in order
>>> to verify the signature. If we just naively insert LFs where missing,
>>> we lose the ability to verify the signature.
>>
>> I still do not understand this part.
>>
>> There is no way to "naively" insert, is there? You have an array of
>> lines (each of which you have already stripped its terminating LF at
>> its end). How else other than adding one LF at the end of each
>> element do you reconstruct the original multi-line string the client
>> signed? Are there other ways that makes the result ambiguous??
>
> I think I understand the confusion now. I think you and I are working
> from different assumptions about the client behavior.
>
> My assumption was: the intended behavior for the client is to sign the
> exact payload that was sent over the wire, minus pkt-line headers.
>
> For example, under my assumption, if the client sent:
>
> 0008foo\n
> 0007bar
> 0008baz\n
>
> then this indicates the client signed:
>
> "foo\nbarbaz\n"
>
> Under this assumption, "naively inserting LF" means inserting an LF
> after "bar". Thus the server would record the following in a
> persistent store:
>
> "foo\nbar\nbaz\n"
>
> If we only store this string, and do not remember the fact that the
> client originally omitted one of those LFs, then when we go back to
> verify that signature later, it will fail.
>
> That was my assumption.
>
> Your assumption, IIUC, is that the payload the client signed MUST have
> contained LFs in between each line. When framing the content for the
> wire, the client MUST send one "logical line", which has no trailing
> LF, per pkt-line, and furthermore the pkt-line content MAY contain an
> additional trailing LF.
>
> Under your assumption, the server always has enough information to
> reconstruct the original signed payload.
>
>
> The problem with the documentation, then, is that the documentation
> does not say anything to indicate that the signed payload is anything
> other than what is on the wire.
Another way of looking at the problem with my assumptions is, I was
assuming "pkt-line framing" was the same thing as "pkt-line header".
You seem to be saying the definition of "pkt-line framing" is "header,
and optional trailing newline".
A quick scan of pack-protocol.txt did not turn up anything one way or
the other on this issue, so perhaps we could make it more explicit.
The additional upside here is that we could then potentially remove
all or almost all LFs from this document.
> So maybe this series should include an explicit description of the
> singed payload outside of the context of a push. Then, in the push
> section, we can describe the set of transformations that the client
> MUST perform (splitting on LF; adding pkt-line headers) and MAY
> perform (adding LFs).
>
>>> If we say the payload the client signs MUST have LFs only in certain
>>> places, then that gives the server enough information to reconstruct
>>> the payload and verify the signature.
>>>
>>> But if we say the signed payload MUST have LFs and the wire payload
>>> MAY have LFs, then now we have two completely different formats, only
>>> one of which is documented.
>>
>> I thought that was what I was saying. The wire protocol sends the
>> contents of each line (both what is signed and the signature) on a
>> separate packet. When I say "contents of a line", I do not include
>> the terminating LF as part of the line (iow, LF is not even
>> optional; the terminating LF is not considered as part of "the
>> contents of a line"). It becomes irrelevant that a pkt-line may or
>> may not have a trailing optional LF. If there is LF at the end of a
>> packet between "push-cert" and "push-cert-end" packets, that LF by
>> definition cannot be part of the "contents of a line" in a
>> certificate.
>>
>> It is just a pkt-line framing artifact you can and should remove if
>> you are doing a "split to array, join with LF" implementation to
>> recover the original string.
>>
>> And that is very much consistent with the way we send other things
>> with pkt-line protocol. Each packet up to the first flush is
>> expected to have <object name> and <refname> as ref advertisement.
>> The pkt-line framing may or may not add a trailing LF, but LF is not
>> part of <refname>. It is not even part of the payload; merely an
>> artifact of pkt-line framing.
next prev parent reply other threads:[~2015-07-06 17:18 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 18:08 [PATCH 0/7] Clarify signed push protocol documentation Dave Borowitz
2015-07-01 18:08 ` [PATCH 1/7] pack-protocol.txt: Add warning about protocol inaccuracies Dave Borowitz
2015-07-01 19:39 ` Jonathan Nieder
2015-07-01 19:52 ` Junio C Hamano
2015-07-01 19:56 ` Dave Borowitz
2015-07-01 18:08 ` [PATCH 2/7] pack-protocol.txt: Mark LF in command-list as optional Dave Borowitz
2015-07-01 18:21 ` Stefan Beller
2015-07-01 18:46 ` Dave Borowitz
2015-07-01 18:08 ` [PATCH 3/7] pack-protocol.txt: Mark all LFs in push-cert as required Dave Borowitz
2015-07-01 20:00 ` Junio C Hamano
2015-07-01 20:07 ` Dave Borowitz
2015-07-01 20:49 ` Junio C Hamano
2015-07-06 14:46 ` Dave Borowitz
2015-07-06 15:22 ` Dave Borowitz
2015-07-06 15:27 ` Dave Borowitz
2015-07-06 15:29 ` Dave Borowitz
2015-07-06 15:35 ` Dave Borowitz
2015-07-06 16:12 ` Junio C Hamano
2015-07-06 15:46 ` Shawn Pearce
2015-07-06 16:28 ` Junio C Hamano
2015-07-06 16:28 ` Junio C Hamano
2015-07-06 16:38 ` Dave Borowitz
2015-07-06 16:57 ` Junio C Hamano
2015-07-06 17:11 ` Dave Borowitz
2015-07-06 17:18 ` Dave Borowitz [this message]
2015-07-06 17:34 ` Junio C Hamano
2015-07-06 17:38 ` Dave Borowitz
2015-07-06 18:06 ` Junio C Hamano
2015-07-06 18:08 ` Dave Borowitz
2015-07-06 18:23 ` Junio C Hamano
2015-07-06 17:30 ` Junio C Hamano
2015-07-06 17:35 ` Dave Borowitz
2015-07-06 17:59 ` Junio C Hamano
2015-07-01 20:36 ` Junio C Hamano
2015-07-01 20:39 ` Junio C Hamano
2015-07-02 13:53 ` Jeff King
2015-07-03 17:45 ` Junio C Hamano
2015-07-03 18:07 ` Jeff King
2015-07-03 18:43 ` Shawn Pearce
2015-07-03 18:46 ` Jeff King
2015-07-01 18:08 ` [PATCH 4/7] pack-protocol.txt: Elaborate on pusher identity Dave Borowitz
2015-07-01 18:58 ` Junio C Hamano
2015-07-01 18:08 ` [PATCH 5/7] pack-protocol.txt: Be more precise about pusher-key relationship Dave Borowitz
2015-07-01 18:08 ` [PATCH 6/7] pack-protocol.txt: Mark pushee field as optional Dave Borowitz
2015-07-01 18:56 ` Junio C Hamano
2015-07-01 19:06 ` Dave Borowitz
2015-07-01 19:07 ` Junio C Hamano
2015-07-01 19:08 ` Junio C Hamano
2015-07-01 19:31 ` Dave Borowitz
2015-07-01 18:08 ` [PATCH 7/7] send-pack.c: Die if the nonce is empty Dave Borowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAD0k6qQW3TbgXDsc2Wzid8RNyugumUbSu4KTzO21euO3y_OWGw@mail.gmail.com \
--to=dborowitz@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).