Vulnerability: Discord Recon Server is a bot that allows you to do your reconnaissance process from your Discord. Remote code execution in version 0.0.1 would allow remote users to execute commands on the server resulting in serious issues. This flaw is patched in 0.0.2.
Vulnerability ID: CVE-2021-21433
CWE: CWE-94
Severity score: 6.4
Project: https://github.com/DEMON1A/Discord-Recon
Published: 2021-04-09
File: app.py
Commit message: Fixing Command Injection Issues.
Commit author: Mohamed Dief

Vulnerable version (before fix):
 async def ip(ctx , *, argument):  @Client.command() async def dirsearch(ctx , *, argument):     Path = TOOLS['dirsearch']; MainPath = getcwd(); chdir(Path)     await ctx.send(f"**Running Your Dirsearch Scan, We Will Send The Results When It's Done**")     Process = subprocess.Popen(f'python3 dirsearch.py -u {argument} -e * -b' , shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) async def dirsearch(ctx , *, argument):  @Client.command() async def arjun(ctx , *, argument):     Path = TOOLS['arjun']; MainPath = getcwd(); chdir(Path)     await ctx.send(f"**Running Your Arjun Scan, We Will Send The Results When It's Done**")     await ctx.send(f"**Note: The Bot Won't Respond Until The Scan is Done. All Of Your Commands Now Will Be Executed After This Process is Done.")

Fixed version (after fix):
 async def ip(ctx , *, argument):  @Client.command() async def dirsearch(ctx , *, argument):     if not CommandInjection.commandInjection(argument=argument , RCE=RCE):         await ctx.send("**Your Command Contains Unallowed Chars. Don't Try To Use It Again.**")         return          Path = TOOLS['dirsearch']; MainPath = getcwd(); chdir(Path)     await ctx.send(f"**Running Your Dirsearch Scan, We Will Send The Results When It's Done**")     Process = subprocess.Popen(f'python3 dirsearch.py -u {argument} -e * -b' , shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT) async def dirsearch(ctx , *, argument):  @Client.command() async def arjun(ctx , *, argument):     if not CommandInjection.commandInjection(argument=argument , RCE=RCE):         await ctx.send("**Your Command Contains Unallowed Chars. Don't Try To Use It Again.**")         return          Path = TOOLS['arjun']; MainPath = getcwd(); chdir(Path)     await ctx.send(f"**Running Your Arjun Scan, We Will Send The Results When It's Done**")     await ctx.send(f"**Note: The Bot Won't Respond Until The Scan is Done. All Of Your Commands Now Will Be Executed After This Process is Done.")

Patch:
patch: @@ -95,6 +95,10 @@ async def ip(ctx , *, argument):
 
 @Client.command()
 async def dirsearch(ctx , *, argument):
+    if not CommandInjection.commandInjection(argument=argument , RCE=RCE):
+        await ctx.send("**Your Command Contains Unallowed Chars. Don't Try To Use It Again.**")
+        return
+    
     Path = TOOLS['dirsearch']; MainPath = getcwd(); chdir(Path)
     await ctx.send(f"**Running Your Dirsearch Scan, We Will Send The Results When It's Done**")
     Process = subprocess.Popen(f'python3 dirsearch.py -u {argument} -e * -b' , shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
@@ -115,6 +119,10 @@ async def dirsearch(ctx , *, argument):
 
 @Client.command()
 async def arjun(ctx , *, argument):
+    if not CommandInjection.commandInjection(argument=argument , RCE=RCE):
+        await ctx.send("**Your Command Contains Unallowed Chars. Don't Try To Use It Again.**")
+        return
+    
     Path = TOOLS['arjun']; MainPath = getcwd(); chdir(Path)
     await ctx.send(f"**Running Your Arjun Scan, We Will Send The Results When It's Done**")
     await ctx.send(f"**Note: The Bot Won't Respond Until The Scan is Done. All Of Your Commands Now Will Be Executed After This Process is Done.")
path: app.py