Skip to content

Add secret access, as the safeStorage api is now used - #530

Open
razzeee wants to merge 2 commits into
flathub:masterfrom
razzeee:secret-access
Open

Add secret access, as the safeStorage api is now used#530
razzeee wants to merge 2 commits into
flathub:masterfrom
razzeee:secret-access

Conversation

@razzeee

@razzeee razzeee commented Jun 13, 2025

Copy link
Copy Markdown
Member

Closes #528

@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.

@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/191819/im.riot.Riot.flatpakref

@RayJW

RayJW commented Jun 13, 2025

Copy link
Copy Markdown

Manually tested this change and it seems to work fine here :)

@SISheogorath

SISheogorath commented Jun 13, 2025

Copy link
Copy Markdown
Collaborator

This shouldn't be needed, electron should use the portal (it even does use the portal, but it seems either electron or the secrets portal falls short on the encryption API). Therefore, for now, I would avoid adding this API and instead let people click through the warning dialogue.

It's not amazing, but it also doesn't change the status quo. Adding the bypass for the secrets API, can confuse access token storage once more, and I would like to avoid that.

References:
https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Secret.html

@jcz1

jcz1 commented Jun 13, 2025

Copy link
Copy Markdown

Test build working for me (Debian + xfce + gnome-keyring).

@razzeee

razzeee commented Jun 13, 2025

Copy link
Copy Markdown
Member Author

This shouldn't be needed, electron should use the portal (it even does use the portal, but it seems either electron or the secrets portal falls short on the encryption API). Therefore, for now, I would avoid adding this API and instead let people click through the warning dialogue.

It's not amazing, but it also doesn't change the status quo. Adding the bypass for the secrets API, can confuse access token storage once more, and I would like to avoid that.

References: flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Secret.html

The current popup makes it sound, like NOT adding the permission confuses token storage once more. Is it misleading?

image

@bbhtt

bbhtt commented Jun 14, 2025

Copy link
Copy Markdown
Contributor

It should've been using libsecret with -Dcrypto=disabled and this permission when the update with safestorage landed in #524 We discussed this on matrix and it wasn't done.

The secrets portal is quite literally broken for chromium and electron applications.

Now migrating back and forth to fix this will obviously corrupt everyone's secrets storage.

@lucasmz-dev

lucasmz-dev commented Jun 14, 2025

Copy link
Copy Markdown

Does not work for me in a clean install. kwallet6, doesn't help granting org.kde.kwallet6 either
I didn't grant xdg-run/keyring in this case

Edit: granting it, still same issue

@hpdeifel

Copy link
Copy Markdown

Therefore, for now, I would avoid adding this API and instead let people click through the warning dialogue.

Unfortunately, the pop-up is full of technical jargon and the button says "use no encryption", in an app for encrypted communication. I just stopped using the desktop app instead of clicking the button and assumed it would be fixed in the next update.

I would hope that many non-technical users do the same without access to clear information on this problem.

razzeee added a commit to razzeee/im.riot.Riot that referenced this pull request Jun 14, 2025
@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/191965/im.riot.Riot.flatpakref

@razzeee

razzeee commented Jun 15, 2025

Copy link
Copy Markdown
Member Author

So with these changes this happens on start, which I guess is expected and not preventable.

image

@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/192852/im.riot.Riot.flatpakref

@SISheogorath

Copy link
Copy Markdown
Collaborator

The really annoying thing here is we have to choose between:

Short term gain: No popup and we get encrypted messages, but we might break sessions and we have to keep the permissions and update the permissions to read secrets from unsandboxed session store, that might include all your stored website passwords 👍🏻

Long term gain: We wait for Electron and xdg-secret-portal to get along again and work as expected, including support for safeStorage. Sandbox stays intact, no direct access for Electron to your keyring, but we have an ugly popup. 🤔 ⏳

Mid term gain: We add the permissions, we get encrypted messages, but as soon as Electron and portal get along again, we remove the permissions. We just break everyone's sessions, drop the encryption secrets and make everyone re-log. That will certainly not cause any data loss, because everyone uses key backups, right? 😡 💥

Right now, I'm still pushing for the long term gains, because I believe that keeping the sandbox intact, will benefit us in the long term more than avoiding the popup. But feel free to share your thoughts, especially because I see more people in the issues starting to add the permissions manually instead of clicking through the popup.

@almereyda

Copy link
Copy Markdown

@SISheogorath Can you give an example of what "clicking through the popup" means for us who didn't do it, since you mention it in many places? Maybe in the issue #528?

I'm reluctant to clicking a button "Use no encryption" and I'm also hesitant to install a patch that forces me to reauthenticate, to revalidate and to reestablish encryption. A clean migration path would be preferable.

On Flathub this repository is marked as officially provided by New Vector Inc.

Eventually they might want to chime in here?

@razzeee

razzeee commented Jun 23, 2025

Copy link
Copy Markdown
Member Author

On Flathub this repository is marked as officially provided by New Vector Inc.

