🔒 fix(remote-config): Custom Signal Evaluator#3098
🔒 fix(remote-config): Custom Signal Evaluator#3098lahirumaramba wants to merge 1 commit intomainfrom
Conversation
…x Evaluation Implemented a robust sandbox around dynamic Regular Expression evaluation using Node.js's native `vm` module to enforce strict execution timeouts. This mitigates catastrophic backtracking (ReDoS) from maliciously crafted regex patterns or payload strings within the Remote Config Condition Evaluator. To avoid severe performance penalties, a single V8 evaluation context is pre-compiled and reused for all subsequent regex evaluations. Added unit test coverage for catastrophic backtracking patterns and invalid regex strings to ensure evaluation safety and event-loop integrity. Co-authored-by: lahirumaramba <55609+lahirumaramba@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request introduces a safeRegexTest function using the vm module to execute regular expression evaluations with a 100ms timeout, effectively mitigating potential ReDoS vulnerabilities. It also includes new test cases for complex and invalid regex patterns. The review feedback suggests replacing the magic number used for the timeout with a named constant to improve code maintainability.
| sharedRegexSandbox.result = false; | ||
|
|
||
| // Timeout is set to 100ms. | ||
| sharedRegexScript.runInContext(sharedRegexContext, { timeout: 100 }); |
There was a problem hiding this comment.
The timeout value 100 is a magic number. It would be more maintainable and readable to define this as a named constant, for example, REGEX_EVALUATION_TIMEOUT_MS.
| sharedRegexScript.runInContext(sharedRegexContext, { timeout: 100 }); | |
| const REGEX_EVALUATION_TIMEOUT_MS = 100; | |
| sharedRegexScript.runInContext(sharedRegexContext, { timeout: REGEX_EVALUATION_TIMEOUT_MS }); |
PR created automatically by Jules for task 8613496368164200720 started by @lahirumaramba