Skip to content

Commit

Permalink
[sftp server] restrict root in the instance from changing ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
sharder996 committed Nov 2, 2023
1 parent e23cda4 commit 5e80ad1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sshfs_mount/sftp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,17 @@ int mp::SftpServer::handle_setstat(sftp_client_message msg)
}
}

if ((msg->attr->uid == 0 && reverse_uid_for(msg->attr->uid) == -1) ||
(msg->attr->gid == 0 && reverse_gid_for(msg->attr->gid) == -1))
{
mpl::log(mpl::Level::trace,
category,
fmt::format("{}: permission denied: cannot modify path \'{}\' without reverse mapping for root",
__FUNCTION__,
filename));
return reply_perm_denied(msg);
}

QFile file{filename};

if (msg->attr->flags & SSH_FILEXFER_ATTR_SIZE)
Expand Down

0 comments on commit 5e80ad1

Please sign in to comment.