That's a wrong statement. Flathub does not claim that anywhere.

@Gigadoc2

Copy link
Copy Markdown

The thing that got me is that, prior to the problematic update, Electron wasn't using the keyring either. There is something in Electron that requests the secret from the Desktop portal, but it doesn't seem to be using it. I can change or outright delete the secret and Element still starts up fine. But because it does request the Secret, it is looked up (by the desktop portal, not the application) in the keyring, which requests an unlock, etc, which lead me (and maybe others?) to assume that Element was using the system keyring (at least indirectly).

This also means that the session reset on "Use no encryption" is entirely unnecessary, it wasn't "using encryption" to begin with, so there should be the migration path of "doing nothing"...

@SISheogorath: I'd argue for the long term gain, because allowing Element access to the whole keyring weakens security much more than it strenghtens it, for most threat models: With all current desktops, the keyring only provides "encryption at rest", and no "encryption at screen lock" or anything similar. Linux users wishing for encryption at rest will mostly already use some form of disk encryption which provides this. Not allowing keyring access (which has already been the status quo) is a practical weakness only in the case of not using any kind of disk or filesystem encryption which includes $HOME already; and it is only vulnerable to physical attacks.
In contrast, Element, an Electron App directly handling untrusted input, accessing the users entire keyring is a hugely increased attack surface for online attacks. I'd argue that for the vast majority of users, this is a much higher risk, and it is also a new one that hasn't been here before. Additionally, users still wanting this trade-off can have it with a local override anyway.

@lucasmz-dev

Copy link
Copy Markdown

I did notice that clicking 'Use no encryption' had apparent no effect too.

Comment thread im.riot.Riot.yaml
- /share/man
- /man
modules:
- name: libsecret

@Croydon Croydon Jun 25, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding this as a submodule https://github.com/flathub/shared-modules?tab=readme-ov-file

Edit: Not sure if it is the right thing to do overall, but if needed, then adding it as a submodule is probably better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be an option, as it's using different options, which would invalidate our use case.

@LecrisUT

Copy link
Copy Markdown

Any news on this? Iiuc the long-term approach is to wait for upstream release that fixes this? Is there an upstream tracker for it?

@harmathy

Copy link
Copy Markdown

Any news on this? Iiuc the long-term approach is to wait for upstream release that fixes this? Is there an upstream tracker for it?

@LecrisUT upstream issue is [Bug]: Safestorage detection fails on linux outside of predefined desktop environments #39789

@Exist2Resist

Exist2Resist commented Oct 6, 2025

Copy link
Copy Markdown

How is this an upstream issue from 2023 when Element worked perfectly fine no less than 6 months ago. Then the developers decided to change things and it broke the app.

@lucasmz-dev

Copy link
Copy Markdown

xdg-run/keyring can probably be removed right

why is that even needed, I know no other flatpaks that do this

@lucasmz-dev

Copy link
Copy Markdown

Right now, I'm still pushing for the long term gains, because I believe that keeping the sandbox intact, will benefit us in the long term more than avoiding the popup. But feel free to share your thoughts, especially because I see more people in the issues starting to add the permissions manually instead of clicking through the popup.

The sandbox is already not intact; org.kde.StatusNotifierWatcher is considered a sandbox escape, it allows access to the x11 socket even on wayland sessions, xdg-run/keyring is granted, which seems to not be useful at all, and access is granted to all devices.

As far as I can tell also, (maybe this is only in KDE) the secrets portal isn't even that much better in its implementation, it doesn't seem to provide any protection against unsandboxed apps, as long as one has access to the keyring, they can decrypt the Element database.

Ideally I feel like when the secrets portal is available it would migrate the secrets, not just always depend on it.

Comment thread im.riot.Riot.yaml
Comment on lines +37 to +38
# Required for access to the safeStorage https://www.electronjs.org/de/docs/latest/api/safe-storage
- --talk-name=org.freedesktop.secrets

@lucasmz-dev lucasmz-dev Oct 26, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Required for access to the safeStorage https://www.electronjs.org/de/docs/latest/api/safe-storage
- --talk-name=org.freedesktop.secrets
# Required for access to the safeStorage https://www.electronjs.org/de/docs/latest/api/safe-storage
- --talk-name=org.freedesktop.secrets
- --talk-name=org.kde.kwalletd6
- --talk-name=org.kde.kwalletd5

@ActuallyTheOwner

Copy link
Copy Markdown

2026 and I searched for and found this still open?

@moritzdietz

Copy link
Copy Markdown

2026 and I searched for and found this still open?

electron/electron#49054 was just merged so maybe the building blocks are now there?

@razzeee

razzeee commented Feb 24, 2026

Copy link
Copy Markdown
Member Author

Doesn't seem to have reached a release

@BeamingOctagon

Copy link
Copy Markdown

Short-term progress on this issue is unlikely since the maintainer of this Flathub package is stepping down and looking for a replacement. More at #568.

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.

Broken encryption after updating to 1.11.103