Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]My system username is leaked in binary file #6538

Open
kwpal opened this issue Mar 24, 2023 · 1 comment
Open

[bug]My system username is leaked in binary file #6538

kwpal opened this issue Mar 24, 2023 · 1 comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@kwpal
Copy link

kwpal commented Mar 24, 2023

Describe the bug

Based on the recommand options from official website, I have set strip = true, but the compiled binary still contains my system username.

binary screenshot:

username

Reproduction

  1. sh <(curl https://create.tauri.app/sh)
✔ Project name · realapp
✔ Choose which language to use for your frontend · Rust - (cargo)
✔ Choose your UI template · Vanilla
  1. add [profile.release] in Cargo.toml
[profile.release]
panic = "abort"   # Strip expensive panic clean-up logic
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
lto = true        # Enables link to optimizations
opt-level = "s"   # Optimize for binary size
strip = true      # Remove debug symbols
  1. cargo tauri build
  2. search username in binary: src-tauri/target/release/bundle/macos/realapp.app/Contents/MacOS/realapp

Expected behavior

Should remove my username in complied binary.

Platform and versions

Environment
  › OS: Mac OS 11.5.2 X64
  › Node.js: 18.13.0
  › npm: 8.19.3
  › pnpm: 7.26.3
  › yarn: 1.22.19
  › rustup: 1.25.2
  › rustc: 1.68.0
  › cargo: 1.68.0
  › Rust toolchain: stable-x86_64-apple-darwin

Packages
WARNING: no lock files found, defaulting to npm
  › @tauri-apps/cli [NPM]: 1.2.3
  › @tauri-apps/api [NPM]: Not installed!
  › tauri [RUST]: 1.2.4,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.8,
  › wry [RUST]: 0.23.4,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../src
  › devPath: ../src
package.json not found

App directory structure
  ├─ src-tauri
  ├─ .vscode
  └─ src

Stack trace

No response

Additional context

No response

@kwpal kwpal added status: needs triage This issue needs to triage, applied to new issues type: bug labels Mar 24, 2023
@JonasKruckenberg
Copy link
Contributor

JonasKruckenberg commented Mar 24, 2023

Okay so, interesting story. Thanks to your issue I learned about --remap-path-prefix=!

Here's what is happening:
When Rust compiles your binary, for every occurrence of a panic it will include information for displaying a proper panic message. This panic includes a pointer to the line and file in question. So what you are seeing are the panic message strings that are placed into the binary by the compiler.

Now, why are these paths absolute? I have absolutely no clue!
But this has been brought up before (here and here and probably many other times), so this isn't anything we're doing, but something the Rust compiler is doing.

To fix this: As mentioned in the issues I linked above there is a rust compiler flag called --remap-path-prefix= that you can use to "strip"/replace the path prefix that includes your username.
You can set these flags like so:

RUSTFLAGS="--remap-path-prefix=/Users/jonas/Documents/GitHub/rust-updater/tauri-app/src-tauri/src=src --remap-path-prefix=/Users/jonas/.cargo=cargo --remap-path-prefix=/Users/jonas/.rustup=rustup" cargo tauri build

This will strip all the occurrences of your username from the final binary (at least it did on my machine)

Okay cool, I can hear you saying though "this is a stupid and incredibly unergonomic solution" and I would absolutely agree with you, arguably this should be fixed in rust. Maybe we can, as a stopgap solution, add these flags when the tauri cli compiles your app though 🤔

JonasKruckenberg added a commit that referenced this issue Mar 24, 2023
This sets rusts `--remap-path-prefix` flags to strip potential PII from release binaries by truncating absolute paths from panic messages and debug symbols.

closes: #6538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
Status: 📬Proposal
Development

No branches or pull requests

2 participants