View Issue Details

This issue affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
18375Bug reportsPluginspublic2026-11-19 22:22
Reportergabrieljenik Assigned Togabrieljenik  
PrioritynoneSeverityfeature 
Status closedResolutionfixed 
Summary18375: Security : Some plugin settings need encryption
Description

Some plugin settings as API keys could need some encryption when saved.

TagsNo tags attached.
Bug heat8
Complete LimeSurvey version number (& build)
I will donate to the project if issue is resolved
Browser
Database type & version
Server OS (if known)
Webserver software & version (if known)
PHP Version
Git branch / Pull Request URL

Relationships

related to 09056 resolvedc_schmitz Security : Pulgin settings password is shown in HTML source 

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2022-09-26 18:35

developer   ~71955

It must case for password by default ? No ?

gabrieljenik

gabrieljenik

2022-09-26 20:08

developer   ~71959

Issue about handling by defualt for passwords is backward compatibility.
Initially, I prefer to have the developer to manually say they want to encrypt the field.

gabrieljenik

gabrieljenik

2022-10-04 22:44

developer   ~72092

Draft PR: https://github.com/LimeSurvey/LimeSurvey/pull/2645

DenisChenu

DenisChenu

2022-10-05 14:37

developer   ~72107

Discussion closed : you don't update $data if decrypt didn't work.

Then : you can just set a value as crypted, it was crypted when you save it :).

gabrieljenik

gabrieljenik

2022-10-05 14:38

developer   ~72108

This will not work on survey settings.

DenisChenu

DenisChenu

2022-10-05 14:39

developer   ~72109

Survey settings use get and set.
Then : i think it work.

You have a micro plugin to test ?

gabrieljenik

gabrieljenik

2022-10-05 14:42

developer   ~72110

Discussion closed : you don't update $data if decrypt didn't work.
Then : you can just set a value as crypted, it was crypted when you save it :).

Yes, but that was not intended to it. Not sure I want to rely on that.
Information can be lost.

I like to have a way to upgrade my plugin with existing password, i mean : with a plugin moving from version 1.2.4 to 1.3.0 with New feature : encrypt password

I picture this:

  • A setting in plugin: Encrypt Passwords at Rest.
  • A setting: Encruption Current State.
  • When saving setting it will know if it has to do an extra encode or decode while saving settings.

Also:

  • Updating the get/save, as to identify if a setting is a password type, so automatically, encrypt/decrypt
DenisChenu

DenisChenu

2022-10-05 14:47

developer   ~72111

Information can be lost.

Remind : get and save can save anything too.
Then maybe when set
['crypted' => $value]

There can have issue if a plugin use same system ;) to save value

Remind too : plugin can save array of settings etc …
Her : you save only single value.

DenisChenu

DenisChenu

2022-10-05 14:50

developer   ~72112

I picture this:

MyPassword is saved with 2 settings ?

MyPassword
and
MyPasswordIsCrypted

There are potential (but surely rare) plugin using MySettingIsCrypted

Maybe : add a column to DB ?

gabrieljenik

gabrieljenik

2022-10-05 14:50

developer   ~72113

There can have issue if a plugin use same system ;) to save value

Not sure I follow.

Remind too : plugin can save array of settings etc …

Using which type of control?

gabrieljenik

gabrieljenik

2022-10-05 14:52

developer   ~72114

MyPassword and MyPasswordIsCrypted

MyPasswordIsCrypted --> That's the same setting i was referring to by Encruption Current State.

DenisChenu

DenisChenu

2022-10-05 14:52

developer   ~72115

Using which type of control?

By default : dropdown with multiple for example : receive an array of value, save a array of value.

But since plugin dev can update settings before saving : it can be a object or a multiple array. Maybe i have one using this for multilingual, must check.

DenisChenu

DenisChenu

2022-10-05 14:52

developer   ~72116

MyPasswordIsCrypted --> That's the same setting i was referring to by Encruption Current State.

Yes :)

gabrieljenik

gabrieljenik

2022-10-05 14:54

