Challenge, Easy,  on  Linux

Run a Glibc-incompatible Binary Using chroot

You are provided with a binary located at /home/laborant/app/processor.

Try executing it directly on this Ubuntu machine:

/home/laborant/app/processor

You will notice that execution fails immediately with cannot execute: required file not found. This happens because the binary was dynamically compiled against musl libc and expects the dynamic linker /lib/ld-musl-x86_64.so.1, which is not present in Ubuntu's standard glibc root filesystem.

To solve this dependency issue without altering the host OS, you will isolate and run the application inside an Alpine Linux root filesystem at /tmp/newroot using chroot.

Linux Filesystem Isolation with chroot: Host filesystem vs. /tmp/newroot

Objectives

  1. Export Alpine Rootfs: Use the pre-installed crane tool to export the filesystem of alpine:latest and extract it into /tmp/newroot.
  2. Place Binary Inside Rootfs: Copy the application directory /home/laborant/app into /tmp/newroot/app so it is accessible within the new root directory.
  3. Execute in chroot: Run /app/processor inside the chroot jail using sudo chroot.

Hint 1: Exporting an image rootfs with crane

crane export <image> - streams the container filesystem tarball to standard output. You can pipe it directly to tar:

mkdir -p /tmp/newroot
crane export alpine:latest - | tar -xf - -C /tmp/newroot
Hint 2: Running a command in chroot

Once the rootfs is extracted and the app is placed inside /tmp/newroot/app/, execute:

sudo chroot /tmp/newroot /app/processor
Hint 3: Need a Refresher on chroot Basics?

Check out the tutorial Change Your Root: Chroot Basics to learn how the chroot system call manages process root pointers, shared library resolution, and root filesystem isolation.