Mariquita🐞mariquita-sec#

I scan, I map, I exploit .... Red Team Princess—Crowned in Shells.!!!

PicoCTF 2025 – Rust Fixme 3 Write-Up

Challenge Overview

If you're new here, I recommend checking out my RustFixMe1 and RustFixMe2 write-ups before diving into this one. This was another Rust challenge, and this time, it was all about fixing unsafe Rust code to make it safe.

challenge_description

Downloading and Extracting the Files

As always, I started by downloading the challenge files:

The file came compressed as a .tar.gz, so I extracted it with:

tar_unzip

Inside, I found a Rust project with the main code located in src/main.rs

Analyzing the Error

After navigating to the project directory, I attempted to build the code:

cargoerror

However, I was met with an error:

The error E0133 occurs because Rust’s memory safety rules prevent calling unsafe functions unless explicitly marked inside an unsafe block.

The error message tells us that std::slice::from_raw_parts() is an unsafe function, meaning that Rust cannot guarantee memory safety when calling it.

Because of this, Rust requires such calls to be wrapped in an unsafe block.

Fixing the Unsafe Code

After analyzing the code , i found out that the unsafe function was commented, i removed the comments and ran the code

Compiling and Running the Code

cargo init # Initialize Cargo project (if not already set up)

cargo build # Compile the code,

cargo run # Execute the program

And just like that—I got the flag!

This was a fun and straightforward challenge—easy peasy! 😎

This challenge taught me about handling unsafe Rust code, especially when working with raw pointers.

Key Takeaways:

✅ Unsafe Rust is needed for low-level memory operations, but it must be handled carefully.

✅ Using raw pointers in Rust can lead to undefined behavior if not handled correctly.

✅ Wrapping unsafe functions inside unsafe {} blocks is required to compile them.



Back To CTF