SQL Injection handling in Code Igniter |
[eluser]ReSTe[/eluser]
Good Morning, i'm a student @ Politecnico in Milan - Computer Science... i need to know for my 3rd year thesis project (i'll have discussion the 3rd of March ![]() thank you very much guys... greetings from Italy... Matteo. PS: Maximum support to this framework, it's fantastic ![]()
[eluser]uniacid[/eluser]
Hello, CI supports XSS filtering, if you read the user_guide completely you should have seen it talked about: Quote:XSS Filtering So you see you can have CI automatically filter all input in your config or apply the xss filter manually while doing validation on your input fields.
[eluser]ReSTe[/eluser]
yeah i know that and i've used XSS filtering in my web application. But also on the forum i read that i will prevent sql injection attacks with Active Records... so are you telling me that sql injection attacks are also prevented by Xss filtering? So if i put automatic Xss-filtering i will prevent sql injections attacks also if i'll not use Active Records? thank you for the reply ![]()
[eluser]uniacid[/eluser]
Bueno, maybe this will help with your sql injection question, CI handles all active records automatically escaping for you (assuming you're using the active record class). But you can escape manually like so also: Quote:Escaping Queries
[eluser]ReSTe[/eluser]
ok i understood. but how escape /escapestr/active records can prevent sql injections? Simply searching possible "attack-queries" analyzing input data? thank you!
[eluser]xwero[/eluser]
if you look at the Running Queries page of the user guide you see there are two methods for escaping input. You can find escape_str back in every database/drivers/*/*_driver file around line 246. If you look at the if else branch of the mysql_driver there are three native php you can use to escape input mysql_real_escape_string, mysql_escape_string and addslashes. Addslashes is the most invasive function because it places slashes where ever a meta-character (single quote, double quote and backward slash) is found. If you are not careful you end up with a string like : it\\\\\\'s me. Mysql_real_escape_string and mysql_escape_string are the smarter functions. mysql_escape_string is deprecated from 4.3.0 but it's still in for people that run lower versions. The mysql_real_escape_string takes the connection id as an argument to escape the string using the character set of the database. If you do a search for the escape methods your find them back in the AR class.
[eluser]Negligence[/eluser]
While on this topic, it would be nice to enforce (in the future) CI to use prepared statements and bindings, instead of using mysql_real_escape_string() (for MySQL) to handle injection concerns for all databases.
[eluser]adaxa[/eluser]
So, what is the conclusion ? If I use active records i`m safe against sql injections ?
[eluser]Molchy[/eluser]
Hi, I am creating my own cms system and found xss filtering as good codeigniter security. My question is: - I enable in config TRUE Then it automaticly detect eny post or get and filter it out ? But i don't use form helper so does it detect normal $_POST['some_data] ... Tnx |
Welcome Guest, Not a member yet? Register Sign In |