Bug 510968 - Environment variables starting without digits are not filtered
Summary: Environment variables starting without digits are not filtered
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.19.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-23 16:18 UTC by N
Modified: 2025-11-17 21:41 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.21
Sentry Crash Report:


Attachments
test case, sets env 0 and then runs a bash shell (104 bytes, text/x-csrc)
2025-10-23 16:18 UTC, N
Details

Note You need to log in before you can comment on or make changes to this bug.
Description N 2025-10-23 16:18:43 UTC
Created attachment 186046 [details]
test case, sets env 0 and then runs a bash shell

SUMMARY
When launching a process with xdg-open via kio's systemd process launcher, environment variables whose names are not made of [a-zA-Z0-9_]* are filtered to fit systemd unit files[1]; but systemd has an additional restriction that environment variables not start with digits[2]. If an environment variable like "0a" is set, the process will fail to launch.

STEPS TO REPRODUCE
1. Set an environment variable starting with "0". (Ex: setenv.c)
2. Run xdg-open somefile.png

OBSERVED RESULT
kf.kio.gui: Failed to launch process as service: "app-firefox@[...].service" "org.freedesktop.DBus.Error.InvalidArgs" "Invalid environment block."

EXPECTED RESULT
The environment should be filtered alongside other illegal systemd environment variables.

SOFTWARE/OS VERSIONS
Operating System: NixOS 25.05
KDE Plasma Version: 6.3.6
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.1
xdg-utils 1.2.1
kio-6.14.0

ADDITIONAL INFORMATION
[1] https://invent.kde.org/frameworks/kio/-/blob/67fa68b82e1795f636936b4f77623d0146f2ee8e/src/gui/systemd/systemdprocessrunner.cpp#L94
[2] https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Environment=
Comment 1 Bug Janitor Service 2025-11-08 17:12:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/2050
Comment 2 Christoph Cullmann 2025-11-08 17:16:01 UTC
Could you try my patch?
Comment 3 Méven 2025-11-16 14:24:47 UTC
Git commit 292fadb4cce90ade731330ee126cd829232e37df by Méven Car, on behalf of Christoph Cullmann.
Committed on 16/11/2025 at 14:24.
Pushed by meven into branch 'master'.

systemd: prevent passing invalid env vars starting with digit

filter them out, too
for safety: filter empty vars, should not happen, but still

M  +1    -1    src/gui/systemd/systemdprocessrunner.cpp

https://invent.kde.org/frameworks/kio/-/commit/292fadb4cce90ade731330ee126cd829232e37df