Every now and then I see articles on introductory Web application
development that just leave me dumbfounded with their lack of attention
to security. There was one on PHP in an Aussie magazine last year that
paid no attention whatsoever to quoting user-entered data to guard
against SQL injection attacks. I was wondering how many readers would
have blithely copied the example code from that straight into their own
Web pages, leaving their sites wide open to malicious attacks.
I just came across another example, in the June issue of MacTech
magazine. MacTech just isn't what it used to be--in the early days it
was very much a hacker's publication, with articles on all kinds of
interesting ins and outs of the Mac OS, programming it, using it,
undocumented features etc. Since Apple's switch to OS X, it's become
more full of handholding tutorials for newbies unfamiliar with *nix ways
of doing things, like basic command-line concepts. Programmers who can't
handle basic command-line concepts!?
Anyway, the article that got my hackles up is about running a Web server
from home with a dynamic IP address. The technique the writer describes
involves an external minimal-function Web server with a static IP
address that knows how to redirect browsers to your home server. It gets
told which address your home server is on by periodic accesses to a
special Web page that records the address it was accessed from,
ip_to_file.pl (typed in from the article):
#!/usr/bin/perl -w
# Save IP address received from Home Server to file.
use CGI qw(:standard

;
$ipfile = 'home_server_ip';
print header,start_html;
if(open IPFILE, ">$ipfile")
{
$ip = $ENV{REMOTE_ADDR};
print IPFILE $ip . "\n";
close IPFILE;
print "Wrote to file $ipfile: $ip";
}
else
{
print "Failed to open file $ipfile for writing.";
}
print end_html;
Can you begin to describe the stupidity of doing such a thing? Again
we're going to have scores of people blindly copying the code from this
article, and leaving their systems wide open to mischief from others.
The trouble is, there is only one Internet. There is no kiddie pool you
can start out in, the whole pool is the deep end. As soon as you put
something up on a Web site, the entire world is immediately free to take
a crack at it. The bad guys don't just attack the sites of those with
the skills to hold them off, they can attack anybody's site. I guess
people shouldn't be allowed to put up stuff like this without somebody
more experienced to oversee them.