This project contains three demonstrations of common security vulnerabilities, created with the help of the Gemini CLI.
To run these demos, you will need the following dependencies installed:
- Gemini CLI: For interacting with the Gemini large language model.
- Python 3: For running the Python scripts and tests.
- Terraform: For the insecure Google Cloud Storage demo.
- Folder:
python-command-injection
The greeter.py script contains a command injection vulnerability. It uses os.system() to execute a command that includes unsanitized user input. A malicious user could provide input like && rm -rf / to execute arbitrary commands on the system.
greeter.py: The vulnerable Python script.test_greeter.py: A "happy path" test for the script.
To run the test, navigate to the python-command-injection directory and run:
python3 -m unittest test_greeter.py-
Navigate to the
python-command-injectiondirectory. -
Run the
greeter.pyscript with a malicious payload. For example, to execute thewhoamicommand, you can run:python3 greeter.py "; whoami" -
You will see the output of the
whoamicommand, which is your username.
- Folder:
javascript-xss
The index.html file demonstrates a cross-site scripting (XSS) vulnerability. It uses Vue.js with the v-html directive to render user input directly into the DOM. A malicious user could inject script tags (<script>alert('XSS!')</script>) to execute arbitrary JavaScript in the user's browser.
index.html: The vulnerable HTML file.test_xss_structure.py: A test that checks the structure of the HTML file.
-
Open the
index.htmlfile in a web browser. -
In the input field, type the following and press Enter:
<script>alert('XSS!')</script>
-
You will see an alert box pop up, demonstrating that the injected script was executed.
- Folder:
terraform-gcs-insecure-bucket
The main.tf file defines a Google Cloud Storage bucket with a public-read ACL. The iam_member resource grants roles/storage.objectViewer to allUsers, making all objects in the bucket publicly accessible. This is a common misconfiguration that can lead to data breaches.
main.tf: The insecure Terraform configuration.test_terraform_validation.py: A test that validates the insecure configuration (requires Terraform to be installed).
To run the validation test (assuming you have Terraform installed and configured), navigate to the terraform-gcs-insecure-bucket directory and run:
python3 -m unittest test_terraform_validation.py