Wednesday, 24 January 2018

CROSS-SITE REQUEST FORGERY: HIJACKING USER ACCOUNTS


Week Eleven ↓


Otherwise called Sea-Surf, Session Riding, XSRF or CSRF, this attack vector enables attackers to force an unsuspecting user’s browser to send unintended malicious requests by exploiting web application vulnerabilities (Oriyano, 2016). The attacker is able to get into an active session with a trusted site/application while the victim visits a malicious site, and HTTP requests are injected to perform an attack. This pervasive attack has been ranked in OWASP’s Top 10 list of regularly exploited attacks (Acunetix, 2018). Generally, this attack requires the victim to be authenticated and the level of authorization would determine the severity of the attack. This vulnerability is being leveraged upon because web applications would always trust users once their identity is confirmed.
In executing CSRF attacks, an attacker would need to build an exploit URL or script. The victim can then be tricked into executing the script/clicking the link via a technique like social engineering. The targeted web application receives a legitimate looking request from the victim’s browser after the request is sent by the script. Using this crafted request, the attacker can create custom actions to be performed as though it were the victim. To achieve this, a GET or POST request could be used. An example of CSRF attack is seen in 2008’s uTorrent attack where GET requests were used to download malware on a large scale.

CSRF using GET request

When applications are designed to use GET requests to transfer parameter and execute actions, a request could be crafted for a $200 transfer to an attacker’s account as shown below:
GET http://netbank.com/transfer.do?acct=Hacker&amount;=$200 HTTP/1.1
Embedding this request into a seemingly innocent hyperlink would look like:
<a href="http://netbank.com/transfer.do?acct=Hacker&amount;=$200">Read more!</a>


CSRF using POST request

The dichotomy between GET and POST methods is in the method used to execute the attack. For applications that use POST requests, standard “a”, “href” or “img” tags cannot be used to frame malicious requests (Incapsula, 2018). Attackers could however deliver this request using <form> tag with automatic execution of the embedded JavaScript giving a form as shown below.

 <body onload="document.forms[0].submit()">
   <form action="http://netbank.com/transfer.do" method="POST">
     <input type="hidden" name="acct" value="Hacker"/>
     <input type="hidden" name="amount" value="$200"/>
     <input type="submit" value="View my pictures!"/>
   </form>
 </body>

This disguised exploit URL/code can be delivered to a victim using techniques that would encourage a victim to interact with it.

Mitigation

Anti-CSRF tokens can be used to prevent CSRF attacks. This mechanism associates challenge tokens with each request and appends them with the user’s session. These tokens are also called Synchronizer tokens. This way, an attacker crafting a request will need to guess the anti-CSRF token; for a victim to be successfully tricked into sending a request (Veracode, 2018).

Double submission of cookies can also be used to thwart CSRF attacks. In this method, random tokens are assigned to both a cookie and a request parameter; access is then granted to the application upon verifying that these tokens match (Oriyano, 2016).


References

Sean-Philip Oriyano. (April, 2016). CEH v9: Certified Ethical Hacker Version 9 Study Guide, Edition 3.

Acunetix. 2018. CSRF Attacks, XSRF or Sea-Surf. Retrieved from https://www.acunetix.com/websitesecurity/csrf-attacks/

Veracode. 2018. Cross-Site Request Forgery Guide: Learn All About CSRF Attacks and CSRF Protection. Retrieved from https://www.veracode.com/security/csrf

Incapsula. 2018. Cross Site Request Forgery (CSRF) Attack. Retrieved from https://www.incapsula.com/web-application-security/csrf-cross-site-request-forgery.html


Video Credit: Tech4Abhi. August 19, 2017

Wednesday, 17 January 2018

TCP SESSION HIJACKING: TELNET DEMO USING SHIJACK



Week Ten ↓

