How to connect locally managed Docker SWAG with open-appsec to WebUI

open-appsec Docker SWAG integration is currently in "beta".

Connecting your integrated open-appsec deployment to the open-appsec central WebUI provides many benefits. Using the WebUI (SaaS) is optional and included in all editions, including open-appsec free community edition.

  • Central WebUI for viewing/managing all open-appsec configuration and functionality

  • Store and view your open-appsec security logs

  • Monitor your open-appsec deployments

  • Monitor learning status of each of your protected assets

  • See learning progress and status

  • Receive and manage tuning suggestions

  • Get cloud-based shared learning between multiple agents (e.g. in HA scenario)

On this page it will be explained how you can connect your existing locally-managed Docker SWAG deployment with open-appsec to the open-appsec WebUI

Prerequisites

  • Existing SWAG with open-appsec WAF deployment which

    • locally managed

    • not connected to the central WebUI yet

Steps to connect your SWAG with open-appsec WAF deployment to WebUI

  1. Sign up for a free open-appsec WebUI tenant at https://my.openappsec.io

  2. Login to the open-appsec WebUI at https://my.openappsec.io

  3. Create a new Docker Deployment Profile and copy the “Token” from that Profile (you will need it later!).

  1. As subtype select: SWAG + open-appsec

  2. Make sure to Enforce the policy in the WebUI (“Enforce” button in top right corner). You find full details about how to create the profile and get the Token here in our docs.

  3. In your docker-compose.yaml provide your “Token” copied from your WebUI Docker Profile (see Prerequisites above) as the value for the existing AGENT_TOKEN key. It will then look somewhat similar to this: - AGENT_TOKEN=cp-123456-1234-678901234556773478592378645 Providing the token is critical to allow the agent to connect to the specific deployment profile in the central WebUI, which will allow you use the cloud-hosted central management for assets and policies, cloud logging, graphical dashboards, events analysis, and ability to manage multiple deployments/clusters in a scalable way. If you didn’t create a deployment profile and copy the token earlier, here is how to get it.

  4. Run following commands to redeploy your docker-compose file:

docker-compose down && docker-compose up -d

Note: The following step is only relevant when you picked “This management” as management mode earlier! Skip this step for the “Declarative management” management mode as in that case the configuration for open-appsec is done locally in the local_policy.yaml file!

  1. Create one or more assets in the WebUI which represent web applications and/or Web APIs which you want to be protected by open-appsec WAF and allows you to adjust the open-appsec configuration specifically for each of them. Make sure the configured web application in your asset(s) matches your public DNS name for the SWAG container (as configure in the compose file here: URL=yourdomain.url)

    Make sure to link your assets to the specific WebUI Profile which you created earlier (General -> Profiles) and adjust the Threat Prevention mode to Detect-Learn or Prevent (Threat Prevention -> Mode). The steps are described here. Don't forget to Enforce policy in the WebUI after you did any changes!

  2. You can check open-appsec agent status by running:

docker exec appsec-agent open-appsec-ctl -s

Check what's shown for "Management mode:" to verify that your agent is connected to the central open-appsec WebUI in the mode which you selected within the profile settings.

  1. Now let’s simulate some attack again to verify that open-appsec is preventing it as expected and see them in Monitoring in the open-appsec WebUI: a) Make sure the SWAG NGINX reverse proxy is properly set-up to point to some web application backend (see more details here). The NGINX configuration for the SWAG container is located here (on docker host): ./swag-config/nginx/site-confs/default.conf (and in SWAG container it’s here: /config/nginx/site-confs/default.conf )

Note that for the following simulated attack you can also just run it against the default webpage SWAG returns after deployment and skip the above step.

Run following curl request to simulate an attack (replace with your SWAG container DNS name and Port)

curl -v -k https://<SWAG-CONTAINER-PUBLIC-DNS-NAME>:<PORT>/?shell_cmd=cat/etc/passwd

Note: “-k” was added above so this would work even when still using a Let’s Encrypt “staging” certificate. You can alternatively use your web browser, just open the following URL:

https://<SWAG-CONTAINER-PUBLIC-DNS-NAME>:<PORT>/?shell_cmd=cat/etc/passwd

Last updated