Skip to content

Rust binaries contain path strings that expose system username when using any dependency #89410

Closed
@undersquire

Description

@undersquire

On compiling for release, there should not be literal absolute paths exposing my system username (which on some of my devices is my real name) inside the binaries. I understand maybe its necessary in debug binaries (however I still see no reason to pack these absolute paths in) but they should 100% not be present in a release build.

I have seen many issues reported about this, yet none of them seem to have came to any solution or fix. I have also seen the flag --remap-path-prefix but that doesn't fix the issue. The paths still remain even after using this flag.

Please let me know if there is any current solution for this, or if it is planned to be fixed in a future release.

EDIT: Stripping the binary using strip or even cargo strip tools do not remove the strings either.

How to reproduce:

  • Create rust project
  • Add any dependency to the project, like rand for example
  • Add code to main.rs that uses that crate in any way
  • Build for release using cargo build --release
  • Then to see how many times your system name appears in the binary, you can either manually search using a hex editor or if on Unix-like system you can probably use strings target/release/BINARY_NAME| grep YOUR_SYSTEM_NAME | wc -l

For me, it says my system name appears 20 times in a debug binary and 3 times in a release binary using the rand crate and nothing else.

This issue does not occur if you have no dependencies.

Meta

rustc --version --verbose:

rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: aarch64-apple-darwin
release: 1.55.0
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions