Issue Details (XML | Word | Printable)

Key: MDL-16658
Type: Bug Bug
Status: Open Open
Priority: Blocker Blocker
Assignee: Eloy Lafuente (stronk7)
Reporter: David Mudrak
Votes: 20
Watchers: 22
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Teachers are able to create user accounts during restore even they don't have "moodle/user:create"

Created: 24/Sep/08 10:50 PM   Updated: Thursday 02:50 AM
Return to search
Component/s: Backup
Affects Version/s: 1.9.2
Fix Version/s: 1.9.7

File Attachments: 1. File MDL-16658.diff (1 kB)

Issue Links:
Relates
 

Participants: Anthony Borrow, Brian Warling, Daniel Neis, David Mudrak, Eloy Lafuente (stronk7), Enrique Castro, Jonathan Moore, Mark Webster, Martin Dougiamas, Petr Skoda and Thomas Robb
Security Level: None
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
Please read http://moodle.org/mod/forum/discuss.php?d=106252 and http://moodle.org/mod/forum/discuss.php?d=104358

FULL STEPS TO REPRODUCE
=========================
1. go to server A
2. backup a course together with user accounts
3. go to server B and log in as a Teacher or Course creator
4. restore the backup

WHAT WAS EXPECTED
===================
As neither Teacher nor Course creator have granted capability "moodle/user:create", no users are restored

WHAT ACTUALLY HAPPENS
=======================
New users are registered. The Admin does not know anything.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Brian Warling added a comment - 25/Sep/08 02:38 AM
I'm hoping this can be addressed soon. Because of this, we've disabled course restore for non-administrators. Thanks... Brian

Anthony Borrow added a comment - 26/Sep/08 08:03 AM
I agree that the users should not be added; however, we also need to add feedback so that the user attempting to restore understands that they did not have the privileges and that the user was not added. My +1 for working this out. Perhaps the capability for teachers to create users and ability to create users on restore should be distinguished. Peace - Anthony

Martin Dougiamas made changes - 06/Oct/08 04:49 PM
Field Original Value New Value
Fix Version/s 1.9.4 [ 10300 ]
Fix Version/s 1.9.3 [ 10290 ]
Martin Dougiamas made changes - 06/Oct/08 04:50 PM
Link This issue has a non-specific relationship to MDL-12001 [ MDL-12001 ]
Jonathan Moore added a comment - 13/Nov/08 04:41 AM
+1 from us on this too. Seems like a serious circumvention of security model. This could be exploited maliciously, through specially crafted course restore files, all be itt only to create non-privileged users.

Anthony Borrow added a comment - 24/Dec/08 07:42 AM
David - This is a simple way to prevent the users from being created. I've not tested it but I just wanted to provide a quick way to prevent the users from actually being created. I do not know what impact this might have on other aspects of the restore in terms of the assignments for users that are not created in the restore. I think ultimately the error message should be specific about the user data that is not restored and the reason. I didn't want to create new language strings for this simple patch but thought it might be a step in the right direction for those who feel like they cannot allow teachers to do restores. Peace - Anthony

p.s. - Eloy - Do you think that we should label this as a possible security issue? I could see the argument being made but I don't see too much harm in it.


Anthony Borrow made changes - 24/Dec/08 07:42 AM
Attachment MDL-16658.diff [ 15949 ]
Petr Skoda made changes - 22/Jan/09 02:18 AM
Fix Version/s 1.9.5 [ 10320 ]
Fix Version/s 1.9.4 [ 10300 ]
Petr Skoda made changes - 22/Jan/09 02:20 AM
Link This issue has been marked as being related by MDL-17917 [ MDL-17917 ]
Thomas Robb added a comment - 22/Apr/09 08:26 PM
While I fully agree that the creation of users by non-authorized instructors/course creators needs to be restricted, we need to be sure that this capability can be easily allowed in cases where it is desirable.

I, for example, have a Moodle set up where I am giving course space to teachers at other institutions. They want to use my "MoodleReader module" but for various reasons (mainly the resistance of local staff admins) can't set it up on their own institution's server. I would like them to be able to back up the users in their courses and then restore them to their course on my Moodle so that I don't have to intervene each time. Without the current "bug" they would have to have the students enroll via the mail/confirmation process. This simply would not work efficiently with a large number of students – too many misentered email addresses or other ways that the confirmation message might go astray.


Anthony Borrow added a comment - 23/Apr/09 01:52 AM
Thomas - Any reason why you could not assign the user create capability to those teachers? It would seem that would allow you to do what you want if I understand it correctly. Peace - Anthony

Petr Skoda made changes - 06/May/09 06:21 PM
Fix Version/s 1.9.5 [ 10320 ]
Fix Version/s 1.9.6 [ 10340 ]
Daniel Neis added a comment - 11/Jun/09 01:32 AM
Hello, here at Federal University Of Santa Catarina, Brazil, we have a system that sincronizes the central database of the university with the moodle database, with that all users are automatically created and the data automatically updated.

We let the teachers import courses from any moodle installation they want and sometimes it is not possible to do the backup of original course without user information. If we can set a permission to not allow they create users during backup would be great.


Petr Skoda added a comment - 01/Jul/09 07:23 PM
why not simply add new capability "moodle/backup:createusers", this would be more backwards compatible imho

Daniel Neis added a comment - 01/Jul/09 08:27 PM
I like Peter's approache. A new capability would be great

Martin Dougiamas added a comment - 05/Oct/09 04:00 PM
Eloy, can we add a new capability for 1.9.6 ? This bug has a lot of votes.

Martin Dougiamas made changes - 05/Oct/09 04:01 PM
Priority Critical [ 2 ] Blocker [ 1 ]
David Mudrak made changes - 05/Oct/09 05:44 PM
Link This issue has a non-specific relationship to MDL-9251 [ MDL-9251 ]
Eloy Lafuente (stronk7) added a comment - 05/Oct/09 08:01 PM
Sorry,

really I don't think that using "moodle/user:create" neither "moodle/backup:createusers" is the proper solution. For me there are more "variables" is this problem. Let me explain the thing with one simple use-case:

Imagine server "A", with course "C" and student "S" enrolled (and with forum posts and other activity on it).

Teacher makes backup of course "C". Obviously it will include information of user "S" plus all his forum posts.

Then, for any reason, student is "deleted" from server A (so his login is changed along with other personal information), although forum posts and related info continues there, associated with the "deleted" user.

Then, teacher tries to restore backup into a new course, or into the same course (A) but deleting data first.

At this point, student "S" won't be found anymore in the server (check is performed by login - another problem - that has been trashed by the deletion), so restore MUST re-create it or, later in the process, when restoring forum posts, there won't be any user to link the info to). If we rely on any capability to decide if users will be created or no, we can easily end with non-restorable information. So, simple check isn't enough at all (nor for restoring in a different server nor for restoring in the same server, it's important to note that the problem can happen in any server, as the use case above demoes).

So, IMO, we can follow only 2 "safe" approaches:

  • - The radical one: Preventing to restore ANY user related-info if user lacks the "moodle/user:create" (or "moodle/backup:createusers") capability. Note I'm not talking only about to prevent user creation BUT about to prevent restore of ANY user-related info (forum posts...) what can lead to a BIG loss of functionality for, say, 95% of sites. Of course, it's 100% safe, because now new users will be created nor information will be "orphaned". This is the approach we recently followed when restoring backup files containing mnet users (MDL-17009) that now are only allowed to "moodle/user:create" users. Of course, we followed that approach for mnet users because it only affects "0.0001%" of sites (those using MNET). The question is if the same approach is extensible to all course backups.
  • - The correct one: It involves to pre-check in the early steps of restore (before performing the restore of activity itself), if all the users to be added already exist in destination server. If that pre-check passes, then restore can continue because we have assured that all the activity will be properly linked to existing users, hence nothing will became orphaned. Obviously this pre-check will be performed when the user misses the "moodle/user:create" (or "moodle/backup:createusers") capability only. Users able to create users don't need the check at all. But we have two big problems with this pre-check: First of all, it doesn't fit well in current backup/restore architecture (it will be really hackery to introduce such a check). And second, we need to improve our algorithm of detecting existing users (see MDL-15598 for example), because current match by "login" is really inaccurate).

So... summarising, we have two alternatives:

  • Completely prevent restoring backup files with user info to users missing the "moodle/user:create" (or "moodle/backup:createusers") capability. Easily doable, although perhaps the default for teachers, for better BC should be "moodle/backup:createusers" => allowed.
  • Implement a complete user pre-check with an stronger match than the current one. More complex to implement but also tons better solution.

Sorry but the long comment, just trying to explain that it isn't only a matter of adding one capability (unless we want to be radical). Please comment, ciao


Thomas Robb added a comment - 05/Oct/09 08:15 PM
Eloy says:
>Implement a complete user pre-check with an stronger match than the current one. More complex to implement but also tons better solution.

This is fine, but the site administrator needs to be able to elect whether this pre-check is enforced or not. As I stated in my comment of 22/Apr/09, I have sites where I need to permit others to do such restores. Can there be a capability created which, if assigned, would permit specific users to restore without the strict check?


Eloy Lafuente (stronk7) added a comment - 05/Oct/09 08:25 PM
Hi Thomas,

yes, I think we can use that new proposed capability "moodle/backup:createusers" to allow users not having "moodle/user:create" (admins) to bypass any check/restriction. No problem with that.

They keys here are which approach we must follow (the "radical" or the "correct" one above) and which defaults (for each legacy role) should we apply to that new capability "moodle/backup:createusers".

Ciao


Mark Webster added a comment - 10/Oct/09 02:13 AM
My vote goes to the "correct" solution, but it'd be good to give the option to proceed with the restore without the user info.

IMHO, only admins should get "moodle/backup:createusers" by default.


Enrique Castro added a comment - 13/Oct/09 03:18 AM
Hi,
I think both approaches proposed by Eluy have merit. The "correct" one is fine, and the sophisticated way. I vote for this for people with "moodle/backup:createusers" capability.

But the "radical" has its own merit.
As a case use, we at ULPGC, as in many Universities, synchronize users from external DB. We want adminds and teh liek to be able to create users on restore but nobody else. We instruct teachers to backup/restore courses from one year to other "Without user activity" and "without users", but there are always errors.

A configurable switch to disallow teachers to restore users &userdata would be very useful (now, we hack restorelib for this purpose): i.e. vote also for capability check to fall into no users/no user info restore when "moodle/user:create" is not allowed.


Eloy Lafuente (stronk7) made changes - 20/Oct/09 05:23 PM
Fix Version/s 1.9.7 [ 10360 ]
Fix Version/s 1.9.6 [ 10340 ]
Eloy Lafuente (stronk7) added a comment - 20/Oct/09 05:24 PM
Moving this to 1.9.7.

I'm aimed to do this in the "correct" way: new capability + pre-check all users, but it isn't trivial to implement now. I hope to be able to do so as we'll need that also for 2.0 (where I'm working now).


Petr Skoda made changes - 16/Nov/09 03:47 AM
Link This issue will help resolve MDL-20840 [ MDL-20840 ]
Martin Dougiamas added a comment - 16/Nov/09 10:28 PM
We talked about a moodle/backup:userinfo setting for 1.9.7 that disallows all user restoring (including creating) and user data, similar to what Enrique mentioned above.

Eloy Lafuente (stronk7) made changes - 16/Nov/09 10:30 PM
Link This issue has been marked as being related by MDL-20849 [ MDL-20849 ]
Daniel Neis added a comment - 19/Nov/09 01:45 AM
Hello,

i have seen a commit at MOODLE_19_STABLE (http://git.catalyst.net.nz/gw?p=moodle-r2.git;a=commit;h=f484cb3e30e485958bafe54a391064e5d298d6c2) that adds the moodle/backup:userinfo capability, disabled by default for teachers.
Is it related to this issue? It checks for the capability in the backup process, but not in the restore. Maybe it should be two distinct caps...


Eloy Lafuente (stronk7) made changes - 19/Nov/09 02:37 AM
Link This issue has been marked as being related by MDL-20834 [ MDL-20834 ]
Eloy Lafuente (stronk7) added a comment - 19/Nov/09 02:50 AM
Hi Daniels,

both MDL-20834 (moodle/backup:userinfo) and MDL-20849 (moodle/restore:userinfo) are there to prevent completely any backup/restore operation related with user data. Not only the creation of users but anything related with users (like forum posts, assignment submissions...).

Both are being implemented right now and both will debut in Moodle 1.8.11 and Modle 1.9.7.

About how they are related with this issue, I'd say that only "tangentially"; they are more restrictive than the proposed "moodle/restore:createuser" as far as they prevent ANY operation with user info, not only account creation but ANY user info.

But, no matter of them, and how every site/institution decides to use them (note that, by default, they aren't granted to teachers!), the "moodle/restore:createuser" must land sooner than later, with proper pre-check and so on, as commented above. And will work together with the moodle/restore:userinfo one, so both will need to be allowed to successfully restore courses needing to create users.

I hope I'll be able to finish the bugs above (and some more I've pending for 1.8.11, 1.9.7 releases) and then, invest some time with this (new capability + proper pre-check).

Ciao