J-Security Center

Title: TWIG Webmail SQL Query Modification Vulnerability

Severity: HIGH

Description:

TWIG Webmail contains a vulnerability which may allow for users to modify SQL queries.

When performing various database operations, form variables from web clients are included as part of the query string. TWIG Webmail does not quote values that are to be stored as integer types in query strings, nor does it ensure that the input is composed only of numeral characters. As a result, it is possible for malicious clients to send values for these variables which may alter the logic of the SQL query. It may be possible to corrupt these SQL queries so that they perform unauthorized operations when they execute.

The following example demonstrates this:

DELETE FROM table WHERE intfield=_SOMEVARIABLE_

'_SOMEVARIABLE_' is a value originating as a form variable.
intfield is an integer type column in the table we are deleting a row from.

The user can set _SOMEVARIABLE_ to the following value, which will be included in the query string:

1 OR intfield=100

The query, now with this value included, looks like this:

DELETE FROM table WHERE intfield=1 OR intfield=100

This query thus performs an unauthorized delete if a row matches the clause 'intfield=100'.

Because this script is written in PHP however, how the query can be modified is limited. PHP automatically escapes all single quotes as a security measure. If these are included in the user variable, they will be escaped and the query will fail due to syntax error. As a result of these built-in protections, more advanced query corruption may be limited.

Affected Products:

  • TWIG TWIG 2.0.0
  • TWIG TWIG 2.0.0 Beta1
  • TWIG TWIG 2.0.0 Beta2
  • TWIG TWIG 2.0.0 beta3
  • TWIG TWIG 2.0.1
  • TWIG TWIG 2.0.2
  • TWIG TWIG 2.0.3
  • TWIG TWIG 2.1.0
  • TWIG TWIG 2.1.1
  • TWIG TWIG 2.2.0
  • TWIG TWIG 2.2.1
  • TWIG TWIG 2.2.2
  • TWIG TWIG 2.2.3
  • TWIG TWIG 2.3.0
  • TWIG TWIG 2.3.1
  • TWIG TWIG 2.3.2
  • TWIG TWIG 2.4.0
  • TWIG TWIG 2.5.0
  • TWIG TWIG 2.5.1
  • TWIG TWIG 2.6.0
  • TWIG TWIG 2.6.1

References:

Juniper Networks provides this content via a wide variety of sources and production methods. If notified of errors or omissions in the content of this page, Juniper Networks, at its discretion, will modify or remove the page or leave the content as is, depending on various factors including but not limited to the reputation and authority of the party providing the notification. Please use the contact information displayed elsewhere on this page to report any errors or omissions regarding the content on this page.