security riddle with $SAFE and untainted strings

P

Phlip

Rubies:

The user gives me a string, inside user_string.

I set up an object model in memory, and eval(user_string). The user_string
contains code to work that object model.

After the call, I want to call system(cmd), where cmd is untainted and
clean.

Now I want to secure that string, so the user may not put
'system("whatever")' inside that string.

So try this:

user_string = "$SAFE = 1\n" + user_string
eval(user_string)

That fails to defend us from system("whatever"), because "whatever" is seen
as an untainted literal, not a tainted element of the greater string we are
inside of.

Raising $SAFE to 2 throttles the safe system() call after my eval().

How to make this situation safe?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top