Jira (PUP-11213) Puppet/Puppetserver can be taken out by bad regex

114 views
Skip to first unread message

Alexander Fisher (Jira)

unread,
Aug 20, 2021, 8:15:03 AM8/20/21
to puppe...@googlegroups.com
Alexander Fisher created an issue
 
Puppet / Bug PUP-11213
Puppet/Puppetserver can be taken out by bad regex
Issue Type: Bug Bug
Affects Versions: PUP 7.9.0, PUP 6.24.0
Assignee: Unassigned
Components: Compiler
Created: 2021/08/20 5:14 AM
Priority: Normal Normal
Reporter: Alexander Fisher

Puppet Version: 6.24.0 7.10.0
Puppet Server Version: N/A
OS Name/Version: N/A

A 'Runaway Regular Expression' in a single host's manifests can denial of service all your puppetservers.

Desired Behavior:

Puppet to detect that parsing a regex will take forever and fail the compilation.

Actual Behavior:

**Puppet compilation never finishes and puppetservers become unavailable.

 

The issue can be reproduced with 'puppet apply' eg.

puppet apply -t -e 'assert_type(Pattern[/\A-----BEGIN PGP PRIVATE KEY BLOCK-----\n(.*\n?)+-----END PGP PRIVATE KEY BLOCK-----\Z/], "-----BEGIN PGP PRIVATE KEY BLOCK-----\nfoo\n-----END PGP PRIVATE KEY BLOCK-----")'

The above command will never exit (given an actual key and not just 'foo' I suspect the heat death of the universe might occur first!).

In the context of puppetserver, the jruby process is never returned to the pool.  Eventually, all jruby processes across all puppetservers are taken up and all other requests fail with "Attempt to borrow a JRubyInstance from the pool timed out" errors.

 

https://www.sysbee.net/blog/sysbee-blog/puppet-timeouts/ describes the same issue (but in that case, the regex was just very very slow, but did eventually parse).

Some online regex testing tools see the issue and refuse to parse the regex. eg.

"Rubular suspects this regex will take forever to parse. Regexes of this sort make Rubular sad."

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Aug 20, 2021, 5:20:02 PM8/20/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-11213
 
Re: Puppet/Puppetserver can be taken out by bad regex

In order to detect this case, we'd need to have access to low-level data structures for the compiled regex. In theory that seems possible using ruby's builtin https://github.com/kkos/oniguruma, but I don't know about JRuby...

Ciprian Badescu (Jira)

unread,
Sep 21, 2021, 5:57:03 AM9/21/21
to puppe...@googlegroups.com

Thank you for filing this issue. While we agree this is an improvement, addressing this issue would require a substantial architecture change that we do not anticipate being able to undertake due to other issues taking precedence. As such, this ticket will be closed as “Won’t Fix”. We may revisit this at a later time, and if so, will re-open this ticket.

Reply all
Reply to author
Forward
0 new messages