Bug 453248 - Path traversal bugs when saving various resources
Summary: Path traversal bugs when saving various resources
Status: CONFIRMED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (other bugs)
Version First Reported In: 5.0.5
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-01 04:36 UTC by Nagy Tibor
Modified: 2024-04-29 10:02 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Screen capture (467.67 KB, video/mp4)
2022-05-01 04:36 UTC, Nagy Tibor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nagy Tibor 2022-05-01 04:36:50 UTC
Created attachment 148484 [details]
Screen capture

SUMMARY
There's a path traversal bug when saving gradients in Krita. Krita doesn't sanitize the name field used for the file names of gradients, dropping files outside of the "$XDG_DATA_HOME/krita/gradients" directory.

Similar to Bug 429925.

I haven't tested it thoroughly but I have a feeling this bug may also be present with other resource types. (palettes, brushes, etc.)

STEPS TO REPRODUCE
1. Create or open a new document
2. Gradients toolbar button -> Add...
3. Enter "../../../../test/abcd" as the name field
4. Click OK

OBSERVED RESULT
See attachment.

EXPECTED RESULT
Sanitize the name field before using it as a file name.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.24
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.3
Graphics Platform: X11
Comment 1 Nagy Tibor 2022-05-01 08:13:00 UTC
I went through most Krita features, I found more places vulnerable to these path traversals:
- Gradients (.svg)
- Palettes (.kpl)
- Predefined image sizes (.predefinedimage)
- Author profiles (.authorinfo)
- Workspaces (.kws)
- Resource bundles (.bundle)

Repro is the same everywhere:
- Create new something...
- Enter a relative path including "../../" as the name
- Save
Comment 2 Halla Rempt 2022-05-10 13:18:09 UTC
Note: svg/stop gradients apparently are all saved as "unnamed.svg" right now and cannot be overwrriten. I think that's a way more important bug, though...
Comment 3 myusualnickname@gmail.com 2024-04-29 10:02:33 UTC
This may be a kio bug?