Skip to content

Critical Security Vulnerability: SQL Injection (SQLi) #13

Description

@codeCraft-Ritik

Description:

The application directly embeds user-provided data from $_POST variables into SQL query strings without sanitization or parameterization. This allows an attacker to manipulate the query logic by inputting special SQL characters (like ', --, or ;), potentially leading to unauthorized data access, modification, or deletion.

Where the issue is: File: home.php.

Specific Code:
Inside the guestdetailsubmit block, the query for inserting reservations is built using raw variables: $sql = "INSERT INTO roombook(...) VALUES ('$Name','$Email','$Country',...)";.

How to fix it: Use Prepared Statements with bound parameters. This ensures that user input is treated strictly as data and not as executable code.

$stmt = $conn->prepare("INSERT INTO roombook(Name, Email, Country) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $Name, $Email, $Country);
$stmt->execute();

Note: While index.php contains a prepareAndExecute helper function, it is not utilized in home.php or other administrative files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions