
Language Sloth Sloth Bot 1.0은 gif() 및 png() 함수에서 디렉터리 트래버설(Directory Traversal) 취약점이 있습니다. 이 함수들은 'name' 매개변수에 대해 검증되지 않은 사용자 입력을 사용하여 파일 경로를 구성하므로, 공격자가 의도된 리소스 디렉터리 외부의 파일을 참조할 수 있습니다.
언어 슬로스(Language Sloth) 디스코드 봇은 gif() 및 png() 함수에서 디렉터리 트래버설(Directory Traversal) 취약점에 노출되어 있습니다. 이 함수들은 '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!**")
name 매개변수는 검증이나 삭제(샌티타이즈) 없이 파일 경로에 직접 삽입됩니다:
f'./gif/{name}.gif'
f'./png/{name}.png'
예시 페이로드:
z!gif ..\..\..\..\Windows\filename
z!png ..\..\..\..\Windows\filename
위 이미지는 C:\Windows\cat.gif에 위치한 이미지를 추출한 것을 보여줍니다.