ReDoSHunter: A Combined Static and Dynamic Approach for Regular Expression DoS Detection

Overview

ReDoSHunter

ReDoSHunter is a combined static and dynamic approach for regular expression DoS detection.


LATEST NOTE (updated at 2021.09.13):

  1. ReDoSHunter is an open-source project that serves for the research purpose. The vulnerabilities exposed by ReDoSHunter should EXPLICITLY acknowledge the use of ReDoSHunter.

  2. Though ReDoSHunter is open sourced and allows commercial usage, recently we noticed an extensive usage of ReDoSHunter for profit. Therefore, we highlight that any exposed and confirmed new CVEs need to be co-owned by the major author (Yeting LI), and the profit from exposing new CVEs using ReDoSHunter should also half-preserved by ReDoSHunter authors. For further questions, please contact Yeting LI at email.


You can find more information in the paper ReDoSHunter: A Combined Static and Dynamic Approach for Regular Expression DoS Detection.

@inproceedings {Li2021ReDoSHunter,
    author = {Yeting Li and Zixuan Chen and Jialun Cao and Zhiwu Xu and Qiancheng Peng and Haiming Chen and Liyuan Chen and Shing-Chi Cheung},
    title = {ReDoSHunter: A Combined Static and Dynamic Approach for Regular Expression DoS Detection},
    booktitle = {30th {USENIX} Security Symposium ({USENIX} Security 21)},
    year = {2021},
    isbn = {978-1-939133-24-3},
    pages = {3847--3864},
    url = {https://www.usenix.org/conference/usenixsecurity21/presentation/li-yeting},
    publisher = {{USENIX} Association},
    month = aug,
}

Usage

1. Detect a single regular expression (cannot set timeout)

The main function is in ./src/main/java/cn/ac/ios/ReDoSMain.java

For example, if you type String regex = "^(a+)+b"; then run this file,

If the input regex is vulnerable, you will get:

^(a+)+b
Is attack success: true
Attack time: 1016 (ms)
Vulnerability Position: ^►(▻a+◅)+◄b
Attack String: "a"+"a"*32+" "
Vulnerability Source: There is a nested quantifier node a+ in (a+)+.
Vulnerability Degree: EXPONENT

2. Test regexes from datasets (can set timeout)

The file structure is

ReDosHunter
├─ ...
├─ data	
│   ├─ expr  # The results will show here!
│   │  ├─ empty.txt  # This file is only used to keep an empty folder in github.
│   │  └─ ...
│   ├─ paper_dataset # Corpus, RegexLib, Snort are the data set used in our paper.
│   │  ├─ corpus.txt 
│   │  ├─ regexlib.txt
│   │  ├─ snort.txt
│   │  └─ test.txt   # put your dataset here!
│   └─ ...
└─ ...

The main function is in ./src/main/java/cn/ac/ios/Test.java

You can change String filename in the main function and run this file.

3. The parameters of static detection & dynamic verification

The default parameter is: 15 threads are used for static detection and 1 thread is used for dynamic verification. For a regular expression, the upper limit time of static detection is 60s. Other parameters are in ./src/main/java/cn/ac/ios/Bean/AttackBean.java.

Static detection contains five patterns (i.e., NQ, EOD, EOA, POA, SLQ in our paper): By default, The five patterns are all detected. If you want to detect not all patterns, change the parameter options in the checkReDoS function.

Dynamic verification is divided into two modes: S mode (default): for each regular expression, if one attack string attack is successful, stop the verification of other attack strings. M mode: verify all attack strings. The change method is to change the parameter model in the validateReDoS function.

Both static detection and dynamic verification support regular expressions under different languages. Java (default), python, JavaScript and PCRE. If you want to change language, please change the language parameter in the checkReDoS and validateReDoS functions.

License

Check the LICENSE.md file.

Comments
  • Unexpected behaviour

    Unexpected behaviour

    Clearly describe the bug ... when I put this regex I get this output, the output should be exponent instead of polynomial in theory.

    ^(a+)+b$ RESULT-TRUE POLYNOMIAL nums:1 POLYNOMIAL AttackString:""+"a"*20000+" " patternType: SLQ2 vulnerability Position: Unable to locate Vulnerability position vulnerability Source: Unable to find Vulnerability source

    What steps are needed to reproduce the bug?

    ... put ^(a+)+b$ in the test.txt file and run it.

    What did you expect to happen?

    ... I expected to get the output as Exponent instead of Polynomial

    What actually happened (e.g. what warnings or errors did you get)?

    ... I got the output as Polynomial instead of exponential.

    opened by adnan0944 1
  • 输入正则中含有空格会导致正则被截取

    输入正则中含有空格会导致正则被截取

    scanner.nextLine()默认会使用"\\p{javaWhitespace}+"做为分隔符,当输入正则中含有空格时,会导致正则被截取

    Which issue, if any, is this issue related to?

    e.g. "Closes #000" or "None, as it's a documentation fix."

    Is there anything in the PR that needs further explanation?

    e.g. "No, it's self-explanatory."

    opened by walk143 0
  • 修复python某些版本运行失败的bug

    修复python某些版本运行失败的bug

    Which issue, if any, is this issue related to?

    e.g. "Closes #000" or "None, as it's a documentation fix."

    Is there anything in the PR that needs further explanation?

    e.g. "No, it's self-explanatory."

    opened by pengkeng 0
  • Language

    Language

    Which issue, if any, is this issue related to?

    e.g. "Closes #000" or "None, as it's a documentation fix."

    Is there anything in the PR that needs further explanation?

    e.g. "No, it's self-explanatory."

    opened by pengkeng 0
  • Language

    Language

    Which issue, if any, is this issue related to?

    e.g. "Closes #000" or "None, as it's a documentation fix."

    Is there anything in the PR that needs further explanation?

    e.g. "No, it's self-explanatory."

    opened by pengkeng 0
Owner
Yeting Li
Yeting Li
Dynamic detection of likely invariants

This is the distribution of the Daikon invariant detector, Daikon version 5.8.11, released November 2, 2021. If you are working with a Daikon distrib

null 159 Dec 28, 2022
The combined power of JUnit, Guice and Mockito. Plus it sounds like a cool martial art.

The combined power of JUnit, Guice and Mockito. Plus it sounds like a cool martial art. So you started using dependency injection because somebody tol

Arcbees 270 Sep 19, 2022
A complete and performing library to highlight text snippets (EditText, SpannableString and TextView) using Spannable with Regular Expressions (Regex) for Android.

Highlight A complete and performing library to highlight text snippets (EditText/Editable and TextView) using Spannable with Regular Expressions (Rege

Irineu A. Silva 16 Dec 22, 2022
Reverse engineer and rewrite real mode dos programs!

Spice86 - A PC emulator for real mode reverse engineering Spice86 is a tool to execute, reverse engineer and rewrite real mode dos programs for which

Kevin 55 Nov 9, 2022
Clean-architecture-guide - Guia sobre Clean Architecture criado a partir dos meus estudos sobre o tema.

Clean Architecture Guide Arquitetura são as práticas e fundamentos de como organizamos um sistema. Tem relação e como os componentes estão relacionado

Jean Jacques Nascimento Barros 3 Apr 23, 2022
Desafios-bootcamps-dio - Desafios em C#, Java, JavaScript, Kotlin, Python e Ruby dos Bootcamps da Digital Innovation One

Desafios dos Bootcamps da Digital Innovation One Aqui você vai encontrar todos os desafios dos bootcamps que realizei da Digital Innovation One. Os có

Pleiterson Amorim 443 Dec 31, 2022
A plugin of Grasscutter for send regular notice.

MeaNotice - Grasscutter Regular Notice Plugin MeaNotice is a plugin of Grasscutter, you can use this plugin to publish notifications in-game regularly

ButterCookies 39 Oct 17, 2022
Document scanner with border detection, perspective correction and custom crop/resize

react-native-document-scanner Preview iOS Android Both Platform Use version >=1.4.1 if you are using react-native 0.48+ $ yarn add https://github.com/

Augusto Pinheiro 53 Nov 10, 2022
Java based open source static site/blog generator for developers & designers.

JBake JBake is a Java based open source static site/blog generator for developers. Documentation Full documentation is available on jbake.org. Contrib

JBake 1k Dec 30, 2022
The MeterRegistryHolder class is designed to hold MeterRegistry as a static field.

MeterRegistryHolder The MeterRegistryHolder class is designed to hold MeterRegistry as a static field. Goal The goal is to simplify using MeterRegistr

Tomasz Fijałkowski 4 Sep 20, 2022
On-device wake word detection powered by deep learning.

Porcupine Made in Vancouver, Canada by Picovoice Porcupine is a highly-accurate and lightweight wake word engine. It enables building always-listening

Picovoice 2.8k Jan 7, 2023
Official React Native client for FingerprintJS PRO. 100% accurate device identification for fraud detection.

FingerprintJS PRO React Native Official React Native module for 100% accurate device identification, created for the FingerprintJS Pro Server API. Thi

FingerprintJS 26 Nov 22, 2022
BungeeCord/Spigot plugin that fixes Multi-world detection by simulating mod presence on the server side

Companion for map mods Unofficial BungeeCord and Spigot (Paper) companion plugin for Xaero's Minimap (and their World Map), JourneyMap and VoxelMap. T

Artur Khusainov 3 Sep 18, 2022
🔥 强大的动态线程池,并附带监控报警功能(没有依赖中间件),完全遵循阿里巴巴编码规范。Powerful dynamic thread pool, does not rely on any middleware, with monitoring and alarm function.

?? 动态线程池(DTP)系统,包含 Server 端及 SpringBoot Client 端需引入的 Starter. 这个项目做什么? 动态线程池(Dynamic-ThreadPool),下面简称 DTP 系统 美团线程池文章 介绍中,因为业务对线程池参数没有合理配置,触发过几起生产事故,进而

longtai 3.4k Dec 30, 2022
A quiz app with great layout design, dynamic questions using firebase and what not....

AndroidQuizApp An android quiz app created using Android Studio with our language JAVA that has great layout design, dynamic questions using firebase

Ejaz Mahmood 4 Dec 30, 2022
A light-weight and dynamic dependency injection framework

⚠️ This project is now part of the EE4J initiative. This repository has been archived as all activities are now happening in the corresponding Eclipse

Java EE 105 Dec 23, 2022
The KubeJS data dumper and dynamic typing generator.

ProbeJS A data dumper and typing generator for the KubeJS functions, constants and classes. Great thanks to @DAmNRelentless, @LatvianModder and @yeste

Li Junyu 22 Dec 8, 2022
dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务

一个基于springboot的快速集成多数据源的启动器 简介 dynamic-datasource-spring-boot-starter 是一个基于springboot的快速集成多数据源的启动器。 其支持 Jdk 1.7+, SpringBoot 1.4.x 1.5.x 2.x.x。 文档 | D

baomidou 3.8k Dec 31, 2022
Dynamic Configuration Capability for SpringBoot Application

Spring Boot Dynamic Config Hot-reload your SpringBoot configurations, with just a '@DynamicConfig' annotation, the simplest solution, ever. English 简体

Joey Yang 153 Jan 3, 2023