developer   ~72117

Let me work on that a bit...

Having this first draft, I believe you can now work on 09056 for completing the whole thing, right?

DenisChenu

DenisChenu

2022-10-05 14:55

developer   ~72118

Using which type of control?

Multiple here : https://gitlab.com/SondagesPro/managament/responseListAndManage/-/blob/master/responseListAndManage.php#L525

Language (set in plugin code) here : https://gitlab.com/SondagesPro/managament/responseListAndManage/-/blob/master/responseListAndManage.php#L429

gabrieljenik

gabrieljenik

2022-10-05 14:58

developer   ~72119

Multiple here : https://gitlab.com/SondagesPro/managament/responseListAndManage/-/blob/master/responseListAndManage.php#L525
Language (set in plugin code) here : https://gitlab.com/SondagesPro/managament/responseListAndManage/-/blob/master/responseListAndManage.php#L429

Ok, maybe we need to do some json_encode before encrypting if it is not scalar

DenisChenu

DenisChenu

2022-10-05 15:34

developer   ~72120

It's done for DB : https://github.com/LimeSurvey/LimeSurvey/blob/cbffb1482a9c193f4bfc2b239954a54268628503/application/libraries/PluginManager/Storage/DbStorage.php#L112

It's the task of the storage https://github.com/LimeSurvey/LimeSurvey/blob/cbffb1482a9c193f4bfc2b239954a54268628503/application/libraries/PluginManager/Storage/iPluginStorage.php#L16

data @mixed for set
and
return @mixed for get

DenisChenu

DenisChenu

2022-10-05 15:35

developer   ~72121

Ok, maybe we need to do some json_encode before encrypting if it is not scalar

Maybe we can just restrict to scalar ?

gabrieljenik

gabrieljenik

2022-10-05 16:52

developer   ~72123

Yes, maybe better :)

DenisChenu

DenisChenu

2022-10-05 17:11

developer   ~72124

More easy ;) and scalar is really needed for resolve bug.
I don't think we need to crypt other.

If not scalar when save : throw exception if debug is set ? And log as error if not ?

gabrieljenik

gabrieljenik

2022-10-05 21:33

developer   ~72132

Last edited: 2022-10-05 21:33

We will handle non scalars with json_encode (at last, dbengine does that).
As to leave a full working solution.
Should be just fine.

gabrieljenik

gabrieljenik

2022-10-05 21:39

developer   ~72133

Another approach we were thinking, for the future, is

  • The plugin should not decide the encryption method, nor execute it, but the storage should.

Then we could:

  • Make all engines to derive from a base engine class (missing here)
  • Add a method to the engine interface
    • SetOptions()
    • SetEncryptedKeys()
    • IsKeyEncrypted()
  • Move what has been done on the get/set at the PlugnBase, to each engine implementation.
  • The engine would known on each set and get if should encrypt a given atribute or not.

Then DbEngine wouldn't need to decide if what is being saved is a scalar or not.
We would just encrypt after json-enconding.

Still, this is something for the future :)

ollehar

ollehar

2022-10-06 00:17

reporter   ~72134

Last edited: 2022-10-06 10:09

The plugin should not decide the encryption method, nor execute it, but the storage should.

Feels like a middleware kind of issue, where encrypt/decrypt is part of a pipeline. Dunno how to apply that here tho.

Unless you let plugins attach middleware classes to the save-load-procedure

https://www.php-fig.org/psr/psr-15/

So the PSR middleware takes a request and returns a response class, but there's no reason we can't adapt that to a database situation. :)

gabrieljenik

gabrieljenik

2022-12-15 13:54

developer   ~73127

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=34137

gabrieljenik

gabrieljenik

2023-02-06 15:57

developer   ~73699

New tests added: https://github.com/LimeSurvey/LimeSurvey/pull/2891

c_schmitz

c_schmitz

2026-11-19 22:22

administrator   ~87672

