Skip to content

waf doc #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions docs/en/tutorial/modsecurity-firewall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
head:
- - meta
- name: description
content: How To Use ModSecurity and OWASP CRS For Web App Firewall (WAF) To Secure Your Website
---

<script setup>
import { data } from '../../.vitepress/config.data.ts'
</script>

# How To Use ModSecurity and OWASP CRS For Web App Firewall (WAF) To Secure Your Website

With security as a primary focus this year, we are happy to bring ModSecurity and OWASP CRS for your Web Application Firewall (WAF) in {{ data.name }}.

## What is Modsecurity

<a href="https://modsecurity.org/" target="_blank">Modsecurity</a> is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx that is developed by Trustwave’s SpiderLabs.

WAF can be enabled in your website to provide an external security layer that increases security, detects, and prevents attacks before they reach web applications, because over 70% of all attacks are now carried out over the web application level.

It can help detect and prevent many attacks against your web application by checking all HTTP(s) requests you are willing to allow or block (e.g., request methods, request headers, content types, etc.) against its set of rules.

If the check fails, the visitor will not see the content of your website, predefined actions are performed, usually the visitor will get 403 Forbidden screen.

## What is OWASP CRS

ModSecurity only is not enough to protect your website. You need to configure an additional rule set to make web protection work.

<a href="https://coreruleset.org/" target="_blank">The OWASP ModSecurity Core Rule Set (CRS)</a> is a set of generic attack detection rules for use with ModSecurity or compatible web application firewalls.

The CRS aims to protect web applications from a wide range of attacks, with a minimum of false alerts, including:

- SQL Injection (SQLi)
- Cross Site Scripting (XSS)
- Local File Inclusion (LFI)
- Remote File Inclusion (RFI)
- PHP Code Injection
- Java Code Injection
- HTTPoxy
- Shellshock
- Unix/Windows Shell Injection
- Session Fixation
- Scripting/Scanner/Bot Detection
- Metadata/Error Leakages

## How To Install ModSecurity and OWASP CRS

In {{ $data.name }}, we want to make it very easy for everyone, from beginner to expert, to enable or disable ModSecurity and OWASP CRS in each of your web site on your servers easily, instead of having to log into the linux terminal to do it.

Please login to your {{ $data.name }} Dashboard, choose your server, in the **Utilities** group
click **Install Web Application Firewall (WAF)** and hit the submit button.
Depending on your webserver it may take a different time to setup WAF

After Install WAF success, **go to WAF menu** and **click pencil icon** on your desire website, and you will see the Config Firewall dialog appear to setup.
![](../../images/docs/en/tutorial/modsecurity-firewall/waf-page.png)

Click “Enable” to to enable Web Application Firewall (WAF) to your current web application, and click “Save.

**That’s all. It is very easy!**

![](../../images/docs/en/tutorial/modsecurity-firewall/site-waf-config-disable.png)

You can customize WAF Settings by configuring paranoia level, anomaly threshold, and common rule exclusion.

## Paranoia Level

Using paranoia level, you can choose the desired level of rule check to protect your web application.

Higher paranoia levels will strengthen web security, but will also increase the possibility of blocking some legitimate traffic due to false alarms (also named false positives or FPs).

![](../../images/docs/en/tutorial/modsecurity-firewall/site-waf-config-enable.png)

From <a href="https://coreruleset.org/faq/" target="_blank">OWASP CRS website</a>, there is a detailed explanation about the difference of paranoia levels.

A **paranoia level of 1 (PL1)** is default. At this level, most core rules are enabled. PL1 is advised for beginners, installations covering many different sites and applications, and for setups with standard security requirements.

**Paranoia level 2 (PL2)** includes many extra rules, for instance, enabling many regexp-based SQL and XSS injection protections, and adding extra keywords checked for code injections.

PL2 is advised for **moderate to experienced users** who desire more complete coverage, and for all installations with elevated security requirements.

**Paranoia level 3 (PL3)** enables more rules and keyword lists that cover less common attacks. PL3 also tweaks limits on all special characters used, which provides high coverage against unknown attack types, obfuscated attacks, and attempted WAF bypasses.

PL3 is aimed at **users who are experienced at the handling of FPs** and at installations with high security requirements.

**Paranoia level 4 (PL4)** further restricts special characters.

PL4 is advised for **experienced users** protecting installations with very high security requirements.

Recommended level for most use cases is **1 (default) or 2**.

## Anomaly Threshold

ModSecurity assigns a score for each security risk found in a request (Critical: 5, Error: 4, Warning: 3, Notice: 2).

Anomaly threshold determines the accumulated score for a request to be blocked.

**Recommended level for production website is 5-10.**

## Common Rule Exclusion

OWASP CRS provides common rule exclusions for some popular Content Management System (CMS), including WordPress, Drupal, NextCloud, DocuWiki, phpMyAdmin and Xenforo.

![](../../images/docs/en/tutorial/modsecurity-firewall/site-waf-config-enable.png)

If your current web application uses any of those CMS, please tick in the checkbox to reduce false positives and it will be automatically applied to your firewall.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions docs/vi/tutorial/modsecurity-firewall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
head:
- - meta
- name: description
content: Cách Sử Dụng ModSecurity và OWASP CRS Cho Tường Lửa Ứng Dụng Web (WAF) Để Bảo Vệ Trang Web Của Bạn
---

<script setup>
import { data } from '../../.vitepress/config.data.ts'
</script>

# Cách Sử Dụng ModSecurity và OWASP CRS Cho Tường Lửa Ứng Dụng Web (WAF) Để Bảo Vệ Trang Web Của Bạn

Với việc bảo mật là trọng tâm chính trong năm nay, chúng tôi hân hạnh giới thiệu ModSecurity và OWASP CRS cho Tường Lửa Ứng Dụng Web (WAF) của bạn trong {{ data.name }}.

## ModSecurity là gì

<a href="https://modsecurity.org/" target="_blank">ModSecurity</a> là một công cụ tường lửa ứng dụng web (WAF) mã nguồn mở, đa nền tảng cho Apache, IIS và Nginx, được phát triển bởi SpiderLabs của Trustwave.

WAF có thể được kích hoạt trên trang web của bạn để cung cấp lớp bảo mật bên ngoài giúp tăng cường bảo vệ, phát hiện và ngăn chặn các cuộc tấn công trước khi tiếp cận ứng dụng web, vì hơn 70% các cuộc tấn công hiện nay được thực hiện ở mức ứng dụng web.

Nó giúp phát hiện và ngăn chặn nhiều cuộc tấn công nhắm vào ứng dụng web bằng cách kiểm tra tất cả yêu cầu HTTP(s) (ví dụ: phương thức yêu cầu, tiêu đề yêu cầu, loại nội dung, v.v.) dựa trên bộ quy tắc.

Nếu kiểm tra không thành công, khách truy cập sẽ không thấy nội dung trang web của bạn, và các hành động được xác định trước sẽ được thực hiện, thường là màn hình 403 Forbidden.

## OWASP CRS là gì

Chỉ riêng ModSecurity thì chưa đủ để bảo vệ trang web. Bạn cần cấu hình thêm một bộ quy tắc để kích hoạt khả năng bảo vệ web.

<a href="https://coreruleset.org/" target="_blank">Bộ Quy Tắc Cốt Lõi OWASP ModSecurity (CRS)</a> là một tập quy tắc phát hiện tấn công tổng quát, được thiết kế cho ModSecurity hoặc tường lửa ứng dụng web tương thích.

CRS nhằm mục đích bảo vệ ứng dụng web trước nhiều dạng tấn công, với mức cảnh báo sai thấp, bao gồm:

- SQL Injection (SQLi)
- Cross Site Scripting (XSS)
- Local File Inclusion (LFI)
- Remote File Inclusion (RFI)
- PHP Code Injection
- Java Code Injection
- HTTPoxy
- Shellshock
- Unix/Windows Shell Injection
- Session Fixation
- Scripting/Scanner/Bot Detection
- Metadata/Error Leakages

## Cách Cài Đặt ModSecurity và OWASP CRS

Trong {{ $data.name }}, chúng tôi muốn việc kích hoạt hoặc vô hiệu hóa ModSecurity và OWASP CRS cho từng trang web của bạn trên máy chủ trở nên dễ dàng với mọi người, từ người mới bắt đầu đến chuyên gia, thay vì phải đăng nhập vào terminal Linux để thực hiện.

