Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Create PHP code" creates broken code and encourages SQL injection #19098

Open
kamil-tekiela opened this issue Apr 6, 2024 · 1 comment
Open

Comments

@kamil-tekiela
Copy link
Contributor

Describe the bug

There exists a button that enables the user to convert an SQL query into a PHP variable. When you click "Create PHP code" a box will show up with PHP code containing a single variable called $sql which has a value assigned of the SQL being executed earlier.

To Reproduce

Steps to reproduce the behavior:

  1. Go to browse table
  2. Add a WHERE 'asd' = 'foo' clause
  3. Click on "Create PHP code"
  4. See broken code

Expected behavior

There should exist no such button. Creation of PHP code should be the responsibility of the PHP developer who will take care of proper parameterization and proper PHP/SQL syntax. The only benefit this button provides is the automatic addslashes which actually creates invalid SQL.

SELECT * FROM `sequence` WHERE \'asd\' = \'foo\';

This button promotes insecure PHP coding practices as inexperienced users may use this to create hardcoded queries and later replace the constant value with interpolated PHP variable creating SQL injection.

I suggest that this feature be removed from PMA in the next major version.

@williamdes
Copy link
Member

We should switch to pdo for examples

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

No branches or pull requests

2 participants