🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
8 messages
8 total messages Started by Julien ÉLIE Sun, 28 Dec 2008 19:44
UTF-8 in NNTP commands
#79938
Author: Julien ÉLIE
Date: Sun, 28 Dec 2008 19:44
41 lines
2398 bytes
Hi,

Should a news server generate a 501 response upon receiving an NNTP command
which is not properly encoded in UTF-8?

RFC 4643 (AUTHINFO) does not tackle the issue of encodings.  Therefore,
I believe it is assumed that everything is in UTF-8.

However, I am unsure that logins and passwords are correctly encoded
by news clients.  I do not know what they send!

    AUTHINFO USER été
    AUTHINFO PASS αβγ

is not allowed by RFC 3977.
And afterwards, external auth programs will have to handle UTF-8 too...

On the other hand, if a news server receive:

    AUTHINFO USER été

from a compliant news client, how can it understand that it is a 3-character
long login ("été") and not a 5-character long login ("été")?


What should be done?


If two newsgroups have the same name (one encoded in ISO-8859-1 and
the other in UTF-8 for instance), they may be seen as two different
newsgroups and we wouldn't be able to access the first one if UTF-8
was required.

And other similar issues...

-- 
Julien ÉLIE

« Quand on demande aux gens d'observer le silence, au lieu de l'observer
  comme on observe une éclipse de lune, ils l'écoutent ! » (Raymond Devos) 
Re: UTF-8 in NNTP commands
#79939
Author: Russ Allbery
Date: Sun, 28 Dec 2008 19:54
54 lines
3705 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

> Should a news server generate a 501 response upon receiving an NNTP
> command which is not properly encoded in UTF-8?

The standard says that clients shouldn't do that, which means that servers
can choose what to do if they receive something like that based on the
normal principles of being liberal in what one accepts.

> RFC 4643 (AUTHINFO) does not tackle the issue of encodings.  Therefore,
> I believe it is assumed that everything is in UTF-8.
>
> However, I am unsure that logins and passwords are correctly encoded
> by news clients.  I do not know what they send!
>
>    AUTHINFO USER été
>    AUTHINFO PASS αβγ
>
> is not allowed by RFC 3977.
> And afterwards, external auth programs will have to handle UTF-8 too...

I'm sure right now they assume servers implement this as byte strings.

SASL provides ways of dealing with this, including Unicode
canonicalization (depending on the SASL mechanism chosen).  I think the
AUTHINFO USER/PASS code should just preserve the legacy approach of
treating the input as a byte string, since newer clients should hopefully
switch to SASL anyway and that's the best opportunity to change behavior
here.  Character set issues really aren't defined well unless you're using
SASL, and there are a ton of them around authentication information and a
whole standard within SASL (saslprep, RFC 4013) for dealing with them.

> If two newsgroups have the same name (one encoded in ISO-8859-1 and
> the other in UTF-8 for instance), they may be seen as two different
> newsgroups and we wouldn't be able to access the first one if UTF-8
> was required.

The server really can't do character set conversion since there's no way
for the client to say what character set it's using, so I think all of the
work needs to be done on the client.  Given that, it's probably simplest
for backwards compatibility for whatever people might be doing in local
hierarchies if the server treats newsgroup names as byte strings and
doesn't reject non-UTF-8 ones.

Currently, there's no provision for non-ASCII newsgroup names in the
article format standard.  My hope is that we'll manage to jump mostly
straight from ASCII to UTF-8 without a lot of ISO-8859-1 newsgroup names
(there are a few out there now, but not many at all).

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: UTF-8 in NNTP commands
#79943
Author: Julien ÉLIE
Date: Sun, 28 Dec 2008 20:39
58 lines
3425 bytes
Hi Russ,

> The standard says that clients shouldn't do that, which means that servers
> can choose what to do if they receive something like that based on the
> normal principles of being liberal in what one accepts.

   Implementations of this specification MUST NOT generate malformed or
   illegal sequences and SHOULD detect them and take some appropriate
   action.  This could include the following:

   o  Generating a 501 response code.

   o  Replacing such sequences by the sequence %xEF.BF.BD, which encodes
      the "replacement character" U+FFFD.

   o  Closing the connection.

   o  Replacing such sequences by a "guessed" valid sequence (based on
      properties of the UTF-8 encoding).

   Implementations SHOULD use one of the first two solutions where
   the general structure of the NNTP stream remains intact and SHOULD
   close the connection if it is no longer possible to parse it
   sensibly.


