Home > Security Tips > Web Security Advisor > Perl taint mode
Security Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

WEB SECURITY ADVISOR

Perl taint mode


Mike Chapple
04.08.2003
Rating: -4.80- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


One of the most important tasks a security administrator can perform is to ensure that all Web code on a system performs proper parameter checking to minimize the potential of catastrophic buffer-overflow vulnerabilities. In many development environments, this is a tedious process that places a heavy burden on the shoulders of already-overworked programmers. If your Web site contains a large base of existing code that has not been safety-checked, the security screening task might seem insurmountable. This same problem may arise when you wish to import someone else's code (such as that downloaded from a Web site) into your Web applications.

If those applications are written in Perl, there's a great way to ferret out these vulnerabilities -- the use of Perl's taint mode. When used in taint mode, the Perl interpreter assumes that all user input is "tainted" or potentially malicious and places restrictions on the actions that the script may perform on that input. The Perl interpreter may be invoked in taint mode using the following string:

#!/usr/local/bin/perl –T

(Note: the command above is used by Perl 5 on a Unix system. If you're using a different version of Perl or a different operating system, consult your documentation for the proper syntax.)

Perl handles tainted data using a special set of rules that limit the actions that may be performed on tainted data. For example, tainted data may not be used in a call to system(), eval(), exec(), open() or a number of other privileged functions. When the interpreter encounters an action that uses tainted data in a manner it considers unsafe, it simply halts execution with an error. It's then your responsibility to troubleshoot the code and determine what change(s) are necessary to make the code safe.

The most common fix to many taint mode errors is to untaint the user input using regular expressions that contain parentheses. (If you're not familiar with regular expressions, Steve Ramsay's Guide to Regular Expressions might come in handy.) Once you've performed this type of transformation, Perl assumes that you've checked for any malicious code and considers the user input safe. It's extremely important to recognize that this is a major assumption on Perl's part. If your regular expression does not adequately clear the vulnerability, the application may execute despite the fact that it is unsafe.

It's important that you don't view taint mode as a panacea for your application security needs. While it's true that taint mode will help prevent buffer-overflow vulnerabilities, it can not detect all possible forms of malicious code (SQL injections are a notable example). However, the use of this security technology can make great strides toward improving the coding practices of your internal developers and provide you with a sense of comfort when importing external code.

If you'd like to read more about taint mode and its operational details, you may wish to take a look at the CGI/Perl Taint Mode FAQ.

About the author
Mike Chapple, CISSP, currently serves as Chief Information Officer of the Brand Institute, a Miami-based marketing consultancy. He previously worked as an information security researcher for the U.S. National Security Agency. His publishing credits include the TICSA Training Guide from Que Publishing, the CISSP Study Guide from Sybex and the upcoming SANS GSEC Prep Guide from John Wiley. He's also the About.com Guide to Databases.


For more information, visit these resources:

Rate this Tip
To rate tips, you must be a member of SearchSecurity.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




BROWSE BY TAG
Web Security Advisor,   Application and Platform Security,   Software Development Methodology,   VIEW ALL TAGS

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Web Security Advisor
DNS rebinding defenses still necessary, thanks to Web 2.0
New defenses for automated SQL injection attacks
PCI compliance and Web applications: Code review or firewalls?
Worst practices: Bad security incidents to avoid
Web scanning and reporting best practices
Social networking Web site threats manageable with good enterprise policy
Enterprise security in 2008: Building trust into the application development process
PCI DSS Section 6: A plan for tackling application security
Making the case for Web application vulnerability scanners
Preparing for uniform resource identifier (URI) exploits

Software Development Methodology
How to detect software tampering
Developers Need Help with Security Errors
Does an EULA make it truly illegal to decompile software?
SQL injection continues to trouble firms, lead to breaches
IBM acquires Ounce Labs for source code analysis
Microsoft issues emergency Active Template Library updates
Software security threats and employee awareness training
Adobe patches ColdFusion vulnerability blocking website attack
nCircle statistics show rising Web application vulnerabilities
Common PCI questions: Web application firewalls or source code review?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
bypass  (SearchSecurity.com)
Common Weakness Enumeration  (SearchSecurity.com)
debugging  (SearchSoftwareQuality.com)
fuzz testing  (SearchSecurity.com)
heuristics  (SearchSoftwareQuality.com)
sandbox  (SearchSecurity.com)
threat modeling  (SearchSecurity.com)
trigraph  (SearchSecurity.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Research Solutions for Network Security, Access Control and Security Threats
TechTarget Security Media
Information Security View this month\\'s issue and subscribe today.
Information Security Decisions Apply online for free conference admission.
SearchSecurity.com
HomeNewsMagazineMultimediaWhite PapersLearningAdviceTopicsEventsAbout Us

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts