Monday, May 25, 2015

Web application security design considerations

  • ·         Development teams must take care to follow secured coding guidelines to ensure that data is kept private and confidential via encryption.
  •            Coding teams must also ensure that the data being passed into a web site will take a number of factors into consideration including how users or device are authenticated.
  •   Application should design by taking care of security considerations. To design the secure application; we have to take consideration of below things.
o   Authentication
o   Authorized access and access control
o   Data input checking and validation
o   Session management
o   Encryption
o   Auditing and logging

  • While design secure application various application vulnerabilities should take care like

o   Insecure direct object references
o   XSS (cross site scripting)
o   Cross-Site Request Forgery(CSRF)
o   Click-Jacking
o   SQL injection
  • Error & Exception handling should be done properly and they could display an appropriate message or take an appropriate course of action when error occurred in application
  • Taking consideration of Privilege escalation - means a user is gaining more rights than were intended within application.
o   Vertical Privilege Escalation: User is getting more permissions or rights than originally intended.
o   Horizontal Privilege Escalation: User authenticated to an application figures out a way to impersonate another user with equal security rights. 
  •   Fuzzing/Fault injection: In testing phase of application; we could feed an application random or unexpected data. The Reason, we would do this in testing is so that we can monitor that application and observe its results.
  •   Memory leaks, buffer overflows, and integer overflow should be handled properly to prevent damage of network security.
  •  Proper checks should be put in place by the application developer for Race conditions, resource exhaustion.
  • While working with web service; WS-security should be implemented to securely transmit from the client browses client-side to the web application or service running server-side. It is accomplished by transmission of data over HTTPS, encryption of data or using SAML token.
  •  Secure coding standards like OWASP should be used by developers to ensure secure of web application and it should be incorporated at every step of the System Development Life Cycle.
  • Specific application issues:
      • Session management
      • Http is session-less
      • Security tokens
      • HTTP cookies
      • Flash Locally Store
      • Improper storage of sensitive data- passwords ,key ,PKI certificates
      • Secure cookie storage and transmission

Monday, May 11, 2015

Hacking Web Application

Footprint Web Infrastructure
Web infrastructure Foot printing is the first step in web application hacking; it helps attackers to select victims and identify vulnerable web application
·         Server Discovery
·         Service Discovery
·         Server Identification
·         Hidden Content Discovery
1.       Server Discovery
Server Discovery gives information about the location of servers and ensures that the target server is alive on internet.
·         Whois Lookup
·         DNS Interrogation
·         Port Scanning
2.       Service Discovery:
Tools used for service discovery.
a.       Nmap
b.      NetsCan tools pro
c.       Sendcat Browser
3.       Server Identification/ Banner Grabbing
analyze the server response header fields to identify the make, model, and version of the web server software.
This information helps attackers to select the exploits from vulnerability database to attack a web server and applications.
Banner Grabbing Tools:

    •     telnet
    • NetCat
    •  ID Serve
    •  NetCraft
4.       Hidden Content Discovery
Discover the hidden content and functionality that is not reachable from the main visible content to exploit user privileges within the application.
a.       Web Spidering :web spidering automatically discover the hidden content and functionality by parsing HTML form and client-side Java-script requests and responses.

5. Web Application Hacking Methodology
    1. Footprint Web infrastructure:  It helps attackers to select victims and identity vulnerable web applications. It's include Server Discovery, Service Discovery, Server Identification, and Hidden Content Discover.
    2. Attack Web Servers:  Identify the web server environment, scan the server for known vulnerabilities by using various tools like Web Inspect, Nessus ,UrlScan, Nikto.
    3. Analyze web Applications:   Identify HTTP header parameters, URL encoding techniques by using tools like Burp Suite, HttPrint, Web Scarab, and OWASP Zed Attack Proxy.
    4. Attack Authentication mechanism: check weakness of authentication policy like failure to check password strength or insecure transportation of credentials.
    5. Attack Authorization Schemes: Attacker’s first access web applications using low privileged account and then escalate privileges to access protected resources.
    6. Attack Session Management Mechanism: by breaking session management attackers try to bypass the authentication controls and to impersonate privileged application users.
    7. Perform Injection Attacks: attackers supply malicious input to break down the application's normal flow.
    8. Attack Data Connectivity: attack includes connection string injection, Connection String Parameter Pollution, Connection Pool Dos
    9. Attack Web App Client: attack includes Cross-Site Scripting, Redirection Attacks, HTTP header Injection, Frame Injection, Request Forgery Attack, Session Fixation P
    10. Attack Web Services:  SOAP injection by manipulate SOAP requests.
  6] various tool used for web application hacking like Burp Site, Cookie Digger, and Web Scarab & Signification of encoding and different encoding schemes.


