Skip to content

OpenFlights SQL Injection vulnerability in php/helper.php

High
jpatokal published GHSA-mp92-hmg2-j362 Aug 22, 2024

Package

composer jpatokal/openflights (Composer)

Affected versions

< e36b643753f20ea8a90fbf08ce260b578119bb42

Patched versions

e36b643753f20ea8a90fbf08ce260b578119bb42

Description

Summary

SQL Injection vulnerability in the gcDistance function in php/helper.php allows authenticated remote attackers to execute arbitrary SQL commands via the dst_apid parameter in php/submit.php.

Details

openflights/php/helper.php

Lines 200 to 209 in f53e452

function gcDistance($dbh, $src_apid, $dst_apid) {
// Special case: loop flight to/from same airport
if ($src_apid == $dst_apid) {
$dist = 0;
} else {
$sql = "SELECT x,y FROM airports WHERE apid=$src_apid OR apid = $dst_apid";
// Handle both OO and procedural-style database handles, depending on what type we've got.
$sth = $dbh->prepare($sql);
$sth->execute();

openflights/php/submit.php

Lines 104 to 115 in f53e452

$src_date = $_POST["src_date" . $idx];
$src_apid = $_POST["src_apid" . $idx];
$dst_apid = $_POST["dst_apid" . $idx];
$alid = trim($_POST["alid" . $idx]);
if ($alid == 0) {
// this should not be necessary, but just in case...
$alid = -1;
}
// If either the distance or duration is missing, try to calculate it by airports.
if (!$_POST["duration"] || !$_POST["distance"]) {
list($calc_distance, $calc_duration) = gcDistance($dbh, $src_apid, $dst_apid);

PoC

Send form data multi=1&alid1=3&src_date1=2023-09-11&src_apid1=1&dst_apid1=1+%3B+UPDATE+users+AS+a%2C+users+as+b+SET+a.email+%3D+b.password+WHERE+a.name+%3D+%27ouuan%27+AND+b.name+%3D+%27jpatokal%27&duration=&distance=&number=&seat=&type=&class=&reason=&registration=&note=&plane=&trid=NULL&mode=F&fid=0&param=ADD to https://openflights.org/php/submit.php.

Impact

Authenticated remote attackers can use this SQL Injection to steal user information and manipulate data like user information, flights, and airports.

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
High
Availability
None

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:H/A:N

CVE ID

No known CVE

Weaknesses

Credits