Moodle security concern

Moodle security concern

Karan Rawat-mit -
Antal besvarelser: 5
When i inspect moodle site, it show some information like  sesskey,sessiontimeout,themerev  will it impact on security

M.cfg = {"wwwroot":"http:\/\/XYZ\/moodle","sesskey":"y9tjmPnNnX","sessiontimeout":"28800","themerev":"1705409586","slasharguments":1,"theme":"boost","iconsystemmodule":"core\/icon_system_fontawesome","jsrev":"1705409586","admin":"admin","svgicons":true,"usertimezone":"Asia\/Kolkata","contextid":2,"langrev":1705409586,"templaterev":"1705409586","developerdebug":true};var yui1ConfigFn = function(me) {if(/-skin|reset|fonts|grids|base/.test(me.name)){me.type='css';me.path=me.path.replace(/\.js/,'.css');me.path=me.path.replace(/\/yui2-skin/,'/assets/skins/sam/yui2-skin')}};
Gennemsnitsbedømmelse: -
I svar til Karan Rawat

Re: Moodle security concern

Michael Hawkins-mit -
Core developers-ip assinga Moodle HQ-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Testers-ip assinga
Hi Karan,

The M.cfg variable holds information that sometimes needs to be accessible by JavaScript. The "sesskey" is not the session token used to identify you (ie it is not the same token as you would find in your browser cookies). Despite the name, "sesskey" is actually a cross-site request forgery (CSRF) protection token, which helps add a layer of security when you submit forms, add/update/delete data etc, to ensure those operations only work if you have performed some action within the site (and can't be tricked into performing some operation just by clicking a link on an external website or email, for example). This could be needed by JavaScript for things like dynamically submitted forms or web service (API) requests that don't require a page (re)load.

You can find some more information about sesskey and CSRF in general in our Cross-site request forgery documentation.

I hope that helps answer your question!
I svar til Michael Hawkins

Should we actually take the pain of re-naming sesskey?

Tim Hunt-mit -
Core developers-ip assinga Documentation writers-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga

Given the number of false-positive reports we get because our csrftoken is called sesskey, I wonder it would actually be worth the pain inovlved in renaming it? That might acutally be less painful than trying to educate all the careless 'security researchers' in the world who take one look at something and jump a false conclusion?!

Acutally, that might be doable following Moodle's deprecations process.

  1. Note, I am not suggesting that we change the name of any of Moodle's API functions like require_sesskey(), sesskey() etc. Just changing the URL/POST parameter they use. (Though we could acutally rename them, following the deprecation process, if we acutally thoght that was less confusing. Or make a new autoloaded core\xsrf_token class.)
  2. The things we need to change are the names or URL parameters, hidden form fields, etc.
  3. Obviously in core, we can just change everything directly. ('just' ... well ...). But, how to support third-party code during the transition.
  4. In moodleurl, we can make it so that if you set a param sesskey, it actually sets csrftoken and outputs a debugging message.
  5. In formslib, we can make it iso that if you create a field called sesskey, it acutally gets called csrftoken, with debugging.
  6. Possibly, we could also make it so that if you ask optional/required param for sesskey, it acutally gets you csrftoken, and if you ask for csrftoken, and that does not exist, but sesskey does, then it fetches that with a warning.
Not sure it is acutally worth it, but perhaps worth considering?
I svar til Tim Hunt

Re: Should we actually take the pain of re-naming sesskey?

Mark Johnson-mit -
Core developers-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga

I agree, and I would support changing the API functions too. It's not just people looking at things like this, I've seen internal technical discussions get sidetracked in the confusion between sesskey and the actual session token.

I svar til Tim Hunt

Re: Should we actually take the pain of re-naming sesskey?

Dan Marsden-mit -
Core developers-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga Plugins guardians-ip assinga Testers-ip assinga Translators-ip assinga
To me it feels like the number of reports from clients/community members about the sesskey being a security issue has decreased - 8-10 years ago I think we saw this reported a lot more - these days the false reports I've seen tend to be around other things like "SQL blind injection on login form" and variations on those.

I would like to see it renamed, but like you mention I'm not completely sure it's worth the effort from HQ ... unless someone in the community does the heavy lifting?
I svar til Michael Hawkins

Re: Moodle security concern

Brendan Heywood-mit -
Core developers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga
This happened so often that I wrote a wiki page which is now migrated to here:

https://moodledev.io/general/development/process/security/penetration-testing#the-sesskey-param-is-a-csrf-token

Ever time we get a client wanting a pen test we point them at that first

+1 for renaming it, but yeah would be a very rainy day kinda thing