Skip to content

🔒 fix(remote-config): Custom Signal Evaluator#3098

Closed
lahirumaramba wants to merge 1 commit intomainfrom
fix-redos-remote-config-evaluator-8613496368164200720
Closed

🔒 fix(remote-config): Custom Signal Evaluator#3098
lahirumaramba wants to merge 1 commit intomainfrom
fix-redos-remote-config-evaluator-8613496368164200720

Conversation

@lahirumaramba
Copy link
Copy Markdown
Member

@lahirumaramba lahirumaramba commented Mar 26, 2026


PR created automatically by Jules for task 8613496368164200720 started by @lahirumaramba

…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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
sharedRegexScript.runInContext(sharedRegexContext, { timeout: 100 });
const REGEX_EVALUATION_TIMEOUT_MS = 100;
sharedRegexScript.runInContext(sharedRegexContext, { timeout: REGEX_EVALUATION_TIMEOUT_MS });

@lahirumaramba lahirumaramba changed the title 🔒 fix(remote-config): resolve ReDoS vulnerability in Custom Signal Evaluator 🔒 fix(remote-config): Custom Signal Evaluator Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant