Hi,
I am again here to share something with you that may be you know, but still I would like to rate myself :).
So please be ready for my one more boring(don't think so) topic "Salesforce applications with security: SOQL Injection".
This time SOQL injection. So SOQL is a type of vaccine for human body, injects when you really feels weak(Sorry :), No more joke).
It's a code injection technique that exploits a Security vulnerability.
Let me be more specific, Suppose you have a search form and instead of typing a valid search parameter, User types something invalid text and that can make your SOQL query invalid and expose the unexpected result.
This situation occurs when user input is not filtered for escape characters.
let's have a pictorial look :
It's a SQL example , but describe the SOQL injection as well in a good manner.
So here you can see that. In the User id field once user puts a invalid parameter and goes to the controller and form a query that results in a invalid login.
The worst scenario could be if resultant data from a query supposed to be deleted.
let's have one more quick example for this :
I have a case where I want to delete the Account based on name entered in the input name field on page.
Implementation can be like this :
List<Account> listAccount = Database.query('Select id from Account where Name = \'' + nameField + '\' ');
delete listAccount;
It works great with a valid value.
Now it can be worst if value of nameField is provided like :
nameField = \' OR Id != null OR Type != \'
So once the action will be performed, this will be bind-up with the query and resultant query will be like this :
List<Account> listAccount = Database.query('Select id from Account where Name = \'\'\' OR ID != null OR Type != \'\' ');
delete listAccount;
So hopefully , you can see the monster here. It will delete the entire database for account records.
Salesforce provides escape functions to get rid from SOQL injection.
Solution can be one of the followings:
I hope, this post helps you to get a basic understanding of SOQL injection.
Now I am going to finish this, as If I didn't you guys will gone sleep.
So topic ends, party time ....................
Will be back very soon with something new :).
I am again here to share something with you that may be you know, but still I would like to rate myself :).
So please be ready for my one more boring(don't think so) topic "Salesforce applications with security: SOQL Injection".
This time SOQL injection. So SOQL is a type of vaccine for human body, injects when you really feels weak(Sorry :), No more joke).
It's a code injection technique that exploits a Security vulnerability.
Let me be more specific, Suppose you have a search form and instead of typing a valid search parameter, User types something invalid text and that can make your SOQL query invalid and expose the unexpected result.
This situation occurs when user input is not filtered for escape characters.
let's have a pictorial look :
It's a SQL example , but describe the SOQL injection as well in a good manner.
So here you can see that. In the User id field once user puts a invalid parameter and goes to the controller and form a query that results in a invalid login.
The worst scenario could be if resultant data from a query supposed to be deleted.
let's have one more quick example for this :
I have a case where I want to delete the Account based on name entered in the input name field on page.
Implementation can be like this :
List<Account> listAccount = Database.query('Select id from Account where Name = \'' + nameField + '\' ');
delete listAccount;
It works great with a valid value.
Now it can be worst if value of nameField is provided like :
nameField = \' OR Id != null OR Type != \'
So once the action will be performed, this will be bind-up with the query and resultant query will be like this :
List<Account> listAccount = Database.query('Select id from Account where Name = \'\'\' OR ID != null OR Type != \'\' ');
delete listAccount;
So hopefully , you can see the monster here. It will delete the entire database for account records.
Salesforce provides escape functions to get rid from SOQL injection.
Solution can be one of the followings:
- Try to use STATIC queries as much as possible. STATIC query has inbuilt escaping.
- If dynamic query is needed , then all the search parameters should use escapeSingleQuotes() function.like
List<Account> listAccount = Database.query('Select id from Account where Name = \'' + String.escapeSingleQuotes(nameField) + '\' ');
I hope, this post helps you to get a basic understanding of SOQL injection.
Now I am going to finish this, as If I didn't you guys will gone sleep.
So topic ends, party time ....................
Will be back very soon with something new :).
Nice idea actually...good one. Its better to be safe than sorry.
ReplyDeletegood post it helps me to understand basic logic
ReplyDeleteThank You ! :)
ReplyDeletealthough used escapeSingleQuotes ...sql injection issue is not resolved..
ReplyDeleteIt's odd. What issue you are still facing ?
Deletenice post
ReplyDeleteNot working,I used
ReplyDeleteString fieldName=name;
List accountList = (List)Database.query('Select Id,Name FROM Account WHERE Name =:fieldName');
its working and variable name I am passing as parameter to the method which is account name
ReplyDeleteHai,
ReplyDeleteFor more information on SQL Injection attacks see:
http://www.owasp.org/index.php/SQL_injection
http://www.owasp.org/index.php/Blind_SQL_Injection
http://www.owasp.org/index.php/Guide_to_SQL_Injection
http://www.google.com/search?q=sql+injection
salesforce training in Chennai
i also try escapeSingleQuotes but not work for me either anyone have a solution.please post final solution.
ReplyDeleteNice article. I liked very much. All the informations given by you are really helpful for my research. keep on posting your views.
ReplyDeleteSalesforce Training in Chennai
German Classes in Chennai
Salesforce Training Chennai
Salesforce Administrator 201 Training in Chennai
German Training Chennai
German Training Centers in Chennai
I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteAdvanced AWS Training in Bangalore | Best Amazon Web Services Training Institute in Bangalore
Advanced AWS Training Institute in Pune | Best Amazon Web Services Training Institute in Pune
Advanced AWS Online Training Institute in india | Best Online AWS Certification Course in india
Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
ReplyDeletebest rpa training in bangalore
rpa training in pune | rpa course in bangalore
RPA training in bangalore
rpa training in chennai
Wow it is really wonderful and awesome thus it is veWow, it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot.
ReplyDeletebest sap oracle cloud training
best sap oracle cloud education & cerification support
best sap oracle cloud training cost
best sap oracle cloud careers
best sap oracle cloud erp education
best sap oracle cloud courses
best sap oracle cloud training institute
best sap oracle cloud course in bangalore marathahalli
btm layout india
My brother recommended I migh like this website. He was totally right.
ReplyDeleteThis post truly madee my day. You can not imagine just how much time I had spent for this
info! Thanks!
Automated Forex Trading : exness login Is An Automated Forex Investing Software. It Is An Algorithmic Trading Software That Provides Automated Forex Trading Signals.
ReplyDeleteUşak
ReplyDeleteAnkara
Adıyaman
Hatay
Şırnak
HDY3O
E1365
ReplyDeleteErzurum Parça Eşya Taşıma
Kastamonu Evden Eve Nakliyat
Bingöl Parça Eşya Taşıma
Yozgat Lojistik
Bartın Lojistik
6B8BC
ReplyDeleteDüzce Evden Eve Nakliyat
Çanakkale Lojistik
Kütahya Lojistik
Aksaray Lojistik
Çorum Lojistik
7F1C1
ReplyDeleteMuğla Evden Eve Nakliyat
Tekirdağ Fayans Ustası
Kastamonu Evden Eve Nakliyat
Trabzon Evden Eve Nakliyat
Ordu Evden Eve Nakliyat
Rize Evden Eve Nakliyat
Silivri Fayans Ustası
order halotestin
Coin Nedir
65BA3
ReplyDeleteArtvin Parça Eşya Taşıma
İzmir Şehir İçi Nakliyat
Gümüşhane Evden Eve Nakliyat
Bayburt Evden Eve Nakliyat
Uşak Parça Eşya Taşıma
Pursaklar Fayans Ustası
Ağrı Şehir İçi Nakliyat
Nevşehir Şehirler Arası Nakliyat
Antalya Parça Eşya Taşıma
94B83
ReplyDeletesteroids for sale
buy anapolon oxymetholone
primobolan for sale
Çerkezköy Evden Eve Nakliyat
Bitlis Evden Eve Nakliyat
Kocaeli Evden Eve Nakliyat
Kilis Evden Eve Nakliyat
order winstrol stanozolol
İstanbul Evden Eve Nakliyat
شركة صيانة خزانات MY1ZpcWRBr
ReplyDeleteعزل اسطح بالجبيل wZJamRh2Pj
ReplyDeleteافضل شركة تسليك مجاري بالاحساء vb5gWMUfwl
ReplyDeleteشركة مكافحة حشرات بابها 1NMTLXkNuG
ReplyDeleteشركة مكافحة الصراصير بالاحساء nFZVaTpox5
ReplyDelete