Core Defences Mechanism in Web Applications (original) (raw)

Last Updated : 30 Sep, 2022

We divide core defences in web applications into three areas: Handling User Access, Handling User Input, and Handling Attackers. These are explained as following below.**1. Handling User Access:**First task is to handle access according to user (admin user, anonymous user, normal user). Most web applications handle access using a trio (I named it as ASA) of interrelated security mechanisms: Authentication, Session management, and Access control are as explained below.

  1. **Authentication -**Username and password mechanism to check validity of user or anonymous user is the basic one. Nowadays, even more advanced mechanisms like two step verification are also implemented. So, hackers are always check these mechanism to defects.Brute force is the most common one. Limitations and input validations must be applied to these inputs to protect the basic functionality of the application.

  2. **Session management -**After, user passed the first step of authentication it may have to manage and provide access management, which is mostly done by token mechanism. The main areas of vulnerability arise from defects in how tokens are generated, enabling an attacker to guess the tokens issued to other users, and defects in how tokens are handled, enabling an attacker to capture other users’ tokens. So, programmer can implement token validity time check and difficult encrypted tokens which are not easily guessed by an attacker .

  3. **Access Control -**On the basis of received credentials application decided the level of access and due to complex nature these mechanism are often defective. Developers often make ? awed assumptions about how users will interact with the application and frequently make oversights by omitting access control checks from some application functions. So, provide proper mechanism.

**2. Handling User Input:**Mostly flaws are found in input handling of an application. Any unwanted input may even lead to data breach by SQL injection or Token loose by stored XSS and many more attacks may in play and harm your application. So, it becomes very necessary to make these mechanism strong. User input can be user-name, comments, search, forms, sometimes cookies are also used.**Approaches to handle User Input -**We can not guess user mind or methodology while inputting. So, we should use approach will "RKB" method which is "Reject Known Bad".

  1. If SELECT is blocked, try SeLeCt
  2. If or 1=1-- is blocked, try or 2=2--
  3. If alert(‘xss’) is blocked, try prompt(‘xss’)
    Filters designed to block specific keywords can be bypassed by using nonstandard characters between expressions to disrupt the tokenizing performed by the application. For example:
    SELECT/foo/username, password/foo/FROM/foo/users
    NULL byte bypassing example. For example:
    %00alert(1)

**3. Handling Attackers:**We must consider these points while handling errors: Handling errors, Maintaining audit logs, Alerting administrators, and Reacting to attacks are explained as following below.

  1. **Handling Error -**In short term attackers first trying to collect information about application. So, all the error mechanisms in application must not provide any descriptive, i.e., it must not leak any information about databases, system architecture, or path details etc.

  2. **Maintaining Audit -**Audit logs are important while investigate events such an incident, effective audit logs should enable the application’s owners to understand exactly what has taken place, which vulnerabilities were exploited, whether the attacker gained unwanted access to data or performed any unauthorized actions, and, as far as possible, provide evidence of the intruder’s identity. All events relating to the authentication functionality, Key transactions, Any requests containing known attack strings that indicate overtly malicious intentions.

  3. **Alerting administration -**There may be some mechanism which may alert admin of the applications, about any unusual activity in the application like high ping request from a particular IP.

  4. **Reacting to Attack -**Many security-critical applications contain built-in mechanisms to react defensively to users who are identified as potentially malicious. Because most applications are different and attacker have to perform different test to find vulnerability and we will identify many of these requests as potentially malicious and block them. For this reason, some web applications take automatic reactive measures to frustrate the attacker who is working in this way. For an instance, they might respond increasingly slowly to the attacker’s requests or terminate the attacker’s session, requiring him to log in or perform other steps before continuing the attack.