Security: remove support for $(...) in config keys with [$e] marker.
ClosedPublic

Authored by dfaure on Tue, Aug 6, 10:37 PM.

Details

Summary

It is very unclear at this point what a valid use case for this feature
would possibly be. The old documentation only mentions $(hostname) as
an example, which can be done with $HOSTNAME instead.

Note that $(...) is still supported in Exec lines of desktop files,
this does not require [$e] anyway (and actually works better without it,
otherwise the $ signs need to be doubled to obey kconfig $e escaping rules...).

Test Plan

ctest passes; various testcases with $(...) in desktop files,
directory files, and config files, no longer execute commands.

Diff Detail

Repository
R237 KConfig
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dfaure created this revision.Tue, Aug 6, 10:37 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptTue, Aug 6, 10:37 PM
Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald Transcript
dfaure requested review of this revision.Tue, Aug 6, 10:37 PM
dfaure updated this revision to Diff 63239.Tue, Aug 6, 10:38 PM

Also update docu, patch by David Edmundson, thanks

davidedmundson accepted this revision.Tue, Aug 6, 11:07 PM
This revision is now accepted and ready to land.Tue, Aug 6, 11:07 PM
kossebau added inline comments.Tue, Aug 6, 11:12 PM
docs/options.md
69–70

"and shell commands" to be dropped here no?

LGTM. Regarding the test, if we want to get this change in asap due to the security focus I can submit a follow up patch re-adding it.

autotests/kconfigtest.cpp
530

Instead of removing this test, can it instead be switched to verify the command execution does not occur?

docs/options.md
76–77

Grammar suggestion: Note that the application will replace $USER with its expanded values after saving.

+1

I got a valid usecase "Please don't fix this. I use a recursive symlink and a shell script to raise my machine load. The extra heat it produces keeps children warm in the winter." ;)

fvogt added a subscriber: fvogt.Wed, Aug 7, 7:27 AM
dfaure marked 2 inline comments as done.Wed, Aug 7, 7:35 AM
dfaure added inline comments.
autotests/kconfigtest.cpp
530

Hehe, that's what I did initially, and the value being read was (hostname) without the $ because of the way [$e] works. A bit surprising, but in line with the fact that $/ $? $@ etc would also remove the $ (because the code just sees an empty env var name), and if someone wanted to keep the $ they would have to write $$. So I concluded invalid testcase, nobody would write this anymore. But OK, it's a test about old files that might have this. I'll re-add the test.

dfaure updated this revision to Diff 63253.Wed, Aug 7, 7:36 AM

Fix documentation; re-add test for $(hostname)

mdawson accepted this revision.Wed, Aug 7, 1:13 PM
This revision was automatically updated to reflect the committed changes.

Is Frameworks 5.61 going to be re-spun to include this?

kives added a subscriber: kives.Wed, Aug 7, 11:15 PM

Does anyone think this can be easily backported to previous versions of KDE in upstream distros such as Kubuntu, etc.?

fvogt added a comment.Thu, Aug 8, 5:31 AM

Does anyone think this can be easily backported to previous versions of KDE in upstream distros such as Kubuntu, etc.?

I backported this down to KConfig 5.20 and KDELibs 4.14.18, differences were trivial to resolve.