View Issue Details

IDProjectCategoryView StatusLast Update
16330Bug reportsEncryptionpublic2020-06-30 18:35
Reporterpns1953 Assigned To 
PrioritynoneSeveritypartial_block 
Status newResolutionopen 
Product Version4.2.4 
Summary16330: Encrypted fields not decrypted correctly when viewing responses using web UI or when exported to .lsa
Description

Survey includes one question where encryption has been specified (a multiple short text question requesting Firstname, Lastname).
There are no errors when respondents submit, and the database field is showing ciphertext for responses to this question.
However when responses are examined using the Web UI, or exported in a .lsa file, they are NOT shown correctly decrypted but in what also appears to be ciphertext (but is NOT the same character sequence as in the database, so some attempt at decryption seems to be happening).

The security.php file has not been changed during the currency of this survey.

Steps To Reproduce

1) Import and activate attached survey, which has 16 questions in 4 groups.
2) Complete one response - apart from the first question, null responses can be given to most questions but enter text for [G01Q07] "Please give your name"
3) View response for this entry - field is not decrypted as expected.

Additional Information

1) A simple test survey with one encrypted question of the same type (no other questions in survey) does NOT reproduce the problem - the fields in the question are decrypted correctly.

2) I don't think this is relevant, but "for info" the survey exhibiting the bug, and also the simple test survey noted here, have been moved between LimeSurvey instances - behaviour is the same for each survey regardless of server (other server is on 4.2.3)

TagsNo tags attached.
Complete LimeSurvey version number (& build)4.2.4+200520
I will donate to the project if issue is resolvedNo
BrowserSafari, Chrome
Database & DB-VersionMariaDB 10.3.23
Server OS (if known)linux
Webserver software & version (if known)LiteSpeed
PHP Version7.2

Relationships

related to 15669 assignedcdorin Crypted data are not exported uncrypted 
related to 15668 assignedcdorin Crypted data are not shown uncrypted 
related to 15670 assignedcdorin Reloading response via token : crypted data 

Activities

pns1953

pns1953

2020-05-25 14:55

reporter  

DenisChenu

DenisChenu

2020-05-26 10:06

developer   ~58020

About LSA export : i think it's great if we have a "LSA decrypted" export, then user can choose if done for backup for same server then can be crypted. Or not.

:)

The worst one are Reloading response via token : crypted data

DenisChenu

DenisChenu

2020-05-26 10:09

developer   ~58021

1) A simple test survey with one encrypted question of the same type (no other questions in survey) does NOT reproduce the problem - the fields in the question are decrypted correctly.

? Are you sure ?

