The vulnerability is a Regular Expression Denial of Service (ReDoS) caused by inefficient regular expressions in the taro-css-to-react-native package. The provided commit c2e321a8b6fc873427c466c69f41ed0b5e8814bf directly addresses these issues by modifying the problematic regular expressions.
-
In packages/css-to-react-native/src/index.js, the transformDecls function used the regex /(\d+)px/. This regex was found to be inefficient and could lead to ReDoS. The patch replaced it with /(?<!\d)(\d+)px/, which is more efficient and less prone to backtracking issues.
-
In packages/css-to-react-native/src/transforms/rem.js, the remToPx function used the regex /(\d*\.?\d+)rem/g. This regex was also identified as a source of potential ReDoS. The patch replaced it with /(?<!\d)((?:\d*\.\d+)|\d+)rem/g, which is a more robust and efficient pattern for matching numbers followed by 'rem'.
Both functions process CSS string values, and the vulnerability could be triggered by providing specially crafted CSS input that causes the regular expression engine to enter a state of catastrophic backtracking, leading to high CPU usage and a denial of service. The identified functions are directly involved in parsing and transforming these CSS values using the vulnerable regular expressions.