r/PHPhelp • • Feb 08 '25

Security issue with script to fetch data dynamically

Hi,

I'm working on a PHP script to serve as a unified script for all frontend table pages. It functions in a way that the frontend sends the table name and column names, and the backend script then retrieves the data. This approach avoids loading all the data at once, which can be time-consuming for large datasets. The script also supports search and conditional queries.

I posted this on r/php for assistance, but I was informed that the script has several security vulnerabilities. The post request can be intercepted, allowing users to query any table they desire. I'm hoping someone can help me address these issues.

Here's the GitHub repository for the project: https://github.com/aliosayle/php-datatable-with-backed-processing.git

1 Upvotes

27 comments sorted by

View all comments

Show parent comment

0

u/colshrapnel Feb 09 '25

Not sure what are you talking about. Changing this particular query to prepared statement wouldn't change anything, whether it's a "table enumeration" or "potential RCE" or "SQL injection".

For this query, only your other suggestion, "use an allow list of tables" is applicable and actually prevents all sorts of injections.

But making it a prepared statement won't add any security at all.