It looks as though the three first solutions should be used by an
unconditionally compliant news server.  But it would break a few
commands like AUTHINFO USER/PASS with clients which do not implement
RFC 3977.  Therefore, it will probably be impossible to do anything
with badly encoded arguments.



> I think the
> AUTHINFO USER/PASS code should just preserve the legacy approach of
> treating the input as a byte string, since newer clients should hopefully
> switch to SASL anyway and that's the best opportunity to change behavior
> here.

Hmm...  It is not said in RFC 4643.
If someone implements a compliant news client, he has to encode strings
in UTF-8.  And AUTHINFO USER/PASS will not work with news servers!



> Character set issues really aren't defined well unless you're using
> SASL, and there are a ton of them around authentication information and a
> whole standard within SASL (saslprep, RFC 4013) for dealing with them.

I did not know.  Thanks!

-- 
Julien ÉLIE

« -- Mais je leur ai simplement demandé si c'était la bonne route !!!
  -- Ils nous ont fait une 'éponse de No'mand ! » (Astérix) 
Re: UTF-8 in NNTP commands
#79942
Author: Julien ÉLIE
Date: Sun, 28 Dec 2008 20:53
31 lines
2364 bytes
>> I think the
>> AUTHINFO USER/PASS code should just preserve the legacy approach of
>> treating the input as a byte string, since newer clients should hopefully
>> switch to SASL anyway and that's the best opportunity to change behavior
>> here.
>
> Hmm...  It is not said in RFC 4643.
> If someone implements a compliant news client, he has to encode strings
> in UTF-8.  And AUTHINFO USER/PASS will not work with news servers!

In fact, it is said only in the ABNF syntax:

    authinfo-user-command = "AUTHINFO" WS "USER" WS username
    username = 1*user-pass-char
    user-pass-char = B-CHAR

    ;   B- means based on bytes, excluding NUL CR and LF
    B-CHAR     = CTRL / TAB / SP / %x21-FF


Subtlety not easy to spot!
We can easily be caught in a trap.

And I guess that B-CHAR chars must not be overencoded in UTF-8 (I see that
bodies are also B-CHAR and they are not overencoded in UTF-8).

-- 
Julien ÉLIE

« Non omnia possumus omnes. » (Virgile) 
Re: UTF-8 in NNTP commands
#79944
Author: Russ Allbery
Date: Sun, 28 Dec 2008 20:58
46 lines
3249 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

>> The standard says that clients shouldn't do that, which means that
>> servers can choose what to do if they receive something like that based
>> on the normal principles of being liberal in what one accepts.
>
>   Implementations of this specification MUST NOT generate malformed or
>   illegal sequences and SHOULD detect them and take some appropriate
>   action.

Oh, hm, good point.

So we really *should* do something to remove invalid UTF-8, but since
UTF-8 support is new, this may break things.

> It looks as though the three first solutions should be used by an
> unconditionally compliant news server.  But it would break a few
> commands like AUTHINFO USER/PASS with clients which do not implement RFC
> 3977.  Therefore, it will probably be impossible to do anything with
> badly encoded arguments.

As loathe as I am to add even more options, I wonder if we could make
strictly enforcing valid UTF-8 an option.  That would let people avoid
problems with malformed characters (which can in obscure situations
possibly become security issues, although I can't think of ones that would
affect NNTP off-hand) without breaking backward compatibility.

>> I think the AUTHINFO USER/PASS code should just preserve the legacy
>> approach of treating the input as a byte string, since newer clients
>> should hopefully switch to SASL anyway and that's the best opportunity
>> to change behavior here.
>
> Hmm...  It is not said in RFC 4643.  If someone implements a compliant
> news client, he has to encode strings in UTF-8.  And AUTHINFO USER/PASS
> will not work with news servers!

Using non-ASCII characters in usernames and passwords in network protocols
is kind of a mess.  :/  Even the saslprep effort turned into a significant
can of worms.  It's one of those things no one thought about when
designing the original protocols.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: UTF-8 in NNTP commands
#79954
Author: Julien ÉLIE
Date: Mon, 29 Dec 2008 07:25
19 lines
2080 bytes
Hi Russ,

> So we really *should* do something to remove invalid UTF-8, but since
> UTF-8 support is new, this may break things.

Should it be done on AUTHINFO USER/PASS too?  (Has B-CHAR to be in UTF-8?)

Otherwise, UTF-8 can only be put in wildmats for newsgroup names
(LIST ACTIVE, LIST ACTIVE.TIMES, LIST NEWSGROUPS, NEWNEWS, XGTITLE),
in newsgroup names (GROUP, LISTGROUP) or in XPAT.
For all these cases, it is a byte string comparison so maybe UTF-8 should
not be checked (the right command in UTF-8 will probably not be working).
XPAT normally uses US-ASCII (search in headers).

-- 
Julien ÉLIE

« Qui habet aures audiendi, audiat. » (Évangiles) 
Re: UTF-8 in NNTP commands
#79958
Author: Russ Allbery
Date: Mon, 29 Dec 2008 19:03
39 lines
2956 bytes
Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> writes:

> Hi Russ,
>
>> So we really *should* do something to remove invalid UTF-8, but since
>> UTF-8 support is new, this may break things.
>
> Should it be done on AUTHINFO USER/PASS too?  (Has B-CHAR to be in UTF-8?)

Given the ABNF, I think it shouldn't.  After you mentioned that, I vaguely
remember having that come up at the time.

> Otherwise, UTF-8 can only be put in wildmats for newsgroup names
> (LIST ACTIVE, LIST ACTIVE.TIMES, LIST NEWSGROUPS, NEWNEWS, XGTITLE),
> in newsgroup names (GROUP, LISTGROUP) or in XPAT.

XPAT is a nasty problem that may have to be another special case.
Otherwise, newsgroup names are already supposed to be in either ASCII or
UTF-8, and header field names are, of course, required to be ASCII.

> For all these cases, it is a byte string comparison so maybe UTF-8 should
> not be checked (the right command in UTF-8 will probably not be working).
> XPAT normally uses US-ASCII (search in headers).

Well, applications that take UTF-8 as input are supposed to check it for
well-formedness because there are some weird things that you can
potentially do if you can use arbitrary malformed UTF-8 (mostly by
exploiting differences in interpretation in different systems).

I'm starting to wonder if it would be useful to have some sort of strictly
conforming configuration flag in INN that, if set, checks all UTF-8,
requires RFC 1036-compliant message IDs for all articles, etc.  Might be
more trouble than it's worth, though.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: UTF-8 in NNTP commands
#79960
Author: Julien ÉLIE
Date: Mon, 29 Dec 2008 21:38
29 lines
2702 bytes
Hi Russ,

> I'm starting to wonder if it would be useful to have some sort of strictly
> conforming configuration flag in INN that, if set, checks all UTF-8,
> requires RFC 1036-compliant message IDs for all articles, etc.  Might be
> more trouble than it's worth, though.

When you spoke about the possibility to use that syntax in your parser:
    extraoverview: [ xref, newsgroups ]
I thought that we could use something like:
    rfcnocheck: [ utf8-commands, utf8-newsgroups, message-id, authinfo, metadata ]

in order to deactivate the check on UTF-8 for NNTP commands or newsgroups names,
enforce valid message-IDs (250 chars, etc.), AUTHINFO USER only after STARTTLS,
advertise :bytes and :lines in LIST OVERVIEW.FMT and things like that.

A good thing is that it would allow to write an unconditionally compliant
news server without having to wonder every where what is the best to do.

Note that rfcnocheck: could also be named rfcbackwardscompatibility: so that
it highlights that it is not intended to remove sane checks.

-- 
Julien ÉLIE

« -- Ils s'arrêtaient tous les jours à 5 heures,
  pour boire de l'eau chaude...
  -- Je prendrai un nuage de lait, je vous prie. » (Astérix) 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads