Skip to content

Commit

Permalink
Fix for Potential file inclusion attack via reading file
Browse files Browse the repository at this point in the history
  • Loading branch information
aikido[bot] committed Nov 2, 2024
1 parent 258e919 commit 88a53cc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/astroidapi/attachment_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ async def download_attachment(attachment_url, registeredPlatforms):
await surrealdb_handler.AttachmentProcessor.create_attachment(attachment_id, status="downloading", type=attachment_type, registeredPlatforms=registeredPlatforms)
attachment = response.content
attachment_path = f"{pathlib.Path(__file__).parent.resolve()}/TMP_attachments/{attachment_id}.{attachment_type}"
if '../' in attachment_path or '..\\' in attachment_path:
raise Exception("Invalid file path")
with open(attachment_path, 'wb') as file:
file.write(attachment)
file.close()
Expand Down

0 comments on commit 88a53cc

Please sign in to comment.