facebook / facebook/duckling

Time interval data causing hang (potential regex dos vulnerability)

Open
#338 5 comments 5 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
4.3k
Forks
740
PR merge metrics
No merged PRs in 30d

Description

While running duckling over a large set of data, I ran across a particular example that caused it to hang reproducibly. Trying to extract `time` from the following text:
```
from 10.00am on Friday 15th April 2016 until 10.00am on Tuesday 19th April 2016
```

This example does not cause a crash or traceback, it just causes an infinite hang until the thread is killed. My best guess is
- a regex dos caused by a badly written pattern
- a recursive call function call

Both clauses (`from` and `until`) need to be present, neither is sufficient to cause a crash on its own. Removing trivial parts of the text allows the function call to return:

```
# empty response (thread killed)
"from 10.00am on Friday 15th April 2016 until 10.00am on Tuesday 19th April 2016"
# very slow
"from 10.00am Friday 15 April 2016 until 10.00am Tuesday 19 April 2016"
# works
"from 10.00am Friday 15 April until 10.00am Tuesday 19 April"
```

---

See #339 for a branch reproducing this case.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.