Well, there you are. When the program needs taint checking, treat
*every* content that doesn't come from the source as suspect.
Yes, every content from untrusted sources is suspect, but not every
operation on suspect content is unsafe. I think I (and probably Randal)
misunderstood your question "Why does $method need special attention?"
To recap, the code in question was $obj->$method(@args).
I understood your question as "why does calling a method with a user
supplied name need special attention?" and the reason has been explained
by Randal: You cannot call only methods of $obj's class but arbitrary
objects that way. So if you want to restrict the user to call only
$obj's class you have to check $method before the call.
OTOH, calling a method with unchecked arguments is not inherently
unsafe: The method can (and should) check the arguments.
This is exactly what taint checking tries to do, though not always
perfectly as your example below (now snipped) shows. Thus the problem
can be reduced to deciding whether a program needs taint checking.
I was assuming a context which needs taint checking. Otherwise its
perfectly fine if you can call arbirtrary methods.
I don't have a pat answer to that, though I think programmers develop
a reliable intuition in that respect. The question can't be decided
by looking at the program alone.
Right. The question can be decided by looking at the context in which
the program is executed: If the entity running the program does not
completely trust the entities supplying the input data, the data has to
be checked (that doesn't mean taint checking is needed: Taint checking
is just a tool to help the programmer to find places where he needs to
add checks).
Examples:
* A web server: Everybody can send arbitrary data to it. Clearly it
needs to check its input.
* A script invoked by a user on data which he has written himself: Input
checking should not be necessary, the user presumably trusts himself.
In reality, some input checking is still necessary, because the user
may have violated some assumptions that the programmer made: For
example, the programmer may have foolishly assumed that a filename
doesn't contain spaces. If he did that, he'd better check it, because
users will create filenames with spaces if they can.
* A script invoked by a user on data which he obtained from an untrusted
source (e.g., downloaded from a website, or received via email): Input
checking is necessary.
Which checks are necessary also depends on context. For simple
hp