Skip to content

Conversation

odaysec
Copy link
Contributor

@odaysec odaysec commented Jul 9, 2025

eval(request.params.script.code);

Directly evaluating user input (for an HTTP request parameter) as code without properly sanitizing the input first allows an attacker arbitrary code execution. This can occur when user input is treated as JavaScript, or passed to a framework which interprets it as an expression to be evaluated. Examples include AngularJS expressions or JQuery selectors.

fix the issue, we should replace the use of eval() with a safer alternative. Instead of directly evaluating the code, we can create a controlled sandboxed environment to execute the script securely. One way to do this in modern JavaScript is by using a Function constructor, which can limit the scope of the executed code. Additionally, we can define an explicit API for the script to interact with, restricting its capabilities.

  1. Replace the eval() call on line 106 with a Function constructor to execute the code in a controlled environment.
  2. Pass only the explicitly defined API (gpyload) to the script.
  3. Ensure that the code execution occurs in strict mode to prevent potentially unsafe operations.

@CLAassistant
Copy link

CLAassistant commented Jul 9, 2025

CLA assistant check
All committers have signed the CLA.

@GammaC0de GammaC0de merged commit 909e5c9 into pyload:develop Jul 11, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants