How to Use Imperva's WAF with Appdome MOBILEBot Defense

Last updated April 17, 2024 by Appdome

Introduction

Web Application Firewalls (WAFs), like the one offered by Imperva, play a crucial role in protecting web applications from a wide range of cyber threats. Using Imperva’s WAF with Appdome’s MOBILEBot™ Defense solution offers app developers a streamlined approach to protect backend APIs against malicious bots and botnets, credential stuffing attacks, DDoS, invalid traffic and other automated attacks. In this guide, you’ll learn how to integrate Appdome’s Docker Image with Imperva’s WAF.

Before delving into the steps, let’s understand some of the terms used:

MTLS (Mutual Transport Layer Security): Mutual TLS (mTLS) is a method for mutual authentication in which both parties in a network connection validate the SSL certificates presented by each other against a trusted root Certificate Authority (CA) certificate.

Client Certificate: In cryptography, a client certificate is a type of digital certificate that is used by client systems to make authenticated requests to a remote server.

Safe Session: Represents sessions that are determined to be safe or not at risk of any threat.

At Risk Session: Represents sessions that are potentially under threat or have detected anomalies.

Header Payload: The data transferred in the header of HTTP requests or responses. Protecting this data ensures that it cannot be tampered with during transit.

Prerequisites for Using Radware & Appdome Docker Image

For utilizing Appdome MOBILEBot Defense with Imperva, you’ll need the following:

  • An Imperva account with admin permissions
  • An AWS, GCP, or Azure server with admin permissions
  • An Android or iOS app secured by Appdome MOBILEBot Defense
  • An Appdome MOBILEBot Defense License

Getting Started with Imperva’s WAF Setup and Configuration

Note: For any additional information, please refer to Imperva’s  documentation on Cloud Application and Network Security

  1. Access Imperva Portal
  2. Configure Imperva Cloud WAF
    • To open the Origin Server Settings, log in to your my.imperva.com account.On the top menu bar, click Application.
    • On the sidebar, click Websites and click a website name.
    • On the sidebar, click Website Settings.
    • Click Origin Servers.
      For more information, see the Imperva’s guide on how to set up Origin Servers
  3. Set Up Redirect Rule

    • Create a redirect rule in the Imperva portal. This rule should specify the conditions for the redirection (e.g., specific URLs or patterns) and the target URL or domain where you want to redirect traffic.
    • See the Imperva’s guide on how to Create Simplified Redirect Rules
  4. Add a Client Certificate
  5. mTLS Configuration
    • See the Imperva guide on how to Upload a CA certificate to your account

      IMPORTANT:
      It is only necessary to configure the mTLS if you have enabled mTLS in the Appdome Build process. Otherwise, skip ahead to the section Configure Appdome’s Docker Image

Setting up the server of your choice

When the Imperva configuration has been completed, you can begin setting up up your GCP, Azure or AWS sever or any cloud provider of your choice.

Links to Dedicated Appdome Knowledge Base articles:

  • GCP: For setting up a server on Google Cloud Platform and configuring it with Appdome’s Docker Image, follow this guide.
  • Azure: For setting up a server on Microsoft Azure and configuring it with Appdome’s Docker Image, follow this guide.
  • AWS: For setting up a server on Amazon Web Services and configuring it with Appdome’s Docker Image, follow this guide.

To learn more, see the installation instructions for Installing Docker Engine on Ubuntu

After setting up your server of choice, continue with setting up Appdome Docker Image.

Configure Appdome’s Docker Image

Appdome’s Docker Image is a custom solution to secure apps built on the Appdome platform with the Anti-Bot service enabled. This service functions within a Docker container based on Nginx. To facilitate its operation, users must supply an SSL certificate, config files and keys, and designated environment variables.

Prerequisites: Familiarity with Docker and UNIX-based machines is beneficial.

How Does It Work?

Based on Nginx and Lua, the service employs the Lua module to decrypt the payload and validate the signature, then it proxies the request to the target route as specified in the config file.

The module can be used with either the built-in LRU cache or with Redis, but it is recommended to use the built-in LRU to reduce the overhead of making the calls to Redis and ease the setup. If working in a cluster, it is necessary to use Redis to share storage across multiple instances.

