Pages

Wednesday, October 04, 2017

Case Study: Frys Electronics Web Portal - How Exactly *Not To Design* Password Change Component !

NOTE: The issue highlighted in this post is for educational purposes only.

Last weekend some electronic gadgets were ordered from the Fry’s electronic store at (https://shop3.frys.com//wf?a=SIGN_IN,w=CHECKOUT=1). An account was created and after interacting with the web application for 10 minutes, a number of security issues were identified in the Fry's online portal due to insecure design and coding practices. The idea behind this post is to educate application developers on how to design secure components. It is just something I came across and decided to share.

In this post, the insecure design of "Password Change Component" has been presented. The user should take the highlighted issue in consideration while accessing the online web portal.

Insecure Design - Password Change Component


It has been noticed that the "Password Change Component" used by Fry's online portal is designed insecurely. A secure design practice involves that application component should ask for the “old password” from the user before the new password is supplied and verified accordingly. This is required by the application to perform additional password verification to determine whether the HTTP request is issued by the legitimate user or not. If the “old password” is required and validated, it enhances the design and robustness of the system. Further, the component does not even enforce complex password requirements. For examples:- (1) the last used password can be reset again as new password, (2) minimum password length enforced is 6 characters. Many other variables in the password complexity requirements are not met either.



The issue does not end here. The flaw highlighted above is a basic design fallacy. Let's see how multiple vulnerabilities can be chained together.

Cross-site Request Forgery - Password Change Component


The password change component (mod_exist_password.php) is vulnerable to Cross-site Request Forgery (CSRF) attack. Let's look into a number of design checks:
  1. The application does not implement origin verification checks either via unique tokens or "Origin" header. As a result, HTTP POST requests are accepted by application without any token verification and validation.
  2. The password change component does not explicitly enforce the verification of “old password”.
  3. The application does not even perform a basic "HTTP Referer" verification check on the server side.

It means the attacker can easily author a CSRF exploit to change the password on the fly which ultimately results in the account hijacking.

Let's validate this.

The HTTP POST request is taken from the CSRF exploit drafted as a Proof-of-Concept (PoC). It can be deciphered that the HTTP POST request does not carry any token as a part of request header or the body header. In addition, the ‘Referer” header is also removed from the HTTP request.  General, “Referer” validation on the server side is treated as a defense against CSRF attack. In this case, no "Referer" validation is performed either.


POST /wf HTTP/1.1
Host: shop3.frys.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0
Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Content-Type: application/x-www-form-urlencoded
Content-Length: 169
Cookie: ID_KOT=987123654; J1_USER_ID=[Removed]; BTgroup=B; FSERVERID=s107
Connection: close
Upgrade-Insecure-Requests: 1

r=misc,c=new_password=[Truncated]&r=misc,c=new_password_again=[Truncated]&a=MODIFY_PASSWORD,w=ACCTMAINT=&button.x=21&button.y=9


HTTP/1.1 200 OK
Date: [Truncated]
Server: Apache
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Cache-Control: max-age=0
Expires: [Truncated]
Vary: Accept-Encoding
Connection: close
Content-Type: text/html;charset=ISO-8859-1
Via: 1.1 sjc1-10
Content-Length: 13877

By simply sending the HTTP POST request to the server via a CSRF exploit when the user is logged-in the session, the attacker can change the end-user password.


Disclosure:

Frys was contacted via Twitter and via LinkedIn as no direct security contact information was available. No response was received so the details have been released.



Saturday, March 07, 2015

TCPExtract (or TCPxtract) Installation Discrepancies on Mac - Step-by-Step !

TCPExtract (or TCPxtract) is used for extracting specific set of files from the PCAPs by looking into TCP sessions. During object extraction or file analysis in the network traffic, this tool is used. Installation of this tool on the Mac is tricky and several issues need to be debugged before it installs appropriately. I spent sometime on this tool during installation and  thought to share the complete solution. The step by step approach installation steps are discussed below:

My Mac is configured with brew (you can repeat the same steps with ports also).

1. you need to install libnet : brew install libnet.
2. you need to install libnids : brew install libnids
3. you need to install pynids : wget https://jon.oberheide.org/pynids/downloads/pynids-0.6.1.tar.gz --no-check-certificate
4. Download tcpxtract from source forge:  http://tcpxtract.sourceforge.net/
  • extract the tcpxtract files into a folder using - tar zxvf tcpxtract.tar.xz
  • ./configure
  • Before doing make (try one of the steps)
    • cd /usr/lib  and sudo ln -s libl.a libfl.a (Flex issue, need to link the libraries - http://www.linuxfromscratch.org/lfs/view/6.4/chapter06/flex.html)
    • add ldl flag after object files : gcc -D_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g -O2   -o tcpxtract  tcpxtract.o sessionlist.o util.o confy.o confl.o conf.o search.o extract.o  -lpcap -lfl
  • make
  • sudo make install
How it goes:

$ ./tcpxtract -f ~/malware_pcaps_repository/botnet_cc_pcaps/Keylogger_Limlspy.A.pcap -o dump/
Found file of type "html" in session [50.116.98.95:20480 -> 172.31.2.41:14528], exporting to dump/00000001.html
Found file of type "png" in session [50.116.98.95:20480 -> 172.31.2.41:14528], exporting to dump/00000002.png
Found file of type "html" in session [50.116.98.95:20480 -> 172.31.2.41:14272], exporting to dump/00000003.html
Found file of type "png" in session [50.116.98.95:20480 -> 172.31.2.41:14272], exporting to dump/00000004.png

You can also check extending TCPExtract in Python:

1. http://nullege.com/codes/search/TcpExtract.FileExtractor
2. Another solution : http://computer.forensikblog.de/en/2005/10/tcpxtract-version-10.html