Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 19th, 2001, 12:04 PM
lustyx lustyx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 25 lustyx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Taint and Too late for "-T" option

I was wondering if someone could tell me about Taint and using it in a Perl script. I have read up on it and basically I understand that Taint marks data that flows into the program as tainted so that the data cannot be used to access anything outside the scope of the program etc.

Next I tried to use Taint by including

#!/usr/bin/perl -T

at the top of my perl script. I then received the error

Too late for "-T" option

I then tried calling my perl script from a web page

action="myScript.pl -T"

but of course this didn't work either.

So, is Taint used out there? It is important to use? Is it costly? (will it slow down my script?)

If I should use it how do I do so? I'm calling the script from a web page.

Thanks for the help.

Reply With Quote
  #2  
Old July 19th, 2001, 12:38 PM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
It is important for security purposes. When the data is marked, the idea is that nothing else will use it.

The 'Too late for "-T" option is what happens when you run your script from the command line. If you want to do that, then remove the option from your shebang line and pass it in from your command line:
Code:
[prompt]$ perl -T filename.cgi


Otherwise, simply having it on your shebang line should allow you to call the script from a browser with taint checking enabled.
__________________
- dsb -
Perl Guy

Reply With Quote
  #3  
Old July 19th, 2001, 01:17 PM
lustyx lustyx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 25 lustyx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Actually I got the

Too late for "-T" option

error when I included -T on the shebang line.

#!/usr/bin/perl -T

I'm using Apache.

Reply With Quote
  #4  
Old July 19th, 2001, 03:20 PM
dsb dsb is offline
PerlGuy
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2001
Posts: 714 dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level)dsb User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 15 h 44 m 20 sec
Reputation Power: 36
Send a message via AIM to dsb
That's why I said remove it when you are running the script from the command line.

Leave it on the shebang line if you are calling it from your browser.

If you want to call your script from the command line do it like so:
Code:
$ perl -T script.cgi

and your shebang line should read:
Code:
#!/usr/bin/perl

Reply With Quote
  #5  
Old July 19th, 2001, 03:48 PM
lustyx lustyx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 25 lustyx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have never called it from the command line or intend to do so. I got the error while trying to call it from a web page NOT from the command line.

Reply With Quote
  #6  
Old July 19th, 2001, 06:16 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Perl or mod perl ?

Copied from :
http://www.perldoc.com/perl5.6/pod/...%20-T%20options

Code:
Too late for "-T" option 
(X) The #! line (or local equivalent) in a Perl script contains the -T option, but Perl was not invoked with -T in its argument list. 
This is an error because, by the time Perl discovers a -T in a script, it's too late to properly taint everything from the environment.
So Perl gives up. 



Therefore me guesses:

You may be using mod perl and it is invoked without the taint.
Once the she bang is processed the interpreter fails.


Look for perl and mod perl documentation for your version and
how to enable taint.

Hope this helps
__________________
Thanks

Foot in Mouth ver 1.2.5 Onion

Reply With Quote
  #7  
Old July 20th, 2001, 08:49 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Removing "-T" from the shebang line wouldn't be the best solution if you want to run a taint-checked perl script from the command line.

You can just run the script with the -T option enabled in your perl interpreter at compile time, thusly:

perl -T yourscript.pl

Taking taint out of your script is the wrong way to fix it. What it does is keep track of data that comes into the script and make sure you don't use it anywhere that you could compromise security without double-checking what's in the user submitted data. This is, undoubtedly, a good thing for a script to have, it's like a built-in, free, unblinking security audit!

Say you have a script that passes user-submitted data to a "whois" command on your server to allow your visitors to do a whois query. The code in your perl script MIGHT look like this:

my $output = `whois $userdata`;

Now say a malicious user types " & rm -Rf / " into the whois query. Without taint checking enabled in your script, this would just pass right through and delete everything owned by nobody (or whatever your webserver runs as). Same principle applies to a windows server too. Taint checking watches the data to make sure you don't send anything out before you've validated it. A Good Thing.

On the "too late for taint" error your getting from the browser: It does sound like mod_perl is handling the script. You should find out under what circumstances mod_perl is set up to be the handler: Usually for a specific extension or for files in a specific directory.

Good Luck!!

Reply With Quote
  #8  
Old July 20th, 2001, 09:47 AM
lustyx lustyx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 25 lustyx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Again, I'm not calling perl from the command line. Who does this anyway? I am invoking a Perl Script from a web browser by going to a http://www.mysite.myscript.pl

I'm using a local Apache web server and I'm NOT using mod_perl. I still get the "too late" error. Maybe I should wake up earlier in the morning :-)

My script looks like this...

#!/usr/bin/perl -T
require 5.003;

require "cgi-lib.pl";
require "file1.pl";
require "file2.pl";
require "file3.pl";
require "file4.pl";

Can anyone show me an example of using Taint. NOT FROM THE COMMAND LINE BUT FROM THE WEB INVOKING IT.

Thanks

Reply With Quote
  #9  
Old July 20th, 2001, 10:23 AM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
I think your answer is :

I agree you are not running this command line.


I just tried off the web :
Code:
#!c:/perl/bin/perl -Tw

print "Content-Type: text/html\n\n";


  $date ="2001-05-16";

  ($year,$month,$day)   = split(/-/, $date);
  
  print " Year   = $year\n";
  print " Month  = $month\n";
  print " Day    = $day\n";


And no error off the web.

but for the same file on command line:
Code:
C:\Program Files\Apache Group\Apache\cgi-bin>perl -c date.pl
Too late for "-T" option at date.pl line 1.


And :
Code:

C:\Program Files\Apache Group\Apache\cgi-bin>perl -Tc date.pl
date.pl syntax OK


Yeilds no error as the Taint is called first, even before perl looks at the shebang -T.


You have : require 5.003;

I have : perl, v5.6.0 built for MSWin32-x86-multi-thread.

So There must be a configuration where perl is being called without taint and then runs your script with a -T and complains
at this point.

Hope this gets you a little closer to the answer.

Reply With Quote
  #10  
Old July 20th, 2001, 10:47 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
Running a script from the command line is one of the absolute best ways to debug a script. If you develop CGIs without running them from the command line to test them, you are causing yourself much more work than needed.

I understood that you weren't running it from the command line. Without knowing your specific server information or the content of your specific scripts, it is impossible to help you beyond pointing you to documentation.

Good luck!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Taint and Too late for "-T" option


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway