Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chroot escape in Win32 sftp-server #2288

Open
3 tasks done
jhudsoncedaron opened this issue Oct 16, 2024 · 0 comments
Open
3 tasks done

chroot escape in Win32 sftp-server #2288

jhudsoncedaron opened this issue Oct 16, 2024 · 0 comments

Comments

@jhudsoncedaron
Copy link

jhudsoncedaron commented Oct 16, 2024

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

  1. Create test user account

  2. Turn on Developer Mode

  3. Load into sshd_config:

Match User test
       ForceCommand internal-sftp
       ChrootDirectory %h

(In fact any writable directory will do, or even a writable subdirectory, but with different steps to reproduce)

  1. Log in with sftp

  2. Run the following commands

sftp>ln -s .. parent
sftp>ls ..

Expected behavior

shows listing of c:\users\test

Actual behavior

shows listing of c:\users

Error details

No error message generated

Environment data

Not applicable; powershell itself is not in the reproduction steps

Version

OpenSSH_for_Windows_9.8p1 Win32-OpenSSH-GitHub, LibreSSL 3.9.2

Additional Info

MSRC Case 91638 reports: Not a vulnerability

This is still a bug. The behavior of .. bouncing off the root is well-known and stuff depends on this working.

In order to test this on unix systems, currently ChrootDirectory %h on unix systems currently requires the home directory
to be owned by root and not writable by anybody else, so this needs to be tested with a writable subdirectory:

# chown root ~test
# chown chmod 755 ~test
# mkdir ~test/sub
# chown test ~test/sub
# sftp loalhost
sftp>ln -s ../.. sub/grandparent
sftp>ls sub/grandparent
(lists /home/test but on Windows lists C:\Users)

Additional test cases (to avoid breaking something else)

sftp>ln -s root /
sftp>ls root
(should list C:\Users\test and does)
sftp>mkdir aaa
sftp>ln -s ../Documents aaa/docs
sftp>ls aaa/docs
(should list C:\Users\test\Documents and does)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants