Python Snippet #09

This challenge covers the review of a snippet of code written in Python

PRO
Tier
Easy
< 1 Hr.
930

Course


The Code Review Snippet challenges are designed to enhance your skills in identifying and understanding vulnerabilities within small code snippets. This challenge focuses on a Python Flask application that allows users to list files in their directories. The application imports necessary modules, sets up a route to handle requests for listing files, and dynamically creates directories based on the username provided in the URL.

The main issue with this code lies in its handling of the 'username' parameter. The application creates a directory using the 'os.system' command without properly sanitizing the input. This oversight allows an attacker to inject arbitrary commands through the 'username' parameter, potentially executing malicious code on the server. This classic example of command injection illustrates the importance of input validation and proper handling of user-supplied data to maintain application security.

Want to learn more? Get started with PentesterLab Pro! GO PRO