T09 · Insecure Skill Coding Practices
- Location
scriptBackend.py:151- Finding
OS Command Injection Through Unvalidated Project Inputs
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill appears to be a Django project scaffolder, but its bundled script can run unintended shell commands from ordinary project-name, app-name, path, or model-name input.
Treat this as a Review item before installing. Only run it in a disposable directory or isolated environment, never with untrusted names or paths, and prefer a revised version that validates Django identifiers, writes files with Python APIs, uses subprocess argument lists, and pins dependencies.
scriptBackend.py:151OS Command Injection Through Unvalidated Project Inputs
scriptBackend.py:135Shell and Persistent Python Code Injection Through Model Names
scriptBackend.py:45Unsafe Shell-Based Generation of Django Source Files
scriptBackend.py:80Unpinned Dependency Installation and Ineffective Virtual-Environment Isolation
This is a confirmed tainted data flow from appName input to os.system. In the context of a scaffolding skill that encourages users to enter arbitrary names, this makes exploitation realistic and dangerous because the script is expected to run on a developer workstation with write access.
break
with open('settings.py', 'w') as f:
f.writelines(lines)
os.system(f'''echo "from django.contrib import admin
from django.urls import path, include
urlpatterns = [
This is another confirmed appName-to-shell injection path in a code-generation step. Since the script modifies project files automatically, arbitrary command execution here could also tamper with the project, install backdoors, or exfiltrate local data.
''')
os.chdir(f'../{projectName}')
os.system(f'''echo "from django.contrib import admin
from django.urls import path, include
urlpatterns = [
This is a confirmed tainted flow from path input into an os.system invocation. Because path values commonly include spaces and shell-significant characters, this is especially easy to misuse and can result in arbitrary command execution before the rest of the project is even created.
answer = input(f'{color.YELLOW}Would you like to create a venv in the desired directory: {color.END}')
if answer.lower() == 'yes' or answer.lower() == 'y':
os.system(f'python3 -m venv {path}.venv')
loading('Creating Virtual Envirement', 1)
projectName = input(f'{color.YELLOW}Choose a name for your project: {color.END}')
This is a direct tainted flow from projectName input to os.system('django-admin startproject ...'). The context increases risk because project setup tools are commonly run by developers with significant local permissions, so successful injection can fully compromise the workstation or CI environment.
os.chdir(path)
os.system('source .venv/bin/activate')
run_command('pip install django')
os.system(f'django-admin startproject {projectName}')
os.chdir(f'{path}{projectName}')
appName = input(f'{color.YELLOW}Choose a name for your app: {color.END}')
External input (network, user) flows to a code execution sink. This enables remote code execution or command injection.
appName = input(f'{color.YELLOW}Choose a name for your app: {color.END}')
os.system(f'django-admin startapp {appName}')
create = input(f'{color.YELLOW}would you like to create a requirements file: {color.END}')
if create.lower() == 'yes' or create.lower() == 'y':
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
END = '\033[0m'
CYAN_BG = '\33[1;37;40m'
os.system('clear')
print(f'''{color.PURPLE}{color.BOLD}
\t _ __ __
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
def DjangoNoRest():
os.chdir(appName)
os.system('touch urls.py')
os.system(f'''echo "from django.urls import path
from .views import *
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
def DjangoNoRest():
os.chdir(appName)
os.system('touch urls.py')
os.system(f'''echo "from django.urls import path
from .views import *
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
def DjangoNoRest():
os.chdir(appName)
os.system('touch urls.py')
os.system(f'''echo "from django.urls import path
from .views import *
urlpatterns = [
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
urlpatterns = [
path('AppRoute/', YOUR_VIEW),
]" > urls.py''')
os.system(f'''echo "from django.shortcuts import render
# Create your views here.
def YOUR_VIEW(request):
This shell command interpolates appName, which is taken from user input, into an os.system call. An attacker can supply shell metacharacters in the app name to break out of the intended command and execute arbitrary commands on the host.
break
with open('settings.py', 'w') as f:
f.writelines(lines)
os.system(f'''echo "from django.contrib import admin
from django.urls import path, include
urlpatterns = [
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
with open(f'../{projectName}/settings.py', 'w') as f:
f.writelines(lines)
os.system('touch urls.py')
os.system('touch serializers.py')
os.system(f'''echo "from rest_framework_nested import routers
from .views import *
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
f.writelines(lines)
os.system('touch urls.py')
os.system('touch serializers.py')
os.system(f'''echo "from rest_framework_nested import routers
from .views import *
router = routers.DefaultRouter()
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
urlpatterns = router.urls" > urls.py''')
os.system(f'''echo "from rest_framework.viewsets import ModelViewSet
from .models import *
from .serializers import *
This shell command interpolates appName into an os.system call when generating Django URL configuration. Because appName comes from user input, crafted input can trigger arbitrary shell command execution with the privileges of the script runner.
''')
os.chdir(f'../{projectName}')
os.system(f'''echo "from django.contrib import admin
from django.urls import path, include
urlpatterns = [
module values come from user input and are interpolated into a shell echo command that appends to models.py. This creates both command-injection risk and code-generation risk, allowing arbitrary shell execution or malicious Python code insertion into the generated project.
splitted = modulsName.split(', ')
os.chdir(appName)
for module in splitted:
os.system(f'''echo "class {module}(models.Model):
name = models.CharField(max_length=255, unique=True)
def __str__(self):
The path value is user-supplied and directly inserted into an os.system command for virtual environment creation. Crafted path input can break command boundaries and execute arbitrary OS commands.
answer = input(f'{color.YELLOW}Would you like to create a venv in the desired directory: {color.END}')
if answer.lower() == 'yes' or answer.lower() == 'y':
os.system(f'python3 -m venv {path}.venv')
loading('Creating Virtual Envirement', 1)
projectName = input(f'{color.YELLOW}Choose a name for your project: {color.END}')
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
exit(1)
os.chdir(path)
os.system('source .venv/bin/activate')
run_command('pip install django')
os.system(f'django-admin startproject {projectName}')
os.chdir(f'{path}{projectName}')
projectName is taken from user input and inserted directly into an os.system command. A malicious project name containing shell metacharacters can execute arbitrary commands, making this a straightforward command injection leading to full code execution on the local system.
os.chdir(path)
os.system('source .venv/bin/activate')
run_command('pip install django')
os.system(f'django-admin startproject {projectName}')
os.chdir(f'{path}{projectName}')
appName = input(f'{color.YELLOW}Choose a name for your app: {color.END}')
This command directly interpolates appName from user input into a shell command. An attacker can provide a crafted app name to achieve arbitrary command execution during project scaffolding.
appName = input(f'{color.YELLOW}Choose a name for your app: {color.END}')
os.system(f'django-admin startapp {appName}')
create = input(f'{color.YELLOW}would you like to create a requirements file: {color.END}')
if create.lower() == 'yes' or create.lower() == 'y':
os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.
create = input(f'{color.YELLOW}would you like to create a requirements file: {color.END}')
if create.lower() == 'yes' or create.lower() == 'y':
os.system('pip freeze > requirements.txt')
setup = input(f'{color.YELLOW}you want to set up the files for django ? (yes or no): {color.END}')
No manifest is available, so there is no declared purpose that would justify broad command-execution capabilities. The code clears the terminal, creates virtual environments, invokes django-admin/manage.py, and runs pip installs through os.system/subprocess, which is a powerful capability beyond a minimally justified unknown-purpose skill.
The code creates and overwrites project files such as urls.py, views.py, serializers.py, requirements.txt, and settings.py, and changes directories throughout execution. With no manifest or declared scope, this level of write access is not justified by any stated intent and materially changes local developer projects.
This code creates and overwrites project files such as urls.py, views.py, settings.py, serializers.py, and requirements.txt, and also creates virtual environments and Django projects. While there are status messages after some actions, there is no clear user-facing warning that the script will modify files and project structure in the selected path before those operations occur.
The script installs packages with pip, creates a virtual environment, runs django-admin, and executes manage.py commands, all of which change the local environment and system state. Although some success/error messages are printed, the user is not explicitly warned that dependencies will be installed and commands executed on their system.
No suspicious patterns detected.