{"id":23855,"date":"2018-05-07T14:14:42","date_gmt":"2018-05-07T14:14:42","guid":{"rendered":"https:\/\/www.checkmarx.com\/?p=23855"},"modified":"2024-07-28T06:58:30","modified_gmt":"2024-07-28T06:58:30","slug":"redos-go","status":"publish","type":"post","link":"https:\/\/checkmarx.com\/blog\/redos-go\/","title":{"rendered":"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go"},"content":{"rendered":"<p>Go Programming Language (also known as Golang) is an open-source programming language created by Google. Go is compiled, is statically typed as in C (with garbage collection), with limited structural typing, memory safety features and CSP-style concurrent features.\u00a0In this blog post, we&#8217;ll recap Go\u2019s security posture facing Regular Expression Denial of Service (ReDoS) attacks. But first, let\u2019s start by explaining the concept of ReDoS and how such attacks can be exploited and mitigated. This blog post includes a set of practical examples using different programming languages, aiming to show how the Go implementation avoids ReDoS.<br>\n<!--more--><br>\nThe topic of this report was motivated byongoing research on the topic of Go security, where we aim to discover vulnerabilities lurking in Go packages.<br>\n<span style=\"font-size: 12px;\">func sqli() {<\/span><br>\n<span style=\"font-size: 12px;\">username := r.Form.Get(&#8220;username&#8221;)<\/span><br>\n<span style=\"font-size: 12px;\">sql := &#8220;SELECT * FROM user WHERE username='&#8221; + username + &#8220;&#8216;&#8221; row_fullname := db.QueryRow(sql)<\/span><br>\n<span style=\"font-size: 12px;\">fmt.Printf(&#8220;Welcome, %sn&#8221;, row_fullname)<\/span><br>\n<span style=\"font-size: 12px;\">}<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 1: <\/strong>Golang SQLi example<\/span><\/p>\n<h2 class=\"article-anchor\" id=\"article-anchor-1\">ReDoS<\/h2>\n<p>Regular Expression Denial of Service (ReDoS) is an algorithmic complexity attack that provokes a Denial of Service (DoS). ReDos attacks are caused by a regular expression that takes a very long time to be evaluated, exponentially related with the input size. This exceptionally long time in the evaluation process is due to the implementation of the regular expression in use, for example, recursive backtracking ones.<br>\nA regular expression, better known as a \u2018regex\u2019, is a sequence of characters that defines a search pattern, used to search for one or more characters within a string. One of the handy usages of a regex is information validation, i.e., ensuring that only properly formed data is being submitted.<br>\nFor example, let\u2019s pretend that we want to apply a regular expression over the <em>username <\/em>input of listing 1. Thus, a simple regex could be:<br>\n<span style=\"font-size: 12px;\">\/^[a-zA-Z0-9_-]{3,10}$\/<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 2: <\/strong>Regex example 1<\/span><br>\nThe regular expression is contained between the slash characters and in the pattern <a href=\"#_bookmark1\">2 <\/a>regex. We start by telling the parser to find the beginning of the string (\u02c6), followed by any lowercase letter (a-z), uppercase letter (A-Z), number (0-9), an underscore, or a hyphen. The {3,10} section makes sure that the entered string has a length between three and ten characters. Finally, the $ represents the end of the string.\u00a0For this regex, if we used the input <strong>\u201d<\/strong>checkmarx<strong>\u201d <\/strong>\u00a0it would match the pattern:<\/p>\n<div id=\"attachment_23862\" style=\"width: 805px\" class=\"wp-caption alignnone\"><img decoding=\"async\" aria-describedby=\"caption-attachment-23862\" class=\"wp-image-23862\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/redosingo1.png\" alt=\"\" width=\"795\" height=\"333\"><p id=\"caption-attachment-23862\" class=\"wp-caption-text\">Figure 1: Example \u2013 Regex 1<\/p><\/div>\n<p>On the other hand, if we used a string like <strong>\u201d<\/strong>checkmarx\u2019 OR SLEEP(10)&#8211;<strong>\u201d<\/strong>\u00a0it would not match the pattern.<\/p>\n<div id=\"attachment_23863\" style=\"width: 793px\" class=\"wp-caption alignnone\"><img decoding=\"async\" aria-describedby=\"caption-attachment-23863\" class=\"wp-image-23863 \" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/redosingo2.png\" alt=\"\" width=\"783\" height=\"288\"><p id=\"caption-attachment-23863\" class=\"wp-caption-text\">Figure 2: Example \u2013 Regex 1 Fail<\/p><\/div>\n<h2 class=\"article-anchor\" id=\"article-anchor-2\">Evil Regular Expressions<\/h2>\n<p>Even though the benefits of using regexs for input validations are great, depending on the way they are written and the engine used, a malicious user can leverage it and make the application or service unavailable. Thus, evil regexs are the root cause of the ReDoS issue. They are considered evil or malicious if they can stuck on crafted input. To understand this better, let\u2019s consider the following regular expression:<br>\n<span style=\"font-size: 12px;\">\/A(B|C+)+D\/<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 3: <\/strong>Evil Regex example 1<\/span><br>\nIn this scenario, this regex pattern starts by searching for the character \u2019A.\u2019 Then, the following string must either be the character \u2019B\u2019 or one or more \u2019C\u2019s, (B|C+). The next + indicates that it can search for one or more occurrences of the previous string. Finally, the \u2019D\u2019 ensures that the string is terminated by the character \u2019D\u2019. To match this regular expression, any input of the following type would be accepted:<br>\n<span style=\"font-size: 12px;\">ABCD <\/span><br>\n<span style=\"font-size: 12px;\">ABCBD <\/span><br>\n<span style=\"font-size: 12px;\">ACD <\/span><br>\n<span style=\"font-size: 12px;\">ACBD<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 4: <\/strong>Valid input for Evil regex 1<\/span><br>\nTo show the differences between the implementations used by different languages, we created simple programs in four different languages: Python, JavaScript, PHP and Go.\u00a0All created programs use the regex from example 3.\u00a0This benchmark was done incrementing passed inputs, allowing us to visually understand the different behaviors of the program depending on the variations of the inputs.<br>\nIn the example code from listing 5, we show a simple Python implementation to evaluate the evil regex. We start by testing the valid inputs from listing 4. Then we send malicious inputs to try to get the program stuck.<br>\n<span style=\"font-size: 12px;\">regex = r&#8221;A(B|C+)+D&#8221;<\/span><br>\n<span style=\"font-size: 12px;\">test_str = raw_input(&#8220;Enter the string: &#8220;)<\/span><br>\n<span style=\"font-size: 12px;\">matches = re.finditer(regex, test_str) (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">print (&#8220;It took: %s seconds&#8221; % elapsedTime)<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 5: <\/strong>Python Regex compiler<\/span><br>\nTo craft malicious inputs, we started by incrementing valid and invalid inputs, and tweaking it according to the time differences between them. At some point, we found some relevant discrepancies. In figure 4, we show the attempted malicious payloads and the matching elapsed time for evaluation. We see that when a malicious input payload of type AC+E, where + represents one or more occurrences of the character C, is sent with more than 20 Cs, the elapsed time starts to double for each new C.<br>\n<img decoding=\"async\" class=\"alignnone wp-image-23912\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/forblogfirst.png\" alt=\"\" width=\"1131\" height=\"439\"><br>\nThe same principle was applied to the other languages and we maintained the input cases in order to compare the results. The next example is for JavaScript. Listing 6 shows the JS code snippet:<br>\n<span style=\"font-size: 12px;\">const regex = \/A(B|C+)+D\/g; (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">let m;<\/span><br>\n<span style=\"font-size: 12px;\">while ((m = regex.exec(str)) !== null) { (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">} (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">console.log(&#8220;It took: &#8221; + seconds + &#8221; seconds&#8221;);<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 6: <\/strong>JS Regex compiler<\/span><br>\nThe obtained results for the JavaScript implementation are as follows:<br>\n<img decoding=\"async\" class=\"alignnone wp-image-23970\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/graphic-for-higher-education-case-study-5.png\" alt=\"\" width=\"866\" height=\"434\"><br>\nThe next example is PHP:<br>\n<span style=\"font-size: 12px;\">$re = &#8216;\/A(B|C+)+D\/&#8217;;<\/span><br>\n<span style=\"font-size: 12px;\">preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">echo $timediff.&#8221; seconds&#8221;;<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 7: <\/strong>PHP Regex compiler<\/span><br>\nWhere the results from figures 7 and 8 produced these results:<br>\n<img decoding=\"async\" class=\"alignnone wp-image-23969\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/graphic-for-higher-education-case-study-6.png\" alt=\"\" width=\"894\" height=\"448\"><br>\nFinally, an example for Go. We created the following program:<br>\n<span style=\"font-size: 12px;\">func main() {<\/span><br>\n<span style=\"font-size: 12px;\">re := regexp.MustCompile(`A(B|C+)+D`) (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">for i, match := range re.FindAllString(str, -1) { fmt.Println(match, &#8220;found at index&#8221;, i)<\/span><br>\n<span style=\"font-size: 12px;\">} (&#8230;)<\/span><br>\n<span style=\"font-size: 12px;\">fmt.Println(&#8220;It took:&#8221;, elapsed.Seconds(), &#8220;seconds&#8221;)<\/span><br>\n<span style=\"font-size: 12px;\">}<\/span><br>\n<span style=\"font-size: 12px;\"><strong>Listing 8: <\/strong>Go Regex compiler<\/span><br>\nAnd produced the following results:<br>\n<img decoding=\"async\" class=\"alignnone wp-image-23919\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/forblog44.png\" alt=\"\" width=\"1097\" height=\"363\"><br>\nWe can see that the results from PHP (8) and Go (10) implementations are much different from the Python (4) and JavaScript (6) results. The malicious inputs used in Python and JavaScript generated exponential time increments, versus the linear time responses for PHP and Go.<br>\nIn the PHP regex implementation, we used the Perl Compatible Regular Expressions (PCRE) library <a href=\"https:\/\/php.net\/manual\/en\/book.pcre.php\">1<\/a>, which uses\u00a0backreferences. The official regex package [2] implemented in Go uses the RE2 engine <a href=\"https:\/\/github.com\/google\/re2\">2<\/a>, which does not support backreferences, and guarantees a linear time execution while avoiding regex denial of service.<br>\nIn table 1, we summarize the obtained results for each programming language, where it is displayed the elapsed time in seconds for each input that was tested. For the purpose of this post, we only tested ten inputs, starting with \u00a020 \u2019C\u2019 characters and incrementing one unit. This clarifies that for the Python and JavaScript implementations the time doubles when a new C is added.<br>\nFinally, in the chart seen in figure 11, it becomes visually clear what the discrepancies are between the results and places of the performances of PHP and Go side by side.<br>\n<img decoding=\"async\" class=\"wp-image-23928 alignnone\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/table1.png\" alt=\"\" width=\"831\" height=\"283\"><br>\n<img decoding=\"async\" class=\"size-full wp-image-23930 alignnone\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/benchmark1.png\" alt=\"\" width=\"563\" height=\"339\"><\/p>\n<h2 class=\"article-anchor\" id=\"article-anchor-3\">Behind the Curtains<\/h2>\n<p>The most commonly used algorithms to implement regular expression matching are:<\/p>\n<ul>\n<li>Perl-based<\/li>\n<li>NFA-based<\/li>\n<\/ul>\n<p>So far, we have seen how the PHP implementation uses the PCRE, Perl-based, and Go uses the RE2. In any case, to accomplish the regular expression matching, the engine builds a Nondeterministic Finite Automaton (NFA), which is a finite state machine where for each pair of state and input symbol, there may be several possible next states. Hence, for each input symbol, the NFA will transit to a new state until all the input symbols have been consumed. This will try all paths of the NFA until it reaches an accepting state, that is, where a match occurred or all the paths were attempted but with no match.<br>\nConsidering the regex <strong>\u02c6(a+)+$ <\/strong>and its correspondent NFA:<br>\n<img decoding=\"async\" class=\"wp-image-23934 alignnone\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/figure12.png\" alt=\"\" width=\"588\" height=\"219\"><br>\nWe can use the same methodology of inputting different sizes in order to understand the NFA behavior. To this, if we choose the input <strong>aaaaX<\/strong>, 16 possible paths will exist in the graph from figure 12.<br>\nIf we modify the input to <strong>aaaaaaaaaaX, <\/strong>it will have 1024 steps. And if we change it to <strong>aaaaaaaaaaaaaaaaX, <\/strong>65536 possible paths will be generated.\u00a0Each additional \u201d<strong>a<\/strong>\u201d doubles this number. This behavior is an extreme case and happens because the algorithm will go through all the possible paths until failing.<br>\nWhat happens behind the curtains is that any time a symbol is being tested by the engine and it fails to match the next one, it will backtrack and look for another way to compile the previous symbol. If this path gets too long, the number of backtracking steps will eventually become very large, resulting in catastrophic backtracking, leading to a possible denial of service.<br>\nIf we take the example of the regular expression from listing 3, and with the help from the\u00a0<a href=\"https:\/\/regex101.com\/\" target=\"_blank\" rel=\"noopener\">regex101<\/a>\u00a0website, we can resume this behavior in a table, where displayed is the number of steps taken for a target input string.<\/p>\n<div id=\"attachment_23967\" style=\"width: 525px\" class=\"wp-caption alignnone\"><img decoding=\"async\" aria-describedby=\"caption-attachment-23967\" class=\"wp-image-23967\" title=\"Table 2: PCRE (PHP) -\u00a0Benchmark\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/graphic-for-higher-education-case-study-3.png\" alt=\"Table 2: PCRE (PHP) -\u00a0Benchmark\" width=\"515\" height=\"257\"><p id=\"caption-attachment-23967\" class=\"wp-caption-text\">Table 2: PCRE (PHP) &#8211;\u00a0Benchmark<\/p><\/div>\n<p>From table 2, it is clear that each time we incremented the number of C\u2019s by one unit, the engine took twice the number of steps. Using this engine from the regex101 website, if more than 998 C\u2019s are used, it will respond with a <em>catastrophic backtracking <\/em>message:<br>\n<img decoding=\"async\" class=\"wp-image-23939 alignnone\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/figure13.png\" alt=\"\" width=\"798\" height=\"282\"><br>\nThis is the <strong>turning point <\/strong>between the PHP and Go implementations. In subsection 2.2, we saw that for the input used, the results in terms of elapsed time were very similar, but we did not test for extremely large inputs, as seen in figure 13, crashes the PHP implementation. This is avoided in Go.<br>\nAs a matter of fact, all programming language engines (from <a href=\"https:\/\/regex101.com\" target=\"_blank\" rel=\"noopener\">this website<\/a>) will have disastrous behaviors with this input &#8211; except for Go. JavaScript will respond with a <em>timeout <\/em>and the Python with a <em>catastrophic backtracking<\/em>. As for Go, it will resolve the string input in approximately 218ms. These results can be consulted <a href=\"https:\/\/regex101.com\/r\/zbnwSp\/1\" target=\"_blank\" rel=\"noopener\">here<\/a>.<br>\n<strong>2.3.1 Easter Egg<\/strong><br>\nIt is also important that websites testing regular expressions can properly detect catastrophic cases:<br>\n<img decoding=\"async\" class=\"wp-image-23966\" title=\"Figure 14: Catastrophic Backtracking on Pythex\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/graphic-for-higher-education-case-study-2.png\" alt=\"Figure 14: Catastrophic Backtracking on Pythex\" width=\"723\" height=\"362\"><\/p>\n<p style=\"text-align: center;\"><strong>Figure 14<\/strong>: Catastrophic Backtracking on Pythex<\/p>\n<p>A malicious user could take advantage of the lack of validation in this website to provoke a denial of service. Another example happens in the <a href=\"https:\/\/www.debuggex.com\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.debuggex.com\/ <\/a>website. When a vulnerable regular expression is used with a malicious input, it will hang the page.<br>\n<img decoding=\"async\" class=\"wp-image-23941 alignnone\" title=\"Figure 13: Example - Catastrophic Backtracking\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/figure13-1.png\" alt=\"Figure 13: Example - Catastrophic Backtracking\" width=\"764\" height=\"270\"><\/p>\n<h2 class=\"article-anchor\" id=\"article-anchor-4\">Conclusion<\/h2>\n<p>In this blog post, we recapped what a regular expression is and how can it be leveraged to provoke a denial of service. We go through a set of examples where behaviors of different engines are shown. Specifically, we emphasize the Go behavior.<br>\nDespite possible recommendations and workarounds to avoid ReDoS, which revolve around the usual input sanitization, the best measure is to target the root cause, and so, focus on the implemented algorithm.<br>\nThe implementation provided by the Go package (<em>regexp<\/em>) is guaranteed to run in time linear in the size of the input. A property that is not guaranteed by most open-source implementations of regular expressions [3].<\/p>\n<h4 style=\"text-align: center;\">Using open-source, but not sure what versions and components are in use?<br>\n<a href=\"https:\/\/checkmarx.com\/cxsca-open-source-scanning\/\" target=\"_blank\" rel=\"noopener\">Get a single holistic view of your application portfolio<\/a>\n<\/h4>\n<h3>References<\/h3>\n<ul>\n<li><span style=\"font-size: 16px;\"><em>ReDoS<\/em>, available at <a href=\"https:\/\/www.owasp.org\/index.php\/Regular_expression_Denial_of_Service_-_ReDoS\" target=\"_blank\" rel=\"noopener\">https:\/\/www.owasp.org\/index.php\/Regular expression Denial of Service &#8211; ReDoS<\/a>.<\/span><\/li>\n<li><span style=\"font-size: 16px;\"><em>Package regexp<\/em>, available at <a href=\"https:\/\/golang.org\/pkg\/regexp\/\" target=\"_blank\" rel=\"noopener\">https:\/\/golang.org\/pkg\/regexp\/<\/a>.<\/span><\/li>\n<li><span style=\"font-size: 16px;\"><em>Regular Expression Matching Can Be Simple And Fast<\/em>, available at <a href=\"https:\/\/swtch.com\/~rsc\/regexp\/regexp1.html\" target=\"_blank\" rel=\"noopener\">https:\/\/swtch.com\/~rsc\/regexp\/regexp1.html\u00a0<\/a><\/span><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Go Programming Language (also known as Golang) is an open-source programming language created by Google. Go is compiled, is statically typed as in C (with garbage collection), with limited structural typing, memory safety features and CSP-style concurrent features.\u00a0In this blog post, we&#8217;ll recap Go\u2019s security posture facing Regular Expression Denial of Service (ReDoS) attacks. But [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":57424,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[84],"tags":[97,98,99,100,101,102,103,104,105,106,107,108,109,110],"class_list":["post-23855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-catastrophic-backtracking","tag-denial-of-service","tag-go","tag-golang","tag-input-sanitization","tag-javascript","tag-nondeterministic-finite-automaton-nfa","tag-open-source-programming-language","tag-php","tag-python","tag-redos","tag-regex","tag-regular-expression-denial-of-service","tag-regular-expressions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Diving Deep into Regular Expression Denial of Service (ReDoS) in Go<\/title>\n<meta name=\"description\" content=\"Join us to examine Regular Expression Denial of Service (ReDoS) attacks and how such attacks can be exploited and mitigated, plus how Go avoids ReDoS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/checkmarx.com\/blog\/redos-go\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go\" \/>\n<meta property=\"og:description\" content=\"Join us to examine Regular Expression Denial of Service (ReDoS) attacks and how such attacks can be exploited and mitigated, plus how Go avoids ReDoS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/checkmarx.com\/blog\/redos-go\/\" \/>\n<meta property=\"og:site_name\" content=\"Checkmarx\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-07T14:14:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-28T06:58:30+00:00\" \/>\n<meta name=\"author\" content=\"Erez Yalon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.checkmarx.com\/wp-content\/uploads\/2018\/05\/twitter-redos-in-go-1.png\" \/>\n<meta name=\"twitter:creator\" content=\"@checkmarx\" \/>\n<meta name=\"twitter:site\" content=\"@checkmarx\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Erez Yalon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/\"},\"author\":{\"name\":\"Erez Yalon\",\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/person\/cb0710e4bc79b776a473a974986cc123\"},\"headline\":\"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go\",\"datePublished\":\"2018-05-07T14:14:42+00:00\",\"dateModified\":\"2024-07-28T06:58:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/\"},\"wordCount\":1865,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/checkmarx.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg\",\"keywords\":[\"Catastrophic Backtracking\",\"Denial of Service\",\"Go\",\"Golang\",\"input sanitization\",\"JavaScript\",\"Nondeterministic Finite Automaton (NFA)\",\"open-source programming language\",\"PHP\",\"Python\",\"ReDoS\",\"regex\",\"Regular Expression Denial of Service\",\"Regular Expressions\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/checkmarx.com\/blog\/redos-go\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/\",\"url\":\"https:\/\/checkmarx.com\/blog\/redos-go\/\",\"name\":\"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go\",\"isPartOf\":{\"@id\":\"https:\/\/checkmarx.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg\",\"datePublished\":\"2018-05-07T14:14:42+00:00\",\"dateModified\":\"2024-07-28T06:58:30+00:00\",\"description\":\"Join us to examine Regular Expression Denial of Service (ReDoS) attacks and how such attacks can be exploited and mitigated, plus how Go avoids ReDoS.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/checkmarx.com\/blog\/redos-go\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage\",\"url\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg\",\"contentUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg\",\"width\":1024,\"height\":512},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/checkmarx.com\/#website\",\"url\":\"https:\/\/checkmarx.com\/\",\"name\":\"Checkmarx\",\"description\":\"The world runs on code. We secure it.\",\"publisher\":{\"@id\":\"https:\/\/checkmarx.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/checkmarx.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/checkmarx.com\/#organization\",\"name\":\"Checkmarx\",\"url\":\"https:\/\/checkmarx.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg\",\"contentUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg\",\"width\":1,\"height\":1,\"caption\":\"Checkmarx\"},\"image\":{\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis\",\"https:\/\/x.com\/checkmarx\",\"https:\/\/www.youtube.com\/user\/CheckmarxResearchLab\",\"https:\/\/www.linkedin.com\/company\/checkmarx\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/person\/cb0710e4bc79b776a473a974986cc123\",\"name\":\"Erez Yalon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/89d2fa04735f99d8297d6cf7abe12b74e420dd8f431dccf12f3155689c53ad43?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/89d2fa04735f99d8297d6cf7abe12b74e420dd8f431dccf12f3155689c53ad43?s=96&d=mm&r=g\",\"caption\":\"Erez Yalon\"},\"url\":\"https:\/\/checkmarx.com\/author\/erezy\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go","description":"Join us to examine Regular Expression Denial of Service (ReDoS) attacks and how such attacks can be exploited and mitigated, plus how Go avoids ReDoS.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/checkmarx.com\/blog\/redos-go\/","og_locale":"en_US","og_type":"article","og_title":"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go","og_description":"Join us to examine Regular Expression Denial of Service (ReDoS) attacks and how such attacks can be exploited and mitigated, plus how Go avoids ReDoS.","og_url":"https:\/\/checkmarx.com\/blog\/redos-go\/","og_site_name":"Checkmarx","article_publisher":"https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis","article_published_time":"2018-05-07T14:14:42+00:00","article_modified_time":"2024-07-28T06:58:30+00:00","author":"Erez Yalon","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.checkmarx.com\/wp-content\/uploads\/2018\/05\/twitter-redos-in-go-1.png","twitter_creator":"@checkmarx","twitter_site":"@checkmarx","twitter_misc":{"Written by":"Erez Yalon","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/checkmarx.com\/blog\/redos-go\/#article","isPartOf":{"@id":"https:\/\/checkmarx.com\/blog\/redos-go\/"},"author":{"name":"Erez Yalon","@id":"https:\/\/checkmarx.com\/#\/schema\/person\/cb0710e4bc79b776a473a974986cc123"},"headline":"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go","datePublished":"2018-05-07T14:14:42+00:00","dateModified":"2024-07-28T06:58:30+00:00","mainEntityOfPage":{"@id":"https:\/\/checkmarx.com\/blog\/redos-go\/"},"wordCount":1865,"commentCount":0,"publisher":{"@id":"https:\/\/checkmarx.com\/#organization"},"image":{"@id":"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage"},"thumbnailUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg","keywords":["Catastrophic Backtracking","Denial of Service","Go","Golang","input sanitization","JavaScript","Nondeterministic Finite Automaton (NFA)","open-source programming language","PHP","Python","ReDoS","regex","Regular Expression Denial of Service","Regular Expressions"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/checkmarx.com\/blog\/redos-go\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/checkmarx.com\/blog\/redos-go\/","url":"https:\/\/checkmarx.com\/blog\/redos-go\/","name":"Diving Deep into Regular Expression Denial of Service (ReDoS) in Go","isPartOf":{"@id":"https:\/\/checkmarx.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage"},"image":{"@id":"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage"},"thumbnailUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg","datePublished":"2018-05-07T14:14:42+00:00","dateModified":"2024-07-28T06:58:30+00:00","description":"Join us to examine Regular Expression Denial of Service (ReDoS) attacks and how such attacks can be exploited and mitigated, plus how Go avoids ReDoS.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/checkmarx.com\/blog\/redos-go\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/checkmarx.com\/blog\/redos-go\/#primaryimage","url":"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg","contentUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2018\/05\/2017-03-CHE-1859-w-Websitefacelift-blog4.jpg","width":1024,"height":512},{"@type":"WebSite","@id":"https:\/\/checkmarx.com\/#website","url":"https:\/\/checkmarx.com\/","name":"Checkmarx","description":"The world runs on code. We secure it.","publisher":{"@id":"https:\/\/checkmarx.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/checkmarx.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/checkmarx.com\/#organization","name":"Checkmarx","url":"https:\/\/checkmarx.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/","url":"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg","contentUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg","width":1,"height":1,"caption":"Checkmarx"},"image":{"@id":"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis","https:\/\/x.com\/checkmarx","https:\/\/www.youtube.com\/user\/CheckmarxResearchLab","https:\/\/www.linkedin.com\/company\/checkmarx"]},{"@type":"Person","@id":"https:\/\/checkmarx.com\/#\/schema\/person\/cb0710e4bc79b776a473a974986cc123","name":"Erez Yalon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/checkmarx.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/89d2fa04735f99d8297d6cf7abe12b74e420dd8f431dccf12f3155689c53ad43?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/89d2fa04735f99d8297d6cf7abe12b74e420dd8f431dccf12f3155689c53ad43?s=96&d=mm&r=g","caption":"Erez Yalon"},"url":"https:\/\/checkmarx.com\/author\/erezy\/"}]}},"_links":{"self":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/posts\/23855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/comments?post=23855"}],"version-history":[{"count":0,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/posts\/23855\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/media\/57424"}],"wp:attachment":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/media?parent=23855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/categories?post=23855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/tags?post=23855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}