Re: Zero terminated strings
- From: "Tech07" <tech07@xxxxxxxxxx>
- Date: Sat, 1 Aug 2009 04:50:54 -0500
"Kaz Kylheku" <kkylheku@xxxxxxxxx> wrote in message
news:20090810164513.204@xxxxxxxxxxxx
On 2009-07-31, jacob navia <jacob@xxxxxxxxxx> wrote:
Zero terminated strings are a continuing security nightmare.
Slashdot reports this today:
"Two researchers, Dan Kaminsky and Moxie Marlinspike, came up with exact
same way to fake being a popular website with authentication from a
certificate authority.
Wired has the details: 'When an attacker who owns his own domain -
badguy.com - requests a certificate from the CA, the CA, using contact
information from Whois records, sends him an email asking to confirm his
ownership of the site. But an attacker can also request a certificate
for a subdomain of his site, such as Paypal.com\0.badguy.com, using the
null character \0 in the URL.
Obviously, this bug was caused by idiots who thought that they could solve
some
imaginary problem by using a ``better'' string library that can represent
a
null byte in the middle of a string.
A null byte has absolutely no place in character (i.e. text) strings. If
an
array of bytes contains nulls, it's not a character string, but a binary
string, or blob if you will. Null is not really a character, basically.
It has
no glyph, and no signaling action for printing control.
There is no legitimate need, ever, in a data representation for text, to
support an embedded null byte. It's not text; it's a special code which
says
``I am not text''. So, implicitly, if a null byte follows text, it means
either
that the text has ended, or the text is corrupt with the repugnant
inclusion of
non-text data.
The moral of this story is that if your language or string library allows
nulls
in the middle of a string, it's wrong, and you should fix it such that the
null
is treated as a terminator, or such that an exception is triggered if it
occurs.
There are good reasons for working with strings in a representation other
than
the null-terminated array, but being able to represent a null in the
middle of
a string is not one of those good reasons. Strings that know their own
length
should still banish the null byte from being a constituent.
"string" is actually the more general computer science term. "character
string" is a sub category. "string" is used as a synonym for "byte string"
where each byte may be 0 thru 255. In this thread though, "string" was
apparently being used as "character string"???
Jacob, when you say "string", do you mean "character string" or "byte
string"?
.
- Follow-Ups:
- Re: Zero terminated strings
- From: Tech07
- Re: Zero terminated strings
- References:
- Re: Zero terminated strings
- From: Kaz Kylheku
- Re: Zero terminated strings
- Prev by Date: Re: Zero terminated strings
- Next by Date: Re: Zero terminated strings
- Previous by thread: Re: Zero terminated strings
- Next by thread: Re: Zero terminated strings
- Index(es):
Relevant Pages
|