A Taint Mode for Python via a Library
Vulnerabilities in web applications present threats to on-line systems.
SQL injection and cross-site scripting attacks are among the most common threats
found nowadays. These attacks are often result of improper or none input validation.
To help discover such vulnerabilities,
popular web scripting languages like Perl, Ruby, PHP, and Python
provide taint analysis. Such analysis is
often implemented as an execution monitor, where the interpreter needs to
be adapted to provide a taint mode. However, modifying interpreters might be a
major task in its own right. In fact, it is very probably that new releases of
interpreters require to be adapted to provide a taint mode. Differently from previous
approaches, we show how to provide a taint analysis for Python via a library written
entirely in Python, and thus avoiding modifications in the interpreter. The concepts
of classes, decorators and dynamic dispatch makes our solution lightweight,
easy to use, and particularly neat. With minimal or none effort, the library can be
adapted to work with different Python interpreters.
The library can be downloaded here
Paper published at OWASP AppSec Research 2010, Sweden.