Some Internet protocols can be hijacked on a network level. TCP/IP hijacking helps to do this by bypassing the password authentication at the start of the session. The attacker takes advantage of a genuinely established network connection by an authorized user. One of the tools used for TCP session hijacking is “Shijack”. Let’s see how to hijack a telnet session.
At the beginning of the session, the three-way handshake occurs. Hosts are also discovered and the transmission over the network is monitored. The right sequence number is needed for a session to be hijacked by an attacker (Cheese, 2010). To achieve this, the network must be sniffed. Sequence numbers could be guessed, but since its 32 bits giving about 4.3 billion possibilities, this is not feasible.
Ettercap or arpspoof (on command line) uses ARP poisoning to create packets intended for the server for a Man-in-the-Middle (MiTM) attack. The attacker can then analyze packets using sniffing tools like Wireshark, and the hijacked telnet connection information can be seen. Sequel to this, the command below can be used to hijack the connection using "Shijack" for the scenario described in what follows.


root:/home/root/hijack# ./shijack eth0 192.168.0.100 53517 192.168.0.200 23



When the tool runs, another packet is created and sent to the server in an attempt to get a working sequence number. The server receives this, thinking it is legitimate and increases the expected sequence number for the next packet. When the legitimate client sends his packet, it is dropped by the server and client connection is lost. The hijack is done automatically, and we can now remotely communicate with the server through the pre-established session.
        
Mitigation 

Encrypted protocols should be used to replace “clear-text” protocols as all unencrypted sessions are vulnerable to TCP/IP session hijacking. Multi-Factor authentication techniques could also provide an extra level of security against these attacks (Oriyano, 2016).


References

Sean-Philip Oriyano. (April, 2016). CEH v9: Certified Ethical Hacker Version 9 Study Guide, Edition 3.
Cheese. (October, 2010). TCP Session Hijacking. Retrieved from https://www.exploit-db.com/papers/13587/
 
Video Credit: Jenil Jain. February 24, 2016

Friday, 12 January 2018

CROSS-SITE SCRIPTING: SESSION ID THEFT




Week Nine ↓
 Popularly known as “XSS” or “CSS” attacks, this application-level session hijacking attack is used to gain unauthorized access via client-side scripts. This is achieved by exploiting vulnerabilities in web applications with dynamically generated web pages. One of such vulnerabilities is unvalidated input where a client input is not validated before being processed by a web application and backend server (Oriyano, 2016). An attacker can exploit this flaw to perform a Cross-site scripting attack. An attacker could achieve this by injecting malicious JavaScript, VBScript, HTML, ActiveX requests to be executed. The crafted link then runs and completes the instructions made by the attacker. Some common motives of XSS attacks include; data theft, redirecting to a malicious server, exploiting user privileges, interfering with session information.
 
XSS attacks come in two main forms presented below:

Stored XSS attacks: In these attacks, web applications allow attackers store data on target servers, comment fields, message forum. “Once this happens, their data
will be part of the site, and when a subsequent visitor comes to the site, they
inadvertently run the same data” (Oriyano, 2016). This type of XSS attacks are also called Persistent or Type-I XSS attacks.

Reflected XSS attacks: Here, Injected script is bounced or reflected off a webserver as an error message, search result or some other response. The attack is done via another route which could be via email or some other website. A browser executable code is injected within a single HTTP response upon clicking a link. The injected code travels to the vulnerable web site and the attack is reflected to the user’s browser, the code which reflects the attack back to the user’s browser is executed. This type of XSS attacks are also called Non-Persistent or Type-II XSS. Reflected XSS attacks are relatively easier to carry out.
Xssed.com is an online archive of VSS vulnerable websites.

Countermeasures

All cookies, headers, form fields query string and other parameters should be validated against a specification of some sort;
Web application firewalls should be used to block execution of malicious script;
XSS attacks are not dependent on HTTPS/HTTP connections, in essence, trust no website;
Test for XSS flaws in applications before they are rolled out;
Scripts could be signed using asymmetric cryptographic keys to ascertain the authenticity of the script.



REFERENCE

Sean-Philip Oriyano. (April, 2016). CEH v9: Certified Ethical Hacker Version 9 Study Guide, Edition 3.


Video Credit: Danscourses. Sept 28, 2012