The Websafe Test Application deploys two web applications on the host machine; one vulnerable variant, and one secure variant.
This test application focuses being lightweight, setup-free and easy-to-deploy through the use of Docker. The compose file automatically imports a premade sql dump into each database, so no prior setup using PHPmyadmin is needed.
The Websafe Site is a shopping site with various function and pages, such as user creation, login/logout, a comments wall, a cart page, and an admin page for privileged accounts.
PhpMyAdmin is a web interface designed for managing databases. In this project, this is provided for users to see what changes are being made in the database as they navigate the site, and also for debugging purposes.
The External Server simulates... an external server, lying on an internal network that the websafe site is in. This external server serves as a target and a demonstration of Server-Side Request Forgery.
- Clone this entire repository into a folder
- Go to the
php-image/
folder- Run
docker build -t <image name>
- Go out to the root folder
- To start, run
docker-compose up -d .
- To close, run
docker-compose down
WEBSAFE SITE
Username: Admin101
Password: Admin101
(Passwords are the same as the username for every default account)
DATABASE USING PHPMYADMIN
Database: insecure_database / secure_database
Root username: root
Root password: w3bs@fe_ADmin
Username: Lottie
Password: Ad0r@ble
INSECURE VARIANT
127.0.0.1:8000 > Websafe Web Application
127.0.0.1:8001 > PhpMyAdmin SQL management page
127.0.0.1:8002 > External Server
SECURE VARIANT
127.0.0.1:9000 > Websafe Web Application
127.0.0.1:9001 > PhpMyAdmin SQL management page
127.0.0.1:9002 > External Server
INSECURE VARIANT
Network address: 192.168.20.0/24
Websafe Web Application: 192.168.20.69
External Server: 192.168.20.22
SECURE VARIANT
Network address: 192.168.40.0/24
Websafe Web Application: 192.168.40.69
External Server: 192.168.40.22
- Removed the "code" design element from both stylesheets
- Adjusted the Compose file
- Updated this README file to not speak nonsense (kind of)
- Added better descriptions for this README file
- Added "credentials" section for this README file.
- Updated
INSECURE_SERVER/welcome.txt
andSECURE_SERVER/welcome.txt
- Cleaned up comments for
design.css
on secure and insecure sites
- Updated
SECURE/login/reset/secure_update_password.php
and updated designs to go along with it- Updated the logo for insecure and secure site
- Cleaned up the compose file.
- Changed container name from
webapp_secure
tosecure_webapp
.
- Replaced product images for both secure and insecure site.
- Replaced the sql dump for both secure and insecure site.
- Fixed a bug on the Insecure and Secure index webpage which prevent modals from showing when a product is clicked.
- Changed
SECURE/index.php
andINSECURE/index.php
to not show "add to cart" if the logged in user is an admin.- Updated document name for
SECURE_SERVER/index.php
to "Manage Users" instead of "Documnet".- Created a new "toggle admin" function for both insecure and secure external servers.
- Updated
SECURE/index.php
andINSECURE/index.php
to reflect this change.
- Fixed a bug where logging in on the secure site would not set the user's privilege in cookies.
- Fixed a bug on the secure site where a user cant access the cart page.
- Fixed a flaw where
SECURE/login
failed to properly encrypt UID.- Fixed a bug where
SECURE/index.php
would fail to add products to cart.- Fixed bugs where functions in
SECURE/cart/*
failed to work.- Fixed a bug where
SECURE/logout
failed to flush session storage.
- Edited
INSECURE/profile
to authenticate and store passwords in base64 encoding instead of plaintext.- Edited the login function in
SECURE/login
to encrypt the user privilege- Edited
SECURE/admin/manage
to decrypt the user privilege fromSECURE/login
and cross check the privilege cookie with the privilege object in the PHP sessions array- Edited
SECURE/logout
andSECURE/init_timeout
to clear the "privilege" cookie upon logout.- Added comments to all pages in INSECURE site to indicate examples of CWE vulnerabilities (MISSING COMMENTS FOR
A09:*
ANDCWE-20: Improper Input Validation
)- Added comments to pages in SECURE site to indicate examples of CWE mitigations (MISSING COMMENTS FOR
A09:*
ANDCWE-20: Improper Input Validation
)- Fixed a bug where
SECURE/comment/post_comment.php
didn't submit a comment, and instead redirected users to the home page.
- Fixed a bug where Secured webpage wouldn't log out properly.
- Edited
INSECURE/register
,INSECURE/login
andINSECURE/login/reset
to store passwords in base64 encoding instead of plaintext.
- Fixed database connection for
INSECURE_SERVER/*
andSECURE_SERVER/*
.- Installed functional SSRF-mitigation function for
SECURE/admin/main/index.php
.- Updated sessionTimeout function to clear session storage in secure site.
- Deleted
SECURE/register/deleteUser.php
.- Fixed database import routing for
INSECURE/admin/logs/index.php
- Changed input field for the email in
INSECURE/register
from "email" to "text" type.- Non-admin kickout check has been removed in
INSECURE/admin/main/index.php
andINSECURE/admin/manage/index.php
.- Updated pages that hardcoded the SQL connection instead of importing it.
- Changed "manage users" to "manage products" in the admin navbar.
- Cleaned up unnecessary comments in all pages.
- Added a function in
SECURE/admin/main/index.php
to mitigate SSRF, but haven't tested if it's working.
- Made the SQL con, error reporting and session timeout functions into their own PHP pages, and replaced all the existing code on (almost) all pages to
include()
them. (Haven't testing if anything is broken tho)- Changed Document Titles for all webpages so they actually reflect what the page is about instead of just "helpme" or "Document"
- Renamed the stylesheet file to
design.css
, and updated all pages accordingly- Removed non-logged-in-kickout functions on
INSECURE/cart/cart.php
andINSECURE/cart/index.php
- Changed the modals on the main page so that when a user clicks on the "Add to cart" button while not logged in, it will create an alert and redirect the user to the login page
- Made it so that sql dumps for secure and insecure are automatically imported into the database upon container start
- Changed "lottie" to "Lottie" so nothing else would break because of one stupid inconsistency
- Disabled database consistency by commenting out the "mysql" volumn in the compose files (both secure and insecure variants)
- I know this version convention is confusing but basically
2.2I1.0 + 2.2S1.0 = 2.2C1.0
right? Like you get it, no?- I basically just combined the insecure and secure versions together, like that's it
- Updated port mapping to prevent clash
- Updated container names to prevent clash
- It's just the normal site but basically no security, idk what else to say
- Security features installed on all* Websafe pages
- Security features installed on Server1 pages
- Small tweaks to some pages. Was too stupid to note which ones.
- Deleted file backups
- Deleted code snippet comments for all files
- That's it lmao