Setup

The following environment variables are required to set up the service.

Environment Variable Name Required Description
REDIS Optional Only provide AD_REDIS_HOST if you intend to use it.
LOG_LEVEL Optional The default setting is warn. Available options include: debug, info, notice, warn, error, crit, alert, emerg. All logs are output to the stdout.
RESOLVER Mandatory Provide the resolver DNS server to use for discovering upstream servers.
PASSTHROUGH Optional A key that logs only headers but does not validate them.
Note: For a Kubernetes server, the default DNS server IP is 192.168.0.10. For a pure Docker configuration, the default server IP is 127.0.0.11

Configs: Located in /home/configs, this folder contains JSON files. The name of the file is task_id, as built on Appdome and the content of the file is a JSON array of the mobile anti bot configuration as provided by Appdome.

Keys: Located in /home/keys, this folder contains private keys used to validate the headers sent by Appdome.After receiving the JSON file from the Appdome support team, you will need to add two fields: key, target and, optionally, heartbeat_validity. The first two are string fields, and the last is the heartbeat number in seconds.
The key will point to a key from the keys folder mentioned above to validate the headers. The target is the address to which the request will be forwarded, which should be resolvable by the resolver. The target can be an internal address provided that the resolver can find it.
Example:
“key”: “keys/task-id-1-host-1.pem”,
“target”: “http://jsonplaceholder.typicode.com/posts/1”

Optional: How to Configure SSL & mTLS

If you want the Appdome Docker Image to handle SSL and mTLS, additional configuration is required. This includes passing environment variables and mounting certificates to the service.
Environment Variable Name Description
SSL_ON In order to enable the reverse proxy to handle SSL connections, you need to mark the SSL_ON=true. Make sure to mount SSL certificates to the container under /etc/nginx/certs/{ssl.crt, key.key}.
MTLS_ON In order to enable the reverse proxy to handle mTLS, you need to set both SSL_ON and MTLS_ON=true.
Make sure to mount the CA certificate that will be used for the mTLS under /etc/nginx/certs/ca.crt.
FINGERPRINTS If MTLS_ON=true the certificate fingerprints can be passed to allow only specific certificates identified by a SHA1 fingerprint. The value format should include a string of comma-separated values with a space following each comma as follows: asd, zxc, qwe

How to run Appdome Docker Image

Connect to your VM, and run the following commands:

    • Pull the docker image from our public repository:
      docker pull public.ecr.aws/n2i7f1e2/appdome-waf:1.0.0
    • Run the docker image with the following command:
      docker run -p 443:443 -p 80:80 -d \
      -v "$(pwd)"/certs:/etc/nginx/certs \
      -v "$(pwd)"/keys:/home/keys \
      -v "$(pwd)"/configs:/home/configs \
      -e REDIS=<redis address> \
      -e PASSTHROUGH=false \
      -e RESOLVER=<resolver address> \
      -e SSL_ON=true \
      -e MTLS_ON=true \
      -e FINGERPRINTS=asd, zxc, qwe \
      -e LOG_LEVEL=debug \
      --restart unless-stopped \
      public.ecr.aws/n2i7f1e2/appdome-waf:1.0.0

At this point, you have a machine that will run the Appdome Docker Image. Make sure that your application traffic is routing correctly to the Appdome Docker Image and that the Appdome Docker Image is passing the traffic correctly to the target.

Conclusion

By integrating Akamai with your preferred Virtual Server and using Appdome’s MOBILEBot Defense, you can protect your backend APIs against malicious bots and enhance the security of mobile apps. By mastering and implementing the aforementioned configurations, businesses can safeguard and optimize their mobile app traffic.

Related Articles:

Thank you!

Thanks for visiting Appdome! Our mission is to secure every app on the planet by making mobile app defense easy. We hope we’re living up to the mission with your project. If you don’t already have an account, you can sign up for free.

Appdome

Want a Demo?

Mobile Bot Defense

AlanWe're here to help
We'll get back to you in 24 hours to schedule your demo.