Translated message

A translation of this page exists in English.

Warning message

This translation is outdated. For the most up-to-date information, please refer to the English version.

HTTPoxy - O meu JBoss/tomcat foi afetado?

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6.x
  • Red Hat JBoss Enterprise Application Platform (EAP) 5.x
  • Red Hat JBoss Enterprise Web Server (EWS) 2.x
    • Tomcat 6
  • Red Hat JBoss Web Server (JWS) 3.x
    • Tomcat 6
    • Tomcat 7

Issue

Este problema acontece quando você está usando CGIServlet no JBoss EAP ou Tomcat. Todas as solicitações enviadas, geradas da solicitação original do invasor para o script CGI, podem ser redirecionadas para um proxy controlado pelo invasor.

Resolution

O uso de um CGIServlet em produção não é aconselhável. Recomenda-se remover o aplicativo web usando CGIServlet, caso você tenha essa opção. Você também pode, em contra partida, adicionar um Filtro Servlet ao seu aplicativo, o que retorna uma resposta ‘400: Bad Request’, se um Cabeçalho HTTP com o nome 'Proxy' for detectado. Por exemplo:

Adicione um Filtro Servlet ao seu war do aplicativo CGI que filtra solicitações com o cabeçalho 'Proxy':
OBSERVAÇÃO: o filtro bloqueará a porção CGI das linguagens de programação.

package com.redhat.prodsec.web.filter;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.annotation.WebFilter;

/*
 *  This is a sample servlet filter to disallow requests with "Proxy" http header
 */
@WebFilter("/*")
public class ProxyHeaderFilter implements Filter {

    /**
     * @see Filter#destroy()
     */
    public void destroy() {
        // TODO Auto-generated method stub
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) req;
        Enumeration<String> headerNames = httpRequest.getHeaderNames();


        if (headerNames != null) {
                while (headerNames.hasMoreElements()) {
                    String headerName = headerNames.nextElement();
                    if(headerName.equalsIgnoreCase("Proxy"))
                        ((HttpServletResponse) res).sendError(HttpServletResponse.SC_BAD_REQUEST);
                }
        }

        chain.doFilter(req, res);

    }

    /**
     * @see Filter#init(FilterConfig)
     */
    public void init(FilterConfig fConfig) throws ServletException {
    }

}

Após compilar o ProxyHeaderFilter.java, um pacote nomeado com.redhat.prodsec.web.filter será criado, contendo ProxyHeaderFilter.class.

Crie um jar para o ProxyHeaderFilter.class usando o comando acima. Isto gerará um jar chamado ProxyHeaderFilter.jar.

jar -cvf ProxyHeaderFilter.jar com

Coloque esse jar na sua pasta WEB-INF/lib do aplicativo web. Isto habilitará o Filtro Servlet no aplicativo web.

Root Cause

Consulte HTTPoxy - Vulnerabilidade no código do aplicativo CGI afetando PHP, Go, Python, entre outros para mais informações.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments