Skip to main content

Inappropriate coding practices - Eval function


The eval function is used with the input of request data, such as url params or request headers, this data is not properly validated and can lead to statements being injected to execute commands on the server.


  • Execute commands on the server.
  • Send expressions that saturate the server.


Perform validations over user data entry.


Attacker authenticated from the Internet.

Expected Remediation Time

⌚ 120 minutes.


Default score using CVSS 3.1. It may change depending on the context of the vulnerability.


  • Attack vector: N
  • Attack complexity: L
  • Privileges required: L
  • User interaction: N
  • Scope: U
  • Confidentiality: L
  • Integrity: L
  • Availability: L


  • Exploit code madurity: P
  • Remediation level: X
  • Report confidence: X


  • Vector string: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L/E:P/RL:X/RC:X
  • Score:
    • Base: 6.3
    • Temporal: 6.0
  • Severity:
    • Base: Medium
    • Temporal: Medium

Code Examples

Compliant code

All user inputs are validated and sanitized before being evaluated

def grantAccess(urlInput):
clearInput = clearUrl(urlInput)
userId = getSearchParams(clearInput)
if eval(expression, {}, {"url":urlInput}):
//Grant permissions
return None

Non compliant code

The application uses the eval function with unvalidated user inputs

def grantAccess(urlInput):
userId = getSearchParams(urlInput)
if eval(expression, {}, {"url":urlInput}):
//Grant permissions
return None


free trial

Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.