Gemini-Self-Protector: The Runtime Application Self-Protection Solution Combined With Deep Learning

Lê Thành Phúc
5 min readJun 26, 2023

--

In today’s digital landscape, securing applications against various attacks and vulnerabilities is of utmost importance. With the ever-evolving threat landscape, it becomes crucial to have robust security measures in place. This is where Gemini-Self-Protector comes into play. Gemini is a cutting-edge Runtime Application Self-Protection (RASP) solution that combines the power of deep learning to detect and prevent attacks in real-time.

The Architecture of Gemini-Self-Protector

The architecture of Gemini-Self-Protector is designed with a focus on performance without compromising security. It consists of seven optimized layers that work seamlessly within the application

Deep Learning for Advanced Vulnerability Detection

Gemini-Self-Protector leverages a deep learning model that combines Convolutional Neural Network (CNN) and a family of Recurrent Neural Network (RNN) techniques. This powerful combination allows Gemini to accurately detect and identify various vulnerabilities in your application.

To enhance its detection capabilities, Gemini-Self-Protector integrates with the Web-Vuln-Detection-Predict project, providing you with a comprehensive solution for identifying and mitigating potential threats.

Protecting Against a Wide Range of Attacks and Weaknesses

Gemini-Self-Protector provides robust protection against a multitude of attacks and weaknesses commonly exploited by hackers. Some of the supported attacks include:

  • Malformed Content Types
  • HTTP Method Tampering
  • Large Requests
  • Command Injection
  • Cross-Site Scripting (XSS)
  • SQL Injection
  • Weak Browser Caching
  • Vulnerable Dependencies
  • API Rate Limiting, and more.

With Gemini-Self-Protector, you can strengthen your application’s security posture and minimize the risk of successful attacks.

Gemini Security Response Headers

Gemini-Self-Protector enhances the security of your application by providing default configurations for various HTTP response headers. These headers help protect against common security vulnerabilities and ensure a secure communication environment.

Simple Installation and Usage

Getting started with Gemini-Self-Protector is quick and easy. Simply install the package using pip:

$ pip install gemini_self_protector

Once installed, you can configure Gemini to operate in different modes, such as off, monitor, or block, depending on the sensitivity level required for your application.

Gemini-Self-Protector provides flexibility in its usage, whether you prefer the CLI mode or the GUI mode. Here’s how you can use Gemini in both modes:

CLI Mode

In CLI mode, you can integrate Gemini-Self-Protector into your Flask application by following these steps:

from flask import Flask, request
from gemini_self_protector import GeminiManager

app = Flask(__name__)
gemini = GeminiManager()

GUI Mode

If you prefer a graphical user interface (GUI) for managing Gemini-Self-Protector, you can use the GUI mode. Here’s an example of how to use Gemini in GUI mode:

from flask import Flask, request
from gemini_self_protector import GeminiManager

app = Flask(__name__)
gemini = GeminiManager(app)

Basic Usage

The basic usage of Gemini-Self-Protector allows you to quickly get started with default settings. By default, Gemini runs in the “monitoring” mode with a sensitivity level of 50. Requests with a sensitivity level above 50 will be stored for monitoring purposes. Here’s an example:

from flask import Flask, request, jsonify
from gemini_self_protector import GeminiManager

app = Flask(__name__)
gemini = GeminiManager(app)

@app.route('/api/login', methods=['POST'])
@gemini.flask_protect_extended() # Declare Gemini below Flask route without any options
def login():
username = request.json['username']
password = request.json['password']
if username == "test" and password == "test":
response = jsonify({
"status": "Success",
"message": "Login successful",
"access_token": access_token
})
return response
else:
return jsonify({
"status": "Fail",
"message": "Incorrect Username or Password"
}), 401

if __name__ == "__main__":
app.run()

Advanced Usage

Gemini-Self-Protector also allows for advanced usage with deeper customization. In the advanced mode, you can specify individual modes for each route and have a dashboard to monitor the application’s activity. The running mode and sensitivity can be adjusted directly on the dashboard. Additional features are continuously being developed to enhance Gemini’s capabilities. Here’s an example of advanced usage:

from flask import Flask, request
from gemini_self_protector import GeminiManager

app = Flask(__name__)
gemini = GeminiManager(app)

@app.route('/api/login', methods=['POST'])
@gemini.flask_protect_extended(protect_mode='block') # Declare Gemini below Flask route with protect mode option
def login():
username = request.json['username']
password = request.json['password']
if username == "test" and password == "test":
response = jsonify({
"status": "Success",
"message": "Login successful",
"access_token": access_token
})
return response
else:
return jsonify({
"status": "Fail",
"message": "Incorrect Username or Password"
}), 401

if __name__ == "__main__":
app.run()

GUI Features for Enhanced Management

Gemini-Self-Protector provides a user-friendly GUI that offers several features to streamline the management of your application’s security. Some of these features include:

  • Monitor Abnormal Events
  • Hot Configuration
  • Access Control List
  • Activity Logging
  • Dependency Vulnerability Checks

With these features, you have better control over your application’s security and can respond effectively to any potential threats.

Demo Install — Configurate — Usage

Screenshot

Gemini Dashboard
Gemini Configurate
Gemini Access control list
Gemini Dependency Check
Gemini Block Malicious Request
Gemini Event Details

--

--

Lê Thành Phúc
Lê Thành Phúc

Responses (1)