Web authoring advice
Saturday, October 1st, 2005 10:39 pmI've been sort-of commissioned to make a website for Marom. Now the only complex websites I've made until now have been strictly functional ones for work, driven by Perl CGI backends and with no security measures, as behind work's firewall. I can stumble my way through simple JavaScript from knowledge of C++, but don't know any Flash.
So I have a few questions for anyone who's made a public-facing website beforehand:
Firstly, any recommendations for an host ISP? This is a site of interest probably only to a few hundred people, but those few hundred might be visiting it frequently.
Secondly, as regards making it updatable by non-techies, I was thinking of providing proformas and inclusion of "what's on this week" files, etc, by server-side includes. Are server-side includes something ISPs are likely to provide?
Thirdly, would I stand a chance of having Perl available as a backend? And if so, how do you make it secure? I gather taint-checking is involved; once I've taken that into account, can I leave it all to Perl? Actually, I probably don't need Perl for the basic proposition, but when I was talking about it with Assael, he waxed lyrical about the possibilities -- message boards, a dating subsite, the works -- and it would be nice to be able to extend the site after its initial launch.
Any other advice whilst I'm at it?
So I have a few questions for anyone who's made a public-facing website beforehand:
Firstly, any recommendations for an host ISP? This is a site of interest probably only to a few hundred people, but those few hundred might be visiting it frequently.
Secondly, as regards making it updatable by non-techies, I was thinking of providing proformas and inclusion of "what's on this week" files, etc, by server-side includes. Are server-side includes something ISPs are likely to provide?
Thirdly, would I stand a chance of having Perl available as a backend? And if so, how do you make it secure? I gather taint-checking is involved; once I've taken that into account, can I leave it all to Perl? Actually, I probably don't need Perl for the basic proposition, but when I was talking about it with Assael, he waxed lyrical about the possibilities -- message boards, a dating subsite, the works -- and it would be nice to be able to extend the site after its initial launch.
Any other advice whilst I'm at it?
no subject
Date: 2005-10-02 12:36 am (UTC)Anyone offering "CGI" is almost certain to offer Perl.
Perl's taint mode is neither necessary nor sufficient; i.e. you can do without it (and many do), and even if you do use it you don't have any guarantee of security (you do have a guarantee of inconvenience, though).
You should think about how data you are passing across any interface will be interpreted. For instance anything you pass to the single-arg form of system will be treated as a shell command, with all the interesting bits of syntax that implies. You don't want your users to be able to insert a raw ; or ``, or any of a number of other characters, into a shell command you execute.
There are several approaches to dealing with this kind of thing. The two main ones are sanitization and quoting. The former means limiting the set of characters passed to those known to be safe: that is to say you remove or reject all characters not known to be safe. The latter means passing any character but quoting it appropriately for the interface in question so that the shell (or whatever) will not treat it as starting a new command or something. In the case of shell commands Perl's \Q operator is handy here.
I prefer the quoting approach, but both have their place.
(Hopefuly you've noticed that I've phrased things in terms of rejecting/removing/quoting characters not known to be safe, rather than rejecting those known to be unsafe.)
You should understand the interfaces you use. In Perl system is an obvious danger point as is ``; but open can take shell commands too, so if the caller has any influence at all over choice of filenames then you must be incredibly careful - if the client controls the first or last character of the “filename” for instance then they can potentially arrange for the command of their choice to be executed. Another trap with user-controlled filenames is using .. to escape into a parent directory - perhaps via a child directory! - and access some file that ought not to be available.
Changes of encoding used to be a classic source of error - e.g. decoding URL-encoding twice. Re-emitting input data to output without suitable SGML (or whatever) quoting is very another common error (a problem with this being that it lets an attacker “run” arbitrary HTML, perhaps with embedded scripts, with the victim's privileges, provided they can trick the victim into visiting a carefuly chosen URL). Format strings vulnerabilities (where you let the user control the first arg to printf or similar) are more commonly found in C programs, and probably aren't as evil in Perl as in C, but could in principle at least cause problems in Perl programs.
The idea of taint checking is that every bit of data received from an “untrusted” source is marked as tainted and any attempt to pass it across an interface where a badly chosen value could cause unexpected effects provokes an error. There are rules about which operations keep and lose the taint. I'm not really a fan of this approach myself, and it's noticable that taint checking seems to be very rarely used - I think in practice it's just not as useful as it sounds.
About the one thing you don't have to worry about in Perl are buffer overruns. But there are a large number of other potential disasters.
no subject
Date: 2005-10-02 10:20 am (UTC)Well I certainly have now. :o)
About the one thing you don't have to worry about in Perl are buffer overruns. But there are a large number of other potential disasters.
Ulp. Maybe I'll get someone with knowledge of insecurities to look over my scripts once I've written them.
But thanks for your advice anyway!
no subject
Date: 2005-10-02 03:24 pm (UTC)I'd also suggest reading up a little about SQL injection attacks if you're using any databases as a back-end to anything.
no subject
Date: 2006-05-26 01:07 pm (UTC)You should think about how data you are passing across any interface will be interpreted. For instance anything you pass to the single-arg form of system will be treated as a shell command, with all the interesting bits of syntax that implies. You don't want your users to be able to insert a raw ; or ``, or any of a number of other characters, into a shell command you execute.
Okay, my scripts are doing one of two things with their input. I have one script which uses the CGI params passed to it (by other links on the site) to call an off-site URL (what it's doing is rebranding a Yahoo Calendar to fit the site). This merely passes the parameters on to a LWP::UserAgent call to Yahoo, and reports them back to the user in the form of a link to the linked-to site. I would imagine this does not need protecting, as the user could not get control of anything here bar what is passed on to the Yahoo site.
The other thing I'm doing is parsing a webform by substituting the filled in field values and emailing it on (with fixed email headers) as an HTML page. Here I strip out angle brackets and script tags before sending it on. I'm using Mailer::Sender (actually Mailer::Sender::Easy), which connects direct to the mail server via a socket, to do the mailing. Do you know what the vulnerabilities of this are? Do I need to do any further substitution, like you suggest above; or worry about anything that this might do, in re buffer overruns or anything?
One of my webforms allows uploading of a file. I'm using code I found on the Web (http://perlmeme.org/tutorials/cgi_upload.html) to do so in a taint-safe manner, but is there anything else I should worry about in this regard?
no subject
Date: 2006-05-26 01:29 pm (UTC)As for the webform, it'll depend on how you're parsing the input. Better than stripping out known bad stuff is only allowing known good stuff.
Perl doesn't tend to have buffer-overrun problems very much, its problems are much more to do with its tendency to eval all sorts of things.
no subject
Date: 2006-05-26 01:41 pm (UTC)Depends how anal they're being, I suppose. It's no different, really, from presenting a syndicated RSS feed that looks different to its originating page (which I'm also doing). It's not that I'm trying to pass off Yahoo's work as my own: I'm providing a link to the original site, and including the Yahoo copyright notice, complete with hyperlinks to the terms of service and privacy policy.
Where do you draw the line? If you regard that as not okay, what if I'd got Yahoo's site in a frame on another site, with other content around it? Or an iframe?
OTOH, maybe I should get advice on this before I make the site live...
no subject
Date: 2006-05-26 01:42 pm (UTC)no subject
Date: 2006-05-28 08:37 am (UTC)no subject
Date: 2006-05-28 09:13 am (UTC)This is crazy. I've just been looking at the ToS for Blogspot, and Flickr, which I shall also be remunging in this way. The Blogspot ToS (http://www.blogger.com/terms.g) state:Which seems clear enough... and yet they provide an Atom feed for each blog, which expressly seems to encourage such behaviour! Moreover the ToS are not referenced in the Atom feed XML (http://maromuk.blogspot.com/atom.xml) or the "About Atom feeds"</>A page, nor do the ToS refer to syndication at all!
With Flickr, it's even crazier. Flickr's been bought by Yahoo. The Flickr ToS (http://www.flickr.com/terms.gne) page links to both Flickr's and Yahoo's ToS. The Flickr page says However, the Yahoo ToS (http://docs.yahoo.com/info/terms/)—the same as started off this subthread—say:And yet Flickr provides a syndication feed too! (I suppose the "interface that is provided by Yahoo! for us" could get a get-out clause for the syndication feed...) (http://help.blogger.com/bin/answer.py?answer=697)
no subject
Date: 2006-05-27 10:08 pm (UTC)The linked script allows a user who has a login on the system the CGI runs on to (over-)write any filename that the CGI can write to.
Stripping out script tags from HTML is doomed to failure unless you do a full SGML parse and reconstruct the message using only known-good elements and conservative quoting, since you cannot possibly hope to take account of the quirks everyone else's HTML parsers.
no subject
Date: 2006-05-27 10:22 pm (UTC)The linked script allows a user who has a login on the system the CGI runs on to (over-)write any filename that the CGI can write to.
Good point, though not relevant as I'm not using the save-back-to-disk part of the script.
Stripping out script tags from HTML is doomed to failure unless you do a full SGML parse and reconstruct the message using only known-good elements and conservative quoting, since you cannot possibly hope to take account of the quirks everyone else's HTML parsers.
Does changing all angle brackets into HTML entities such as I have in my script count as conservative quoting in this instance?
no subject
Date: 2006-05-27 10:43 pm (UTC)no subject
Date: 2006-05-28 08:38 am (UTC)no subject
Date: 2006-05-28 10:24 am (UTC)Ah, right. I'm unclear at what point you're substituting into HTML, but whatever point that is is the point you should SGML quote it, and not before.
I would:
Obviously you need to know what the input encoding is in order to be able to correctly interpret any bytes outside the 0-127 range. DisOrder uses <form ... enctype="multipart/form-data" accept-charset=utf-8> to request that the input be UTF-8.
Once you have encoded every character with special meaning, there is no need to delete script tags, since there's no possibility of anything being interpreted as a tag any more.
no subject
Date: 2006-05-28 11:03 am (UTC)no subject
Date: 2005-10-02 03:27 pm (UTC)no subject
Date: 2005-10-02 03:44 pm (UTC)no subject
Date: 2005-10-11 09:06 am (UTC)Host ISP Bug
Date: 2018-03-07 06:59 am (UTC)https://isphack.blogspot.com/2018/02/how-to-find-working-host-for-free.html
Is Hack of any Local ISP!
Date: 2018-03-07 07:02 am (UTC)Finding ISP Host and BUG to get Free Internet (https://isphack.blogspot.com/2018/02/how-to-find-working-host-for-free.html)
[url=https://isphack.blogspot.com/2018/02/how-to-find-working-host-for-free.html]Find Best Tips to Get ISP Host Bug[/url]