rapid7 / recog

Pattern recognition for hosts, services, and content
Other
662 stars 195 forks source link

http_servers: fix incorrect IP regex #353

Closed tsellers-r7 closed 3 years ago

tsellers-r7 commented 3 years ago

Description

This PR corrects a regex used for IPv4 addresses used in http_servers.xml. The regex failed to escape a . and could DoS the parser when processing very long numeric sequences.

The PR correctly escapes the period and limits the number of repeating digits allowed before the match fails.

This issue was highlighted in a PR to recog-java here: https://github.com/rapid7/recog-java/pull/7

Motivation and Context

Bug fix, performance improvement

How Has This Been Tested?

rspec with built in example tests. I have also tested the regex with Go and Rust online regex testers. Both of these languages use the RE2 engine by default.

Types of changes

Checklist: