diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-02 17:32:59 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-02 17:32:59 +0200 |
| commit | d774f0e94e7c5a7864ca585c5b3493ee9e33fcf6 (patch) | |
| tree | aa438d80f2421419f5595a93a423371753df3061 /tests/CMakeLists.txt | |
| parent | 35d3e4ff127b0213fa4d34f630c4a019e533a4df (diff) | |
| download | qtmaildir-d774f0e94e7c5a7864ca585c5b3493ee9e33fcf6.tar.gz qtmaildir-d774f0e94e7c5a7864ca585c5b3493ee9e33fcf6.zip | |
fix: make attachment path-containment guard separator-aware
Attachment::saveTo()'s escape guard compared paths with a bare
QString::startsWith(), which is not a path-boundary test: "/tmp/safe-evil"
textually starts with "/tmp/safe", so a sibling directory whose name merely
extends the target's name would incorrectly pass as contained within it.
Extract the check into Attachment::isPathInsideDirectory(), comparing
QDir::cleanPath()'d absolute paths and requiring an exact match or a prefix
ending at a '/' boundary. Not exploitable today since safeFilename() always
reduces the name to a bare basename before saveTo() builds the target, so
the guard is unreachable via saveTo()'s public interface; comments on both
now say so plainly instead of implying it is currently load-bearing.
Add pathInsideDirectoryRejectsSiblingPrefix, testing the guard directly
(independent of safeFilename(), which would mask a broken guard by never
producing an escaping path), and safeFilenameStripsPathComponents, testing
the sanitiser that actually stops traversal today.
Diffstat (limited to 'tests/CMakeLists.txt')
0 files changed, 0 insertions, 0 deletions
