1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 15:49:42 +02:00

security: restrict backup file upload (#1522)

This commit is contained in:
Hayden 2022-08-02 12:53:58 -08:00 committed by GitHub
parent 6649ccf224
commit 11478134a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

View file

@ -0,0 +1,25 @@
from fastapi.testclient import TestClient
from mealie.core.config import get_app_dirs
from tests import data
from tests.utils.fixture_schemas import TestUser
def test_recipe_asset_exploit(api_client: TestClient, admin_user: TestUser):
dirs = get_app_dirs()
file_payload = {
"archive": ("../test.txt", data.images_test_image_1.read_bytes()),
}
response = api_client.post(
"/api/admin/backups/upload",
files=file_payload,
headers=admin_user.token,
)
assert response.status_code == 400
# Ensure File was not created
assert not (dirs.BACKUP_DIR / "test.txt").exists()
assert not (dirs.BACKUP_DIR.parent / "test.txt").exists()