Try to import included lsa : i think it broke with a 500 error (Wrong decryption key! Decryption key has changed since this data were last saved, so data can't be decrypted. Please consult our manual at https://manual.limesurvey.org/Data_encryption#Errors.)

pns1953

pns1953

2020-05-26 11:42

reporter   ~58022

Hi - I think I may have diverted attention away from my main issue here by talking about exporting / importing survey archives with encrypted fields.
I did spot issues 15668 and 15669 before posting, and have verified in a one-question survey with encryption that in this case, my export is decrypted - obviously that will be necessary to migrate it to another server with different encryption keys. That may not be so wise for a server backup but that's another question for debate / feature request to select as part of the export.

I did import your test survey and that had an error as expected when I tried to display a response:
"500: Internal Server Error
Call to a member function decrypt() on null"

This is my issue:
With the survey I uploaded here, I get NO errors when I activate the survey, enter one response including 'First Name, Surname', and then display the response.
In the DB I can see that the relevant fields are encrypted, but when displaying the response I see:

[G01Q07_SQ01] (First name) Ys1jwmKfS1+rYB274j2gO06GPrYdL...
[G01Q07_SQ02] (Surname) 5PORCDiCzCidyf4hN0LbX0wdG74d...

(I've shortened the strings above). No error is shown but the decryption is incorrect (the above strings are different from the DB fields for those questions)
Are you able to replicate the problem with my survey?
There seems to be something specific in my uploaded survey that's stopping the correct decryption, though the simple one-question survey with encryption DOES work.
Thanks!

DenisChenu

DenisChenu

2020-05-26 11:49

developer   ~58023

I can confirm i have encrypted field in browse response.

The strange part : « though the simple one-question survey with encryption DOES work.» : you mean a survey with only ONE question (encrypoted) ?

Because a survey with 2 question : one crypted + on not crypted show (and export) only crypted data.

DenisChenu

DenisChenu

2020-05-26 11:49

developer   ~58024

DenisChenu

DenisChenu

2020-05-26 11:52

developer   ~58025

OK : database are not the same, but export as LSA, import as LSA : work and show same data.

pns1953

pns1953

2020-05-26 12:02

reporter   ~58026

Yes that seems to replicate what I'm seeing - both web UI and exported LSA are showing the same data (WRONGLY decrypted version of the DB contents).

Re your previous note - I have made two test surveys - one with only one question that was encrypted, the second survey with two questions, one of which was encrypted. BOTH behaved as expected with the DB fields being encrypted, but shown correctly in the Web UI and being exported unencrypted (as in the attached LSA for the two-question survey).
It is strange that the problem seems to be present in some surveys but not others. If if you are seeing the problem in your survey with only two questions (one encrypted) that may make debugging easier hopefully.

DenisChenu

DenisChenu

2020-05-26 12:31

developer   ~58028

It's not really wrongly encryted since we can export as lsa and import (in same instance) without issue.

If there are a bad system here : we can not do it :)

pns1953

pns1953

2020-05-26 12:59

reporter   ~58032

Yes I understand what you are saying, the decryption on the 'bad' surveys / fields isn't showing an error so must the actual decryption must be happening correctly, but if so, then the correct plaintext string resulting from that decryption isn't being shown in the UI or the LSA. I have checked to see if a small sub-string of what is displayed in the UI / LSA field is present in the encrypted DB field, and it isn't. So I'm not sure where the output shown in UI / LSA is coming from.

GuernseyResearch

GuernseyResearch

2020-06-30 18:35

reporter   ~58599

Further information:
When a person drops out of the survey without a submit the encrypted data appears fine in the show responses for that record.
However, when the person completes the survey with a submit at the end the encrypted data is not properly displayed in the UI (show responses) for that record.

Issue History

Date Modified Username Field Change
2020-05-25 14:55 pns1953 New Issue
2020-05-25 14:55 pns1953 File Added: limesurvey_survey_597794.lss
2020-05-26 10:04 DenisChenu Relationship added related to 15669
2020-05-26 10:04 DenisChenu Relationship added related to 15668
2020-05-26 10:04 DenisChenu Relationship added related to 15670
2020-05-26 10:06 DenisChenu Note Added: 58020
2020-05-26 10:09 DenisChenu Note Added: 58021
2020-05-26 10:09 DenisChenu File Added: survey_archive_crypted.lsa
2020-05-26 11:42 pns1953 Note Added: 58022
2020-05-26 11:49 DenisChenu Note Added: 58023
2020-05-26 11:49 DenisChenu Note Added: 58024
2020-05-26 11:49 DenisChenu File Added: Capture d’écran du 2020-05-26 11-47-31.png
2020-05-26 11:52 DenisChenu Note Added: 58025
2020-05-26 11:52 DenisChenu File Added: Capture d’écran du 2020-05-26 11-51-21.png
2020-05-26 11:52 DenisChenu File Added: Capture d’écran du 2020-05-26 11-50-34.png
2020-05-26 12:02 pns1953 Note Added: 58026
2020-05-26 12:02 pns1953 File Added: survey_archive_971865-2.lsa
2020-05-26 12:31 DenisChenu Note Added: 58028
2020-05-26 12:59 pns1953 Note Added: 58032
2020-05-27 15:36 ollehar Category Response browsing => Encryption
2020-06-30 18:35 GuernseyResearch Note Added: 58599