Hãy đăng nhập vào Bảng Điều Khiển {{ $data.name }}, chọn máy chủ của bạn, trong nhóm **Tiện ích** bấm **Cài đặt tường lửa ứng dụng (WAF)** và nhấn nút gửi.
Tùy theo webserver, thời gian cài đặt WAF có thể khác nhau.

Sau khi cài đặt WAF thành công, **vào menu WAF** và **bấm biểu tượng bút** trên trang web bạn muốn, sẽ xuất hiện hộp thoại Cấu hình tưởng lửa ứng dụng để cấu hình.
![](../../images/docs/en/tutorial/modsecurity-firewall/waf-page.png)

Bấm “Kích hoạt” để bật Tường Lửa Ứng Dụng Web (WAF) vào ứng dụng web hiện tại, rồi bấm “Lưu”.

**Vậy là xong. Rất đơn giản!**

![](../../images/docs/en/tutorial/modsecurity-firewall/site-waf-config-disable.png)

Bạn có thể tùy chỉnh Cài Đặt WAF bằng cách thiết lập paranoia level, anomaly threshold và common rule exclusion.

## Paranoia Level

Bằng cách sử dụng paranoia level, bạn có thể chọn mức độ quy tắc mong muốn để bảo vệ ứng dụng web của mình.

Mức paranoia cao hơn sẽ tăng cường bảo mật, nhưng cũng sẽ tăng khả năng chặn một số truy cập hợp lệ do cảnh báo sai (false positives hoặc FPs).

![](../../images/docs/en/tutorial/modsecurity-firewall/site-waf-config-enable.png)

Theo <a href="https://coreruleset.org/faq/" target="_blank">trang web OWASP CRS</a>, có giải thích chi tiết về sự khác nhau giữa các mức paranoia.

**Paranoia level 1 (PL1)** là mặc định. Ở mức này, hầu hết các quy tắc cốt lõi đều được kích hoạt. PL1 được khuyến nghị cho người mới, cài đặt bao gồm nhiều trang web và ứng dụng khác nhau, và cho các hệ thống yêu cầu bảo mật tiêu chuẩn.

**Paranoia level 2 (PL2)** bao gồm nhiều quy tắc bổ sung, ví dụ như bật nhiều chức năng bảo vệ SQL, XSS dựa trên biểu thức chính quy, và thêm danh sách từ khóa kiểm tra các đoạn mã độc.

PL2 thích hợp cho **những người có kinh nghiệm vừa phải** muốn bảo vệ toàn diện hơn, và cho hệ thống yêu cầu bảo mật cao hơn.

**Paranoia level 3 (PL3)** kích hoạt nhiều quy tắc và danh sách từ khóa cho các cuộc tấn công ít phổ biến hơn. PL3 cũng giới hạn toàn bộ ký tự đặc biệt, giúp ngăn chặn tốt các cuộc tấn công chưa được biết, tấn công ẩn và kỹ thuật né tránh WAF.

PL3 dành cho **những người dùng có kinh nghiệm xử lý FPs** và các hệ thống có yêu cầu bảo mật cao.

**Paranoia level 4 (PL4)** tiếp tục hạn chế các ký tự đặc biệt.

PL4 được khuyến nghị cho **người dùng có kinh nghiệm** bảo vệ hệ thống có yêu cầu bảo mật cực cao.

Mức khuyến nghị cho hầu hết trường hợp là **1 (mặc định) hoặc 2**.

## Anomaly Threshold

ModSecurity gán điểm cho mỗi rủi ro bảo mật được phát hiện trong một yêu cầu (Critical: 5, Error: 4, Warning: 3, Notice: 2).

Anomaly threshold xác định điểm tổng cộng mà tại đó một yêu cầu sẽ bị chặn.

**Mức khuyến nghị cho trang web chạy thực tế là 5-10.**

## Common Rule Exclusion

OWASP CRS cung cấp một số quy tắc loại trừ phổ biến cho một số hệ thống CMS như WordPress, Drupal, NextCloud, DocuWiki, phpMyAdmin và Xenforo.

![](../../images/docs/en/tutorial/modsecurity-firewall/site-waf-config-enable.png)

Nếu trang web của bạn đang sử dụng một trong các CMS này, hãy đánh dấu tùy chọn đó để giảm thiểu cảnh báo sai và nó sẽ được tự động áp dụng cho tường lửa của bạn.