digininja / DVWA

Damn Vulnerable Web Application (DVWA)
GNU General Public License v3.0
10.36k stars 3.65k forks source link

Container image 312293e does not connect to the database #604

Closed JGillam closed 8 months ago

JGillam commented 10 months ago

Describe the bug When building with container image tagged 312293e, the following exception occurs: Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/www/html/dvwa/includes/dvwaPage.inc.php:508 Stack trace: #0 /var/www/html/dvwa/includes/dvwaPage.inc.php(508): mysqli_connect('127.0.0.1', 'dvwa', Object(SensitiveParameterValue), '', '3306') #1 /var/www/html/login.php(8): dvwaDatabaseConnect() #2 {main} thrown in /var/www/html/dvwa/includes/dvwaPage.inc.php on line 508

Using the previous container (1fb5078) works normally. I have not had a chance to look into why yet (I'm working with a class on this today) and plan to follow up with more details later.

To Reproduce This is a container build issue, simply starting with the :latest container from this repo is causing the problem for me, and simply rolling back to :1fb5078 resolves it.

note: I did not provide additional detail below - but will attempt to fill in more detail later today.

Logs Include the last five lines of the Apache log file from directly after the problem happened.

Expected behaviour A clear and concise description of what you expected to happen.

What have you done to help fix the issue yourself? What have you tried, what research have you done, what changes have you made.

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

Additional context Add any other context about the problem here.

digininja commented 10 months ago

I accepted a PR this morning which changed how the database connection strings worked, I'll roll it back.

digininja commented 10 months ago

Try now.

On Tue, 16 Jan 2024 at 19:52, Jason @.***> wrote:

Describe the bug When building with container image tagged 312293e https://github.com/digininja/DVWA/commit/312293edbc2dd8f77bc33c4beec3ad71b21d6396, the following exception occurs: Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/www/html/dvwa/includes/dvwaPage.inc.php:508 Stack trace: #0 /var/www/html/dvwa/includes/dvwaPage.inc.php(508): mysqli_connect('127.0.0.1', 'dvwa', Object(SensitiveParameterValue), '', '3306') #1 /var/www/html/login.php(8): dvwaDatabaseConnect() #2 {main} thrown in /var/www/html/dvwa/includes/dvwaPage.inc.php on line 508

Using the previous container (1fb5078 https://github.com/digininja/DVWA/commit/1fb50789b269e34428b99fc13d2d97bae898cf10) works normally. I have not had a chance to look into why yet (I'm working with a class on this today) and plan to follow up with more details later.

To Reproduce This is a container build issue, simply starting with the :latest container from this repo is causing the problem for me, and simply rolling back to :1fb5078 resolves it.

note: I did not provide additional detail below - but will attempt to fill in more detail later today.

Logs Include the last five lines of the Apache log file from directly after the problem happened.

Expected behaviour A clear and concise description of what you expected to happen.

What have you done to help fix the issue yourself? What have you tried, what research have you done, what changes have you made.

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

  • OS: [e.g. Windows, Ubuntu]
  • Database and Version [e.g. MySQL, MariaDB, 10.5.12-MariaDB]
  • PHP Version [e.g. 7.4.25]
  • Installed PHP modules

Additional context Add any other context about the problem here.

— Reply to this email directly, view it on GitHub https://github.com/digininja/DVWA/issues/604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4SWKD764HGA2NWEVBBUDYO3K65AVCNFSM6AAAAABB5LZ5UOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DINZTHA4DQMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

digininja commented 10 months ago

It looks like the database server is missing from the image!

I'll have a quick play but this may be above my docker skills.

digininja commented 10 months ago

Agreed it broke after version https://github.com/digininja/DVWA/commit/1fb50789b269e34428b99fc13d2d97bae898cf10 but I can't see why.

If you can suggest anything I'll take it. The docker compose is working fine locally.

Hope the class goes well.

JGillam commented 10 months ago

I believe I found the source of the problem. I build container labs for students using a template to dynamically generate compose files. It appears an expected environment variable passed through compose was renamed from DB_SERVER to DVWA_DB_SERVER.

So I can fix this on my end by updating my template. In fact, I will simply add both keys. Sorry for the fire drill.

digininja commented 10 months ago

Could you have a look at this PR that I reverted, should I put this back or not?

https://github.com/digininja/DVWA/compare/master...revert-605-revert-592-env-config?expand=1

On Wed, 17 Jan 2024 at 12:29, Jason @.***> wrote:

I believe I found the source of the problem. I build container labs for students using a template https://github.com/SamuraiWTF/shogun/blob/main/lab_configs/docker_compose_templates/dvwa.yaml to dynamically generate compose files. It appears an expected environment variable passed through compose was renamed from DB_SERVER to DVWA_DB_SERVER.

So I can fix this on my end by updating my template. In fact, I will simply add both keys. Sorry for the fire drill.

— Reply to this email directly, view it on GitHub https://github.com/digininja/DVWA/issues/604#issuecomment-1895711784, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4SWMS536ICLHWC4PWAADYO672DAVCNFSM6AAAAABB5LZ5UOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJVG4YTCNZYGQ . You are receiving this because you commented.Message ID: @.***>