Protección contra los intentos de eludir el DNS mediante el token seguro «x-ch-no-bypass».

Introduction

Esta guía ofrece una visión general y ejemplos de cómo puedes protegerte contra los intentos de elusión del DNS. La implementación del encabezado «x-ch-no-bypass» no es obligatoria para ninguna de las integraciones de CrowdHandler; sin embargo, hacerlo proporcionará una capa adicional de verificación del usuario y, por lo tanto, se recomienda.

Which integration types is this article relevant for?

Akamai

Cloudflare

CloudFront

DNS

What do we mean by DNS bypass attempts?

La integración de CrowdHandler en la CDN que elijas dificulta eludir los controles de CrowdHandler; sin embargo, los usuarios expertos que sean capaces de rastrear la información de red asociada a tu infraestructura web podrían desviar su tráfico por fuera del punto final de tu CDN, eludiendo así toda la protección que esta ofrece, incluida tu integración con CrowdHandler.

How it works

When configured, your CrowdHandler integration will attach a header named "x-ch-no-bypass" to all requests forwarded to your application. The value of the header will be your secure no-bypass token. With a minimal amount of code required, you can configure your web application to check that requests are sent with this header and token, ensuring that only users that have been checked by CrowdHandler are allowed onto your application.

Where can I find my token?

Si utilizas la integración de DNS, el token se encuentra en la consola de administración de CrowdHandler, en la pantalla de configuración del dominio de la aplicación web que vas a proteger. El valor del token se almacenará en el campo «No-Bypass Token».

For other CDN integrations (Akamai, Cloudflare, and CloudFront), the respective installation guides will instruct you on how to set up your no-bypass token.

Integration Examples

La validación de la presencia y el valor del encabezado de solicitud «x-ch-no-bypass» se puede realizar fácilmente en la mayoría de los lenguajes de programación y servidores web. A continuación se muestran algunos ejemplos de implementación para diversos lenguajes y servidores web populares.

Apache

RewriteEngine On

# block if request header x-ch-no-bypass value isn't matched
RewriteCond %{HTTP:x-ch-no-bypass} !^(YOURTOKENVALUE)$
RewriteRule ^ - [F]

Nginx

location / {

    if ($http_x_ch_no_bypass != "YOURTOKENVALUE") {
        return 403;
    }

    proxy_pass http://app:3000/;
}

Express.js

app.get('/', (req, res) => {
    if (req.header('x-ch-no-bypass') !== "YOURTOKENVALUE") {
        res.status(403).send("Sorry! You can't see that.")
    }
    res.sendFile(__dirname + "/views/index.html");
})

PHP

function getRequestHeaders() {
    $headers = array();
    foreach($_SERVER as $key => $value) {
        if (substr($key, 0, 5) <> 'HTTP_') {
            continue;
        }

        $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
        $headers[$header] = $value;
    }
    return $headers;
}

$headers = getRequestHeaders();

if($headers['X-Ch-No-Bypass'] != "YOURTOKENVALUE") {
    header("HTTP/1.1 403 Forbidden" );
    exit;
}

Python (Django)

from django.http import HttpResponseForbidden
from django.http import HttpResponse

def index(request):
    chBypassKey = request.META.get('HTTP_X_CH_NO_BYPASS')
    if (chBypassKey) != "YOURTOKENVALUE" :
        return HttpResponseForbidden()
    else :
        return HttpResponse("¡Hola, mundo!")