Hacker News new | past | comments | ask | show | jobs | submit login

Here's one approach: http://blog.moertel.com/posts/2006-10-18-a-type-based-soluti...

Different languages (SQL, JS, HTML, Shell, Plaintext, etc.) are treated as different types. Language-specific functions only accept arguments of the relevant type (eg. shell_exec takes Shell, db_query takes SQL, etc.). User input is Plaintext (usually; sometimes it might be something more specific like BASE64).

Different languages can't be combined (eg. SQL can't be concatenated with Plaintext), but they can be converted down to Plaintext and Plaintext can be converted to any language via escaping functions. This avoids injection attacks, since the only way to please the type-checker is by escaping properly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: