lecture in color

Security and Patterns

Tainting

Algebra of tainting.

Untainting and validation

What you can't do with tainted data

Examples (from Chapter 23)

 $arg = shift (@ARGV);        # tainted
 $hid = "$arg, 'bar'";        # result is tainted.
 $path = $ENV{'PATH'};        # tainted
 $mine = 'abc';               # not tainted

 system "echo $mine";         # unsafe, $ENV{'PATH'} and others tainted
 system "echo $arg";          # unsafe, $arg tainted
 system "echo", $arg;         # special form ignores tainting of $arg
 system "echo $hid";          # unsafe: $hid and $ENV{'PATH'} tainted
 
 $oldpath = $ENV{'PATH'};     # tainted
 $ENV{'PATH'} = '/bin:/usr/bin'; # untainted 
 $newpath = $ENV{'PATH'};     # untainted
 
 delete @ENV(qw(IFS CDPATH ENV BASH_ENV)); # dump other unsafe values 
 system "echo $mine";         # OK, once $ENV{'PATH'} is set. 
 system "echo $hid";          # unsafe: command argument is tainted
 
 open (OOF, "< $arg");        # read-only access to tainted filename OK
 open (OOF, "> $arg");        # unsafe: write to tainted filename
 open (OOF, "echo $arg|");    # unsafe: tainted $arg
 
 $shout = `echo $arg`;        # unsafe: $arg is tainted. 
 $shout2 = `echo $mine`;      # safe, but results of `` are tainted!
 $shout3 = `echo $shout2`;    # unsafe: $shout2 is tainted!

Tainting operations

Some marvelous ideas

A not-so-marvelous idea

How tainting evolved:

Tainting and RE's

Review of RE's

A warning

Delimiters

Documenting patterns

Match Modifiers

Replacement Modifiers

Patterns starting with \

Special patterns corresponding to character classes:

The pattern "engine"

Basics of engine matching

Matching and backtracking

Basic matching algorithm:

Massless patterns that control pattern reading

Massless assertions for lookahead and lookbehind

Quantifiers

Stupid pattern tricks.

Pattern homomorphisms

Two things to remember


lecture in color


downloaded on Nov-23-2009 04:49:19 PM,
was last modified on Dec-31-1969 07:00:00 PM.

All lecture note content is copyright 2003 by
Alva L. Couch, Computer Science, Tufts University
(couch at cs dot tufts dot edu)