question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can use null characters to escape filesystem

See original GitHub issue

I haven’t totally figured out how this works but one of our users managed to escape the restraints of a subfilesystem to be able to write anywhere on the physical filesystem.

The basic theory is this…

using System.IO;
using Zio;
using Zio.FileSystems;

var physical = new PhysicalFileSystem();

// create a sandboxed subsystem
var subsystem = new Zio.FileSystems.SubFileSystem(physical, "/mnt/c/temp/sandboxed", false);

// cool! this is allowed!
subsystem.WriteAllText("/hello.txt", "hello");

// agh!
UPath path = "/\0\0/mnt/windows/system32/evil.txt";
subsystem.WriteAllText(path, "we escaped!");

This seems to want to write to a T: drive (which I don’t have).

image

But obviously there’s some deeper funny business going on here.

I’m not sure whether you even meant for the subfilesystems to work in the sandboxed fashion we’re using them, but since this seems like unpredictable/unwanted behaviour I thought I would report it.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
xoofxcommented, Nov 14, 2022

I have pushed a commit 930974d that should fix this issue. The code was using StarsWith without ordinal comparison, so it could make the actual checks to be completely bypassed.

2reactions
xoofxcommented, Nov 14, 2022

Thanks @ninjasploit! Yeah, indeed, we probably need to always check the expanded path to make sure it is within boundaries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bash - Using/reading/writing the null and escape characters
I know that a filename in Linux has no restriction whatsoever except for two characters '/' and '\0' . I know that '/'...
Read more >
in linux, is it normal that there is no null character at the end ...
There is usually no null character at the end of files on Unix. An empty text file has zero bytes. One empty line...
Read more >
Null character
In source code, the null character is often represented as the escape sequence \0 in string literals (for example, "abc\0def" ) or in...
Read more >
Which common characters are illegal in Unix and Windows ...
Most filesystems are fairly permissive: for example, all NTFS, extN, btrfs, XFS and ReiserFS allow everything except 1) the null byte and 2) ......
Read more >
What characters are safe in cross-platform file names for ...
Linux, OS-X: anything except null or /. On all platforms it is best to avoid non-printable characters such as the ASCII control-characters.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found