Summary

This script is possibly vulnerable to Server-side template injection attacks.
Server-side template injection occurs when user-controlled input is embedded into a server-side template, allowing users to inject template directives. This allows an attacker to inject malicious template directives and possibly execute arbitrary code on the affected server.

Impact

An attacker may inject malicious template directives and possibly execute arbitrary code on the affected server.

Actions To Take

  1. See the remedy for solution.
  2. If you are not using a database access layer (DAL), consider using one. This will help you centralize the issue. You can also use ORM (object relational mapping). Most of the ORM systems use only parameterized queries and this can solve the whole SQL injection problem.
  3. Locate all of the dynamically generated SQL queries and convert them to parameterized queries. (If you decide to use a DAL/ORM, change all legacy code to use these new libraries.)
  4. Use your weblogs and application logs to see if there were any previous but undetected attacks to this resource.

Remediation

Templates should not be created from user-controlled input. User input should be passed to the template using template parameters.

Required Skills for Successful Exploitation

There are numerous freely available tools to exploit SQL injection vulnerabilities. This is a complex area with many dependencies; however, it should be noted that the numerous resources available in this area have raised both attacker awareness of the issues and their ability to discover and leverage them. SQL injection is one of the most common web application vulnerabilities.

Severity

High

Classification

PCI v3.2-6.5.1 CAPEC-66 CWE-20 HIPAA-164.306(a) 164.308(a) ISO27001-A.14.2.5 WASC-19 OWASP 2013-A1 OWASP 2017-A1 CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H