Closed bret-miller closed 8 years ago
OK, to further suggest this is a security issue, I am able to use the URL from the block to send a message from a different computer without ever logging into the site or displaying the course. The URL (without domain name) is: https://xxxx/blocks/messageteacher/message.php?courseid=8&referurl=https%3A%2F%2Fxxxx%2Fcourse%2Fview.php%3Fid%3D8&recipientid=5
I've attempted to reproduce this, but cannot. message.php calls require_login(), so any attempts to access the page (either loading the form via AJAX or directly entering the URL) are redirected to the login form.
I hate to post this here, but [redacted] gives me the message page without logging in.
Got it, thanks. I didn't have guest access enabled while I was testing. I'll look into it.
I've just pushed a fix which checks for moodle:site/sendmessage capability. The guest user doesn't have this by default, so this should fix the problem. Please can you test it and confirm for me?
Well, it didn't help. I took the time to look at the code and I don't understand why it's not blocking the message form. That should throw an access exception when using guest access, but it's not--at least not visibly.
The only reason I can think that it would allow the page to be viewed by guest is if, for some reason, the Guest role has the moodle:site/sendmessage capability enabled.
It doesn't. I checked. It was "not set". I changed it to "prohibit" in case that would help, but it didn't help either.
When the session times out, this block sends messages from guest. This makes it very hard to tell who the message is from unless the student signs it. Plus guest isn't allowed to send messages at all so it shouldn't be allowed here either. Guest is also not allowed to display the block.
To reproduce: I logged in as a student and displayed a course. All our courses have the Message My Teacher block. Then I waited until my session expired. Then clicked the teacher's name to display the message form. It displayed it and I went ahead and sent my message. The message was accepted, and sure enough, it was from "Guest User". So there are probably two permissions issues here. First, the block shouldn't display the message form if the session is invalid or at least should check whether the current account (guest in this case) is allowed to send a message. And second, the function it uses to send the message should probably check to see if the current account is allowed to send a message. That second issue probably isn't yours, but perhaps the block should also check the permissions before it tries to send the message.