Skip to content

workaround: Remove bundled libraries from the leaked LD_LIBRARY_PATH#391

Open
cxrvh wants to merge 1 commit into
flathub:masterfrom
cxrvh:workaround-zed-sandbox-escape
Open

workaround: Remove bundled libraries from the leaked LD_LIBRARY_PATH#391
cxrvh wants to merge 1 commit into
flathub:masterfrom
cxrvh:workaround-zed-sandbox-escape

Conversation

@cxrvh

@cxrvh cxrvh commented Jul 1, 2026

Copy link
Copy Markdown

Zed's Flatpak sandbox escape leaks the bundled libraries by setting LD_LIBRARY_PATH. That's Flatpak specific. Because the libraries from LD_LIBRARY_PATH take precedence over but are incompatible with the host's libraries, host tools fail when started from Zed.

A similar issue exists inside the sandbox: /app/lib takes precedences over the runtime libraries & therefore the incompatible Zed libraries lead to issues.

Work around the issues by moving the libraries:

  • Patch zed-editor's RPATH & move Zed's bundled libraries into /app/libzed in order to limit their scope to zed-editor
  • Move any Flatpak bundled libraries into /app/libflatpak to avoid leaking them into the host
  • /app/lib must be kept empty until the issue is fixed upstream

Closes #330

@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Test build enqueued.

@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Started test build.

@flathubbot

Copy link
Copy Markdown
Contributor

Test build failed.

Help
  • bot, build - Restart the test build
  • bot, ping admins - Contact Flathub admins

@cxrvh
cxrvh force-pushed the workaround-zed-sandbox-escape branch from c3d8c4f to 16b308b Compare July 1, 2026 17:03
@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Test build enqueued.

@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Started test build.

@flathubbot

Copy link
Copy Markdown
Contributor

Test build succeeded. To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/298950/dev.zed.Zed.flatpakref

Built for aarch64 and x86_64 architectures.

@cxrvh

cxrvh commented Jul 1, 2026

Copy link
Copy Markdown
Author

This is, in my opinion, the simplest workaround for the LD_LIBRARY_PATH leak:

  • Just move all libraries out of /app/lib so that LD_LIBRARY_PATH does not create any conflicts
  • /app/libflatpak is only for bundled libraries inside the sandbox
  • /app/libzed is for Zed's bundled libraries inside & outside the sandbox - zed-editor is patched accordingly

I haven't tested running it unsandboxed - please test this.

Alternatives would be for example building a patched CLI or some kind of script shenanigans.

@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Test build enqueued.

@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Started test build.

@flathubbot

Copy link
Copy Markdown
Contributor

Test build succeeded. To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/299416/dev.zed.Zed.flatpakref

Built for aarch64 and x86_64 architectures.

@stephanlachnit

Copy link
Copy Markdown

Works for me

Zed's Flatpak sandbox escape leaks the bundled libraries by pointing
LD_LIBRARY_PATH to /app/lib. That's Flatpak specific and because the libraries
from LD_LIBRARY_PATH take precedence over but are ncompatible with
the host's libraries, host tools fail when started from Zed.

A similar issue exists inside the sandbox: /app/lib takes precedences over the
runtime libraries & therefore the incompatible Zed libraries lead to issues.

Work around the issues by moving the libraries:
- /app/lib must be kept empty until the issue is fixed upstream
- Patch zed-editor's RPATH & move Zed's bundled libraries into /app/libzed in
  order to limit their scope to zed-editor
- Move any Flatpak bundled libraries into /app/libflatpak to avoid leaking
  them into the host

Closes flathub#330
@cxrvh
cxrvh force-pushed the workaround-zed-sandbox-escape branch from f6c3e07 to 34b71e5 Compare July 16, 2026 16:52
@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Test build enqueued.

@flathubbot

Copy link
Copy Markdown
Contributor

🚧 Started test build.

@flathubbot

Copy link
Copy Markdown
Contributor

Test build succeeded. To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/303148/dev.zed.Zed.flatpakref

Built for aarch64 and x86_64 architectures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leaks LD_LIBRARY_PATH into application - including zed terminals

3 participants