Sunday, May 10, 2015


First, you need to download the angular.intellisense.js file for Visual Studio and place it in the Program Files (x86)\Microsoft Visual Studio 12.0\JavaScript\References folder of your machine. Now open visual studio and have a look on intellisense support.
This support will work the same with any project that uses AngularJS, including Apache Cordova, ASP.NET MVC, ASP.NET WebForm, LightSwitch, Windows Store apps and any tagged with Angular JS, Intellisense, Jquery.

Thursday, April 23, 2015

Single Responsibility Principle In Detail

Single Responsibility Principle – is one of the SOLID principles defined by Rober.C.Martin. Principle says “Implementation (Class/ Function) should perform only one task or Implementation (Class/Function) should change for only one reason”.

So in simple word it says “Whatever developer implements (Class/Function) in code during development should perform only one task and developer should only have one reason to change implementation (Class/Function).”

Wrong interpretation of the Principle:

Most of developer interprets it as “Class should perform only one task”. But it’s not only class, function you implement in code during development should also need to perform only one task. So one should interpret it as “Implementation(Class/Function) should perform only one task”

Real Life Example of not following Single Responsibility Principle

What happens when one can do more than one tasks. Below is image example of it


One can able to perform multiple tasks there is no question in it, but it’s not going to provide quality /better output. So to get good quality/better output of work, one should do one task at time.

Example of not following Principle in Application Development

In programming i.e. during developing code as below Order class not following principle
Public class OrderManager
{ Public List<string> ValidateOrder() {  //Code for validation }
 Public bool SaveOrder(OrderInfo order) {  //Code for saving order }
 Public void NotifyCustomer() {  //Code for notification  }

Above order class having following responsibility
  1. ValidateOrder - Validating Order placed by customer and return error message if any
  2. SaveOrder – Saving Order placed by Customer and return true/false
  3. NotifyCustomer – Notify customer order is placed 

Method not following principle

Public int SumOfAllCustomerOrder(int customerId)
            int sum =0;
  var query= “Select * from order where customerid =” + customerid;;
           //query orders
          foreach(Order in OrderCollection)
  If(Order.Items.Count > 5)
             Sum += Order.Price;           
  return sum;

Above method having following responsibility
  1. Method first all the order
  2. It went through all order in collection and do some of that 

Following Single Responsibility Principle

To make class or function to following Single Responsibility Principle, divide responsibility by creating new classes or function

Public Class OrderValidator
   Public List<string> Validate(Order order) { //code for validation}
Public Class Notifier
   Public void Notify(string emailId) { //code for notification}
Public Class OrderManager
  Private readonly OrderValidator orderValidator;
  Private readonly Notifier notifier;
  Public OrderManager(OrderValidator oValidator, Notifier nFier)
 orderValidator = oValidator;
   notifier = nFier;
   Public bool SaveOrder(OrderInfo orderInfo)
     //Validate order
        //code for saving order //this might be call to repository to save order
        //notify after successful saving
   Public List GetOrders(int customerId) { //code for getting order by cusotmerid}

Above code shows the three classes which is having only single responsibility to perform.

For method it will be like
Public List GetOrder(int customerId)
            int sum =0;
  var query= “Select * from order where customerid =” + customerid;;
           //query orders
          return ordercollection;
Public int SumOfAllCustomerOrder(int customerId)
          var OrderCollection = GetOrder(customerId);
          foreach(Order in OrderCollection)
  If(Order.Items.Count > 5)
             Sum += Order.Price;           
  return sum;

Following Single Responsibility doesn’t mean one can create class with one method.

Disadvantage of not following Single Responsibility Principle

In programming if developer write a class/function that performs more than one task always cause problem in providing good quality. Following problems related to class perform more than one task 
  1. It’s very difficult for the other developer (i.e. who is not having any knowledge of class) to understand class/function.
  2. It’s difficult for the other developer to maintain the class/function or change the class/function.
  3. Writing test cases for the class/function also becomes difficult. 

How to Identify not following Single Responsibility Principle

  1. Try to write one line description of the class or method, if description contains word like (and, or, but, if). Example description of the class listed above where not following single resposiblity is: 
  2. “Order class that performs order saving, notification to customer and validate order”.
  3. Class constructor taking more than three argument or Method contains too many parameters.
  4. Class or Method is too long implementation.
  5. Class is low cohesive. Read more about cohesion :
Ref. From: Clean code – Robert .C. Martin