News for hackers. Stuff that matters.
Re:Why does my SSH private key still work after changing som... by locusofself on Saturday December 31, 2022 @02:12AM (#34194364)
I think it's funny that removing what looks like actual key material doesn't break a key, but having the wrong kind of newline, or trailing newline in a .pem file can cause certain programs (webservers etc) to not be able to load a cert or key.
Re:Why does my SSH private key still work after changing som... by ausudhz on Saturday December 31, 2022 @03:05AM (#34194587)
That's the difference between format and content. Web servers make sure the format is correct, they won't inspect the content
Re:Why does my SSH private key still work after changing som... by Dylan16807 on Saturday December 31, 2022 @06:28AM (#34195485)
I'm pretty sure they mean a web server configured to use the content for TLS.
Re:Why does my SSH private key still work after changing som... by marcosdumay on Saturday December 31, 2022 @02:49PM (#34200034)
Isn't the whitespace in pem files just recommended? AFAIK, it's there just for interoperability with old transport protocols and not a part of the data at all.
Re:Why does my SSH private key still work after changing som... by IshKebab on Saturday December 31, 2022 @04:56AM (#34195057)
A good example of the robustness of binary formats compared to text formats.
Re:Why does my SSH private key still work after changing som... by metafunctor on Saturday December 31, 2022 @06:24AM (#34195460)
This has nothing to do with binary versus text.
Re:Why does my SSH private key still work after changing som... by myself248 on Saturday December 31, 2022 @06:28AM (#34195481)
I think it does, insofaras OSs feel free to just fuck with the contents of files they think are text, replacing newlines willy-nilly. Files not identified as text are safe from such automatic tampering.
Re:Why does my SSH private key still work after changing som... by MayeulC on Saturday December 31, 2022 @06:36AM (#34195540)
I've never seen this behaviour at an OS level. This seems like an editor issue, and binary files are not exempt from being messed up by a slightly incompatible editor, far from it.
Re:Why does my SSH private key still work after changing som... by nemetroid on Saturday December 31, 2022 @06:48AM (#34195604)
Perhaps you have been spared from writing code for Windows:

https://learn.microsoft.com/en-us/cpp/c-runtime-library/refe...

> In text mode, carriage return-line feed (CRLF) combinations are translated into single line feed (LF) characters on input, and LF characters are translated to CRLF combinations on output.

Re:Why does my SSH private key still work after changing som... by Dylan16807 on Saturday December 31, 2022 @06:59AM (#34195689)
Is there a reason I should blame the OS specifically and not the C runtime?
Re:Why does my SSH private key still work after changing som... by nemetroid on Saturday December 31, 2022 @08:03AM (#34196082)
I guess it depends on how specific you want to be. The Windows C runtime is a component of the OS.
Re:Why does my SSH private key still work after changing som... by Dylan16807 on Saturday December 31, 2022 @08:49AM (#34196384)
Well you're not really supposed to use the OS copy of msvcrt.dll
Re:Why does my SSH private key still work after changing som... by tedunangst on Saturday December 31, 2022 @01:03PM (#34198927)
Yes, library functions do what you ask them to do.
Re:Why does my SSH private key still work after changing som... by MayeulC on Saturday December 31, 2022 @06:33AM (#34195519)
IMO that distinction doesn't make much sense. Text is (as soon as it's stored on a computer) a binary format: you have to specify encoding, etc.

Inserting or removing a control character in a binary file would break stuff too. Maybe even more so.

You may think of the ability to add CRCs (or at least checksums/parity bits) in a binary file? That's extra work, and can be provided by other mechanisms, like par files or at the filesystem level.

The advantage of text formats is that binary decoders for text are ubiquitous. That said, it's usually simple to filter input data through a decoder like gzip.

Re:Why does my SSH private key still work after changing som... by IshKebab on Saturday December 31, 2022 @08:17AM (#34196173)
You're not thinking about the human element. Parsers are implemented by real people, and they make mistakes.

If a format is human-readable and text based it's both far more likely that a) the spec isn't actually complete (because there's an implicit "sensible" option), and b) people don't read the spec anyway and guess the "sensible" option.

There are countless examples of bugs and security flaws in HTTP that wouldn't have been a problem with e.g. Protobuf.

Re:Why does my SSH private key still work after changing som... by woodruffw on Saturday December 31, 2022 @03:25PM (#34200363)
I don't think this is a good example of robustness: if the change had happened to affect the DER encoding instead of just a field within the DER encoding, this could just have easily been an example of the fragility of binary formats.

Rather, what's happening here is that the interpretation of the parsed format is malleable in an arguably incorrect way. There aren't any great solutions that I'm aware of to that, since the "fix" is to validate the correctness of fields that ultimately don't matter to the operation at hand.