Java (Spring MVC)
Zen Firewall by Aikido helps protect your application by blocking common attacks and unsafe behavior at runtime, with controls you can tune per app and environment. Use the guides below to install and set it up.
Requirements
Java 17+ (tested up to Java 21; also supports Kotlin/Groovy with same agent).
Spring MVC 3.x.
Installation & Configuration
Install Zen Firewall by Aikido
Download and extract the latest Java agent bundle:
curl -L https://github.com/AikidoSec/firewall-java/releases/latest/download/zen.zip -o zen.zip
unzip zen.zipcurl -L https://github.com/AikidoSec/firewall-java/releases/latest/download/zen.tar.gz -o zen.tar.gz
tar -xzf zen.tar.gzKeep the extracted folder structure intact (for example /opt/zen) and make sure your process can read and write it.
Add the Java agent to your runtime:
-javaagent:/opt/zen/agent.jarFor rate limiting and user blocking features, add agent_api.jar to your project.
Gradle:
dependencies {
implementation files('/opt/zen/agent_api.jar')
}Maven:
<dependency>
<groupId>dev.aikido</groupId>
<artifactId>agent_api</artifactId>
<version>1.0</version>
<systemPath>/opt/zen/agent_api.jar</systemPath>
</dependency>Enable Request Blocking and User Identification
Use this middleware to enable rate limiting, user identification, and blocking features.
Zen Firewall does not require this middleware to block attacks. Core attack protection works without it. The middleware provides additional request context that Zen uses for protections such as rate limiting, user blocking, bot blocking, country blocking, and threat actor blocking.
Adapt the example to fit how your application identifies users and handles requests.
Set users in an earlier filter:
Start Zen Firewall in dry / detection-only mode
Start your app with Zen enabled and dry mode:
AIKIDO_TOKEN=AIK_RUNTIME_... AIKIDO_BLOCK=false java -javaagent:/opt/zen/agent.jar -jar build/myapp.jarSet the token as an environment variable so the Aikido Zen agent can pick it up. If you don't have a token yet, follow instructions here.
AIKIDO_TOKEN=AIK_RUNTIME_We recommend to start your app in dry mode to ensure it works as expected without blocking any requests. We advise running Zen Firewall in staging for two weeks to avoid false positives.
AIKIDO_BLOCK=falseTest your app
Browse to your application and perform a couple of actions or open a couple of pages. Zen will automatically discover the routes in your application.
You can verify a working agent by looking at the following pages of your Zen application:
Events: Should show an "Application started" event.
Routes: After some time your application routes will start showing here with the method, route and requests.
Instances: Should show the number of active instances for your application where Zen is installed.

Setup rate limiting in the dashboard
When you've added the Zen Firewall middleware you can test protecting a route from brute force attacks, you do this by setting up rate limit in the Aikido Dashboard:
Click on the created app.
Go to the Routes tab.
Find the route you would like to limit and click Setup rate limiting.
Follow the instructions to configure the rate limit (e.g., 5 requests per minute).


Verify Rate Limiting
Start your app and try to access the route you've rate limited 5 times within a minute. After the fifth attempt, you should receive a rate limit error:
You are rate limited by Aikido firewall. (Your IP: 1.2.3.4)Next steps
Congrats you've successfully installed Zen Firewall. If you encountered any problems, have concerns or feature requests, don't hesitate to reach out to support.
You can now go and explore the many features that Zen Firewall provides:
Additional information:
Last updated
Was this helpful?