Plugins in LimeSurvey 7 can list settings in PluginBase::$encryptedSettings to have them stored encrypted (added in PR #2645, with tests in PR #2891). Closing as fixed.

Related Changesets

LimeSurvey: master fb967c7a

2022-11-24 15:27

gabrieljenik

Committer: GitHub


Details Diff
New feature 18375: [security] Some plugin settings need encryption (#2645)

Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
Co-authored-by: Michael Hernandez <michael.hernandez@bairesdev.com>
Co-authored-by: lapiudevgit <devgit@lapiu.biz>
Affected Issues
18375
mod - application/libraries/PluginManager/PluginBase.php Diff File
add - tests/data/plugins/SettingsPlugin.php Diff File
add - tests/functional/backend/SettingsPluginTest.php Diff File

Issue History

Date Modified Username Field Change
2022-09-26 18:23 gabrieljenik New Issue
2022-09-26 18:23 gabrieljenik Issue generated from: 09056
2022-09-26 18:23 gabrieljenik Relationship added related to 09056
2022-09-26 18:35 DenisChenu Note Added: 71955
2022-09-26 18:35 DenisChenu Bug heat 0 => 2
2022-09-26 20:08 gabrieljenik Note Added: 71959
2022-09-26 20:08 gabrieljenik Bug heat 2 => 4
2022-10-04 22:44 gabrieljenik Note Added: 72092
2022-10-04 22:45 gabrieljenik Assigned To => gabrieljenik
2022-10-04 22:45 gabrieljenik Status new => assigned
2022-10-05 14:37 DenisChenu Note Added: 72107
2022-10-05 14:37 DenisChenu Assigned To gabrieljenik =>
2022-10-05 14:37 DenisChenu Status assigned => ready for testing
2022-10-05 14:38 gabrieljenik Note Added: 72108
2022-10-05 14:39 DenisChenu Note Added: 72109
2022-10-05 14:42 gabrieljenik Note Added: 72110
2022-10-05 14:47 DenisChenu Note Added: 72111
2022-10-05 14:47 DenisChenu Assigned To => DenisChenu
2022-10-05 14:47 DenisChenu Status ready for testing => in code review
2022-10-05 14:50 DenisChenu Note Added: 72112
2022-10-05 14:50 gabrieljenik Note Added: 72113
2022-10-05 14:52 gabrieljenik Note Added: 72114
2022-10-05 14:52 DenisChenu Note Added: 72115
2022-10-05 14:52 DenisChenu Note Added: 72116
2022-10-05 14:54 gabrieljenik Note Added: 72117
2022-10-05 14:55 DenisChenu Note Added: 72118
2022-10-05 14:58 gabrieljenik Note Added: 72119
2022-10-05 15:34 DenisChenu Note Added: 72120
2022-10-05 15:35 DenisChenu Note Added: 72121
2022-10-05 16:52 gabrieljenik Note Added: 72123
2022-10-05 17:11 DenisChenu Note Added: 72124
2022-10-05 21:33 gabrieljenik Note Added: 72132
2022-10-05 21:33 gabrieljenik Note Edited: 72132
2022-10-05 21:39 gabrieljenik Note Added: 72133
2022-10-06 00:17 ollehar Note Added: 72134
2022-10-06 00:17 ollehar Bug heat 4 => 6
2022-10-06 00:17 ollehar Note Edited: 72134
2022-10-06 10:09 ollehar Note Edited: 72134
2022-10-07 19:40 DenisChenu Assigned To DenisChenu =>
2022-10-07 19:40 DenisChenu Status in code review => ready for testing
2022-12-15 13:54 gabrieljenik Changeset attached => LimeSurvey master fb967c7a
2022-12-15 13:54 gabrieljenik Note Added: 73127
2022-12-15 13:54 gabrieljenik Assigned To => gabrieljenik
2022-12-15 13:54 gabrieljenik Resolution open => fixed
2023-02-06 15:57 gabrieljenik Note Added: 73699
2026-11-19 22:22 c_schmitz Note Added: 87672
2026-11-19 22:22 c_schmitz Bug heat 6 => 8
2026-11-19 22:22 c_schmitz Status ready for testing => closed