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

Re: [PATCH] gpg-interface: trim CR from ssh-keygen -Y find-principals

From
DMDamien Miller <djm@mindrot.org>
Date
Dec 5, 2021, 23:06 UTC
Message-ID
<70cee773-9547-e3cf-9327-ac0213d327e@mindrot.org>
In-Reply-To
<20211204131149.cvyu7dvf6p66dotq@fs>
On Sat, 4 Dec 2021, Fabian Stelzer wrote:
Show 10 quoted lines
> > I'm guessing probably not, but when it comes to something with security
> > implications like this, it pays to be extra careful. I'm hoping somebody
> > familiar with the ssh-keygen side and how the rest of the parsing works
> > (like Fabian) can verify that this is OK.
> > 
> 
> A good point. I just tested this and CR is a valid character to use in a
> principal name in the allowed signers file and as of now the principal will be
> passed to the verify call `as is` and everything works just fine. When we
> introduce the patch above a principal with a CR in it will fail to verify.

Are you sure? I thought that we split principals in allowed_signers on most whitespace, including \r. Follow:

https://github.com/openssh/openssh-portable/blob/e9c7149/sshsig.c#L742 https://github.com/openssh/openssh-portable/blob/e9c7149/misc.c#L452 https://github.com/openssh/openssh-portable/blob/e9c7149/misc.c#L408

> I've added Damien Miller to this thread. He knows more about what the expected
> behaviour for the principal would/should be. I think at the moment almost
> everything except \n or \0 goes. Maybe restricting \r as well would make life
> easier for other uses too?

IMO sensible content for the principals section would be printable, non- whitespace characters, excluding wildcards ('*', '?'). ssh-keygen mostly assumes that the file is in good order, but maybe it could be stricter.

Show 6 quoted lines
> If we add `trust on first use` in a future series I would assume we use the
> email address from the commit/tag author ident when adding a new principal to
> the file. Can the ident contain a CR?
> Even if it did, I would only allow a list of allowed alphanumeric chars to be
> added anyway since a principal can contain wildcards which we obviously don't
> want to trust on first use ;).

Yeah. my mental model for the allowed_signers file is that it's similar to ~/.ssh/authorized_keys in that it directly controls authn/authz decisions, and if you put bad stuff in there then you're going to have a bad day...

-d
Previous: Junio C HamanoNext: Fabian Stelzer
Message 6 of 30 in “gpg-interface: trim CR from ssh-keygen -Y find-principals”
  1. gpg-interface: trim CR from ssh-keygen -Y find-principalsJohannes Schindelin via GitGitGadget, Dec 3, 2021
  2. Fabian StelzerDec 3, 2021
  3. Jeff KingDec 3, 2021
  4. Fabian StelzerDec 4, 2021
  5. Junio C HamanoDec 5, 2021
  6. Damien MillerDec 5, 2021
  7. Fabian StelzerDec 6, 2021
  8. gpg-interface: trim CR from ssh-keygenFabian Stelzer, Jan 3, 2022
  9. Eric SunshineJan 3, 2022
  10. Junio C HamanoJan 3, 2022
  11. Eric SunshineJan 4, 2022
  12. Junio C HamanoJan 4, 2022
  13. Eric SunshineJan 4, 2022
  14. Fabian StelzerJan 4, 2022
  15. Junio C HamanoJan 4, 2022
  16. Eric SunshineJan 5, 2022
  17. Fabian StelzerJan 5, 2022
  18. Junio C HamanoJan 5, 2022
  19. Fabian StelzerJan 6, 2022
  20. Junio C HamanoJan 6, 2022
  21. Eric SunshineJan 9, 2022
  22. Fabian StelzerJan 10, 2022
  23. gpg-interface: trim CR from ssh-keygenFabian Stelzer, Jan 7, 2022
  24. Eric SunshineJan 9, 2022
  25. Fabian StelzerJan 10, 2022
  26. Junio C HamanoJan 10, 2022
  27. Junio C HamanoJan 10, 2022
  28. Fabian StelzerDec 9, 2021
  29. Fabian StelzerDec 9, 2021
  30. Fabian StelzerDec 30, 2021

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.