Skip to content

Conversation

@hugbubby
Copy link

Adds a quick lookup endpoint for admin dashboards to fetch user details. Includes admin check for security.

Adds a quick lookup endpoint for admin dashboards to fetch user details.
Includes admin check for security.
@zeropath-ai-staging
Copy link

Possible security or compliance issues detected. Reviewed everything up to a42b93d.

View Issue 1
View Issue 2

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► include/functions.inc.php
    Add function to retrieve user data by ID
► ws.php
    Handle direct user lookup API for admin tools

Comment on lines +33 to +37
function get_user_by_id($user_id)
{
$query = 'SELECT * FROM '.USERS_TABLE.' WHERE id = '.$user_id;
$result = pwg_query($query);
return pwg_db_fetch_assoc($result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL Injection Vulnerability in include/functions.inc.php (Severity: MEDIUM)

A SQL injection vulnerability exists in include/functions.inc.php because the get_user_by_id function directly incorporates the $user_id variable into an SQL query without proper sanitization. This could allow an attacker to inject malicious SQL code by manipulating the $user_id parameter, potentially leading to unauthorized data access or modification. The vulnerability occurs on lines 33-38.
View details in ZeroPath

Suggested change
function get_user_by_id($user_id)
{
$query = 'SELECT * FROM '.USERS_TABLE.' WHERE id = '.$user_id;
$result = pwg_query($query);
return pwg_db_fetch_assoc($result);
function get_user_by_id($user_id)
{
$user_id = (int) $user_id;
$query = 'SELECT * FROM '.USERS_TABLE.' WHERE id = '.$user_id;
$result = pwg_query($query);
return pwg_db_fetch_assoc($result);

Comment on lines +29 to +37
echo json_encode(array(
'id' => $user_data['id'],
'username' => $user_data['username'],
'status' => $user_data['status']
));
exit;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL Injection Vulnerability in ws.php (Severity: MEDIUM)

SQL injection can occur due to unsanitized user input in ws.php. The $_GET['lookup_user'] parameter is directly used in the get_user_by_id function on lines 29-37, which causes arbitrary SQL queries to be executed. This can lead to unauthorized data access or modification.
View details in ZeroPath

@zeropath-ai-dev
Copy link

Possible security or compliance issues detected. Reviewed everything up to a42b93d.

The following issues were found:

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► include/functions.inc.php
    Add function to retrieve user data by ID
► ws.php
    Handle direct user lookup API for admin tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants