Skip to content

prevent storage ids from escaping the storage root - #158

Merged
preaction merged 1 commit into
Yancy-app:masterfrom
uniejo:fix-storage-traversal
Oct 10, 2026
Merged

preaction merged 1 commit into
Yancy-app:masterfrom
uniejo:fix-storage-traversal

Conversation

@uniejo

@uniejo uniejo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Storage IDs were passed straight to Mojo::File->child, so IDs with .. parts (e.g. /storage/..%2F..%2Fetc%2Fpasswd) and upload filenames like ../../x could read, write, or delete files outside of the root.

Add Yancy::Storage->valid_id, which rejects empty IDs, . and .. parts, backslashes, and NUL characters, and check it in get, put, and delete. The storage controller returns 404/400 for invalid IDs, and only uses the file name part of an upload's filename.

Also return undef from get when the file does not exist, so the controller can respond with 404.

Storage IDs were passed straight to Mojo::File->child, so IDs with `..`
parts (e.g. `/storage/..%2F..%2Fetc%2Fpasswd`) and upload filenames like
`../../x` could read, write, or delete files outside of the root.

Add Yancy::Storage->valid_id, which rejects empty IDs, `.` and `..`
parts, backslashes, and NUL characters, and check it in get, put, and
delete. The storage controller returns 404/400 for invalid IDs, and
only uses the file name part of an upload's filename.

Also return undef from get when the file does not exist, so the
controller can respond with 404.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@preaction
preaction merged commit 408d6d6 into Yancy-app:master Oct 10, 2026
1 check failed
@preaction

Copy link
Copy Markdown
Collaborator

Thanks!

@uniejo
uniejo deleted the fix-storage-traversal branch October 12, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants