Esta brecha de seguran�a j� foi discutida na lista em um t�pico sobre
Statement x PreparedStatement, e ela n�o � espec�fica do Tomcat ou
SQLServer... � um brecha que o pr�prio desenvolvedor inclui no software.
[]'s,
Leonardo Bueno.
----- Original Message -----
From: "Sergio Oliveira Jr." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 07, 2001 3:42 PM
Subject: [java-list] !!! Brecha de Seguran�a !!!
> O Servlet abaixo possui uma brecha de seguran�a bastante grave. O ambiente
> onde a brecha foi testada � o Tomcat com SQLServer.
>
> S� por curiosidade, algu�m consegue ver aonde est� essa brecha?
>
> public class BadServlet extends HttpServlet {
>
> public void doGet(HttpServletRequest request, HttpServletResponse response)
> throws IOException, ServletException {
> doPost(request,response);
> }
>
> private Connection getConnection() throws Exception {
> // retorna conexao com o SQLServer...
> }
>
> public void doPost(HttpServletRequest request, HttpServletResponse
> response) throws IOException, ServletException {
>
> // Mostra o nome do usu�rio a partir do usuario_id...
>
> String userid = request.getParameter("userid");
>
> String nome = null;
>
> try {
> Connection conn = getConnection();
> Statement query = conn.createStatement();
> StringBuffer sql = new StringBuffer();
> sql.append("SELECT Nome FROM Users WHERE userid = ");
> sql.append(userid);
>
> ResultSet results = query.executeQuery(sql.toString());
>
> if (results.next()) nome = results.getString(1);
>
> query.close();
> conn.close();
>
> } catch(Exception e) {
> throw new IOException("Problemas: " + e.getMessage());
> }
>
> PrintWriter pw = response.getWriter();
>
> if (nome != null) pw.println("<h1>" + nome + "</h1>");
> else pw.println("<h1>Nao achei!!!</h1>");
>
> }
>
> }
>
>
> ------------------------------
> Sergio Oliveira Jr.
> Sun Certified Java Programmer
> Desenvolvedor e Consultor Java
> ------------------------------
>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>
> ------------------------------ LISTA SOUJAVA ----------------------------
> http://www.soujava.org.br - Sociedade de Usu�rios Java da Sucesu-SP
> d�vidas mais comuns: http://www.soujava.org.br/faq.htm
> regras da lista: http://www.soujava.org.br/regras.htm
> para sair da lista: envie email para [EMAIL PROTECTED]
> -------------------------------------------------------------------------
>
------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br - Sociedade de Usu�rios Java da Sucesu-SP
d�vidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------