This paper especially pinpoints the poor practice of cryptography in a URL that is typically implemented to encrypt sensitive data in a website URL in the form of a query string that is transmited across networks. A website usually can be compromised or such subtle information (Query String) can be disclosed by exploiting this vulnerability. This article demonstrates with a real time scenario where the developers are committing mistakes by practicing weak cryptographic methods inadvertently, to protect sensitive data in the URL using public key cryptography and salts. Finally, this article is addressing the various issues in terms of disadvantages that occurr when applying weak cryptography algorithm, moreover suggesting various alternative methods to secure URL data properly.
Introduction
Securing a URL is the process of concealing or encrypting a parameterized Query String based URL such as www.xyz.com/login.aspx?uid=ajay&pawd=09876 by applying complex C# cryptography. The moment a URL is requested from the server, internally we determine the required parameters, then encrypt Query String values where the sensitive information is typically located and redirect them to another source for further processing and then decrypt the encrypted Query-String values there, if it is required. In this entire process, the URL always shows some bizarre values in the Query String and is intact from the malicious hacker eyes because it is very hard for him to determine exactly what is travelling across the network via query string. The idea of Query String encryption protects a web page from MITM or session hijacking attacks at some extent. This mechanism is somewhat similar to URL rewriting where a verbose URL is flashing in the address in spite of an actual web page address where the Query String parameters are still located. The hacker never anticipates that the requested URL would contain Query String values.
Susceptible URL
The following ASP.NET page, that simply authenticates users on behalf of the correct user id and password, is created to demonstrate the real concept behind the disclosing “sensitive data via URL” incident. This page stipulates both facilities to log-in, either plain text or secure sign-in.
When the user enters his credentials and proceeds with the simple plan text mechanism (without checking Secure Sign-in), its login information's user name and password travelled through the Query String to the redirected page and is literally displayed in the URL address bar as below:
Though optionally, we are showing user credential information on the redirected Welcome.aspx page but here is a catch in the address bar. There might be a possibility that a malicious hacker could intercept the traffic and can easily use the user information since such data is travelling or located in the query string in clear text. Hence, this is the crucial vulnerability that we will pinpoint in this paper.
Securing Sensitive Data
This section describes the process of encrypting the data residing in the query string. The Login form interface is designed such that if the user enables the Secure Sign-in check box, the encryption algorithm would be activated behind the scenes and it is hard to anticipate the ciphered data that travels across the webpages in the query string.
As the user proceeds by enabling the Secure Sign-in option, the following piece of code is activated and encrypts the sensitive portion of the URL. Here, the Encryt() method takes the user name and password from the login form and implements the ciphering. Later, the user will be redirected to the welcome page via the query string mechanism as in the following:
- string usr = HttpUtility.UrlEncode(Encrypt(txtUser.Text.Trim()));
- string pwd = HttpUtility.UrlEncode(Encrypt(txtPwd.Text.Trim()));
- Response.Redirect(string.Format("~/welcome.aspx?usrname={0}&password={1}",
- usr, pwd));
Query String Encryption
Here in this code segment, the real encryption of the query string parameters will happen in the Encrypt() method implementation that is called when the user clicks the Sign-In button. Here, the Query String values will be first encrypted using the AES Symmetric key algorithm encoding and then will be sent to the welcome page where the Query String values will be first deciphered and then decrypted using the AES Algorithm again using the Symmetric key that was used for encryption earlier on the Login page.
As we know, the hashing algorithm can be implemented either by Symmetric key or Asymmetric key. In Asymmetric key cryptography, two keys are employed for encryption and decryption but in this tutorial we are relying on a Symmetric key where a single key is sufficient for both ciphering and deciphering the sensitive data.
Generating Secure Key (Symmetric)
The symmetric key could be anything, it just depends on the developer's discretion. Symmetric key algorithms are very effective for processing extensive amounts of data and is less intensive than asymmetric encryption algorithms computationally. Hence, we hardcoded the Symmetric key as “ajaykumar007” that does both of the functions as in the following:
- string password = "ajaykumar007";
- static String CreateKey(int numBytes)
- {
- RNGCryptoServiceProvider rnd = new RNGCryptoServiceProvider();
- byte[] b = new byte[numBytes];
- rnd.GetBytes(b);
- return BytesToHexString(b);
- }
- static String BytesToHexString(byte[] bytes)
- {
- StringBuilder hexString = new StringBuilder(64);
- for (int counter = 0; counter < bytes.Length; counter++)
- {
- hexString.Append(String.Format("{0:X2}", bytes[counter]));
- }
- return hexString.ToString();
- }




Poornima MPosted Nov 4, 2017, 1:38 AM
Sir how to see the password using GET method but it is not shown in url
Kuppurasu NagarajPosted Apr 11, 2016, 1:53 PM
Nice Sharing
Sonu ChaudharyPosted Mar 7, 2016, 11:58 AM
good article
Ajay YadavPosted Nov 24, 2014, 3:53 AM
Thank you all
Manish Kumar ChoudharyPosted Nov 24, 2014, 2:36 AM
great Ajay Yadav sir..
Vipin TyagiPosted Nov 23, 2014, 11:10 PM
Awesome Sir Awesome
Gaurav Kumar AroraPosted Nov 23, 2014, 9:43 AM
an awesome description on secrurity