Lind-Project / lind_project

Lind: Secure Lightweight Adaptive Isolation
https://hub.docker.com/r/securesystemslab/lind
Apache License 2.0
23 stars 8 forks source link

Let's isolate xz from sshd #366

Open JustinCappos opened 6 months ago

JustinCappos commented 6 months ago

We'd like a POC that isolates xz from sshd. See here if you don't know why this is an interesting thing to make.

An easy way to do this is to set up an rpc client / server and to run sshd and xz in different cages. The eventual setup will have the rpc client run from sshd, which will call into the rpc server which runs xz.

A few tips:

ve1nard commented 2 months ago

Implementation using the loopback address: https://github.com/ve1nard/sshdRPC

CacheUseOnly commented 1 month ago

My current understanding is to

  1. rewrite all function calls in sshd calling xz functions into a RPC.
  2. rewrite xz functions that will be called by sshd in RPC schemas
  3. setup a RPC server for xz to handle RPC calls from sshd

However, there are two questions block me:

  1. sshd does not directly need liblzma
    • $ objdump -p $(which sshd) | grep -i 'needed' does not include liblzma.so.5 . In fact, the xz backdoor vulnerability targets OpenSSH but it was done via systemd. [1]
    • Solution 1: Find another example.
    • Solution 2: Modify the liblzma so that the liblzma.so.5 is substituted with another version which uses RPC.
  2. It is mentioned that "Ideally your changes will be minimal. Try to avoid changing code you don't need to change." I wonder if the steps aforementioned is the minimal change one could make.
JustinCappos commented 4 weeks ago

I think the example people are familiar with is this one, so I'd prefer something closer to your Solution 2. If you need to change source code in other places, that's fine too. It's just a good idea not to rewrite things you don't need to (as you note).

On Thu, Oct 3, 2024 at 6:08 PM Yuxuan Luo @.***> wrote:

My current understanding is to

  1. rewrite all function calls in sshd calling xz functions into a RPC.
  2. rewrite xz functions that will be called by sshd in RPC schemas
  3. setup a RPC server for xz to handle RPC calls from sshd

However, there are two questions block me:

  1. sshd does not directly need liblzma

  2. It is mentioned that "Ideally your changes will be minimal. Try to avoid changing code you don't need to change." I wonder if the steps aforementioned is the minimal change one could make.

— Reply to this email directly, view it on GitHub https://github.com/Lind-Project/lind_project/issues/366#issuecomment-2392424814, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGROD7R44QKARMU4SHTYETZZW57DAVCNFSM6AAAAABGVIJYHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJSGQZDIOBRGQ . You are receiving this because you authored the thread.Message ID: @.***>

CacheUseOnly commented 4 weeks ago

@JustinCappos @yzhang71 WIP: https://github.com/CacheUseOnly/sshd-isolation

CacheUseOnly commented 1 day ago

@JustinCappos The function the previous work converted is sd_notify(), a systemd function call rather than one that comes from liblzma. In the next PoC, would you like to patch sshd and substitute the sd_notify() or patch the xz and substitute arbitrary functions from liblzma?

JustinCappos commented 17 hours ago

I don't think it really matters, so long as it's over RPC. What are the pros and cons of each approach?

On Mon, Nov 4, 2024 at 9:21 PM Yuxuan Luo @.***> wrote:

@JustinCappos https://github.com/JustinCappos The function the previous work converted is sd_notify(), a systemd function call rather than one that comes from liblzma. In the next PoC, would you like to patch sshd and substitute the sd_notify() or patch the xz and substitute arbitrary functions from liblzma?

— Reply to this email directly, view it on GitHub https://github.com/Lind-Project/lind_project/issues/366#issuecomment-2456087580, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRODZB44TFA4WLDQPRXTTZ7AMP3AVCNFSM6AAAAABGVIJYHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJWGA4DONJYGA . You are receiving this because you were mentioned.Message ID: @.***>

CacheUseOnly commented 10 hours ago

They don't differ as two approaches, they are two options isolating different library calls for the PoC. If you don't have a strong preference I'll do the patching xz - liblzma pair since I've already done a similar work.

I don't think it really matters, so long as it's over RPC. What are the pros and cons of each approach? On Mon, Nov 4, 2024 at 9:21 PM Yuxuan Luo @.> wrote: @JustinCappos https://github.com/JustinCappos The function the previous work converted is sd_notify(), a systemd function call rather than one that comes from liblzma. In the next PoC, would you like to patch sshd and substitute the sd_notify() or patch the xz and substitute arbitrary functions from liblzma? — Reply to this email directly, view it on GitHub <#366 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRODZB44TFA4WLDQPRXTTZ7AMP3AVCNFSM6AAAAABGVIJYHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJWGA4DONJYGA . You are receiving this because you were mentioned.Message ID: @.>