Topic: MODx Security Fix [for 0.9.1]  (Read 26699 times)

Pages: [1] 2  All   Go Down

#1: 15-Apr-2006, 11:46 AM

Coding Team
netnoise
Posts: 215

WWW
This version of document.parser.inc.php fixes some issues in MODx which were published on yesterday.
Please update your current 0.9.1 MODx installations as soon a possible.


How to patch
Open manager/includes/document.parser.class.inc.php in your favourite text editor and replace the function "getDocumentIdentifier" with the code below.

Code:
  function getDocumentIdentifier($method) {
    // function to test the query and find the retrieval method
    $docIdentifier= $this->config['site_start'];
    switch($method) {
      case "alias" :
        $docIdentifier= $this->db->escape($_REQUEST['q']);
      break;
      case "id" :
        if(!is_numeric($_REQUEST['id'])) {
          $this->messageQuit("ID passed in request is NaN!");
        } else {
          $docIdentifier= intval($_REQUEST['id']);
        }
      break;
      default :
      break;
    }
    return $docIdentifier;
  }
« Last Edit: 3-Jul-2006, 04:36 AM by PaulGregory »

#2: 15-Apr-2006, 12:21 PM

jwtyler
Posts: 93

Hacking with minimal knowledge

WWW
I must have missed it. What exactly was the security issue? Repatching all the paches into the parser is not something I look forward to.

#3: 15-Apr-2006, 01:59 PM

Coding Team
netnoise
Posts: 215

WWW
I am a non windows user myself (but recoded it to DOS CR/LF as the original one is ;-)

Quote
Since the document.parser.class.inc.php you posted includes a bunch of other changes slated for the next release
Oupsie, please see updated posting on top.
« Last Edit: 15-Apr-2006, 02:12 PM by netnoise »

#4: 15-Apr-2006, 02:27 PM

Coding Team

vbrilon
Posts: 258

Groovy! Thanks again for the quick catch.

#5: 15-Apr-2006, 02:29 PM

Coding Team

vbrilon
Posts: 258

I must have missed it. What exactly was the security issue? Repatching all the paches into the parser is not something I look forward to.

No need to do that. Just replace the one function above.

#6: 18-Apr-2006, 08:00 AM

Coding Team

TobyL
Posts: 1,024

Nice one, thank you.

Can anyone tell me where the message "ID passed in request is NaN!" will find a place in the language file?  It will be in there at some stage won't it?  I'd like to make that update in an international installation without hardcoding the mesage in the parser class.

Oh, and a small coding question.  Does the
Code:
default :
      break;
server any purpose?  In my simple brain it doesn't make any difference to the flow if you leave it out so why is it there? Am I missing something?

#7: 18-Apr-2006, 08:29 AM

Foundation

rthrash
Posts: 11,353

WWW
I think the default case is required. And thank you for pointing out the messages should probably go in the language files... can you log that  in our Bug (and Support/Feature request tracker), please?
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#8: 19-Apr-2006, 06:34 AM

Nuker
Posts: 11

I'm RUSSIAN!

if user type ./index.php?id=24blablabla in address field then it's get error message about NaN resource.

May'be this code right?  User get only 404 page.
Code:
/*cut*/
     if(!is_numeric($_REQUEST['id'])) {
      $docIdentifier= 0;
/*paste*/

#9: 19-Apr-2006, 06:37 AM

Coding Team

sottwell
Posts: 10,556

WWW
I just set it to return to the home page. No fuss, no bother.
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#10: 21-Apr-2006, 03:26 PM

axiome
Posts: 14

On special version for free.fr (ModX v0.9.O_Free_Edition), this bug exist ?

#11: 21-Apr-2006, 03:34 PM

Coding Team
netnoise
Posts: 215

WWW
What is "ModX v0.9.O_Free_Edition" Huh

#12: 21-Apr-2006, 03:40 PM

Coding Team

sottwell
Posts: 10,556

WWW
I think it's an edition where the installer was patched to handle the French mysql error messages for the French "Free" hosting service. Davidm knows more about it.
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#13: 21-Apr-2006, 03:55 PM

Moderators

Guillaume
Posts: 711

The future is built today.

It is right, Sottwell.

Free is a french hoster which hosts website for free. The space drive is big (1Go I think). There are some limitations and most of the CMS (or other php site build) don't work naturally with Free. So it is necessary to patch this application.
Sorry for my english. I'm french... My dictionary is near me, but it's only a dictionary !

#14: 21-Apr-2006, 04:41 PM

axiome
Posts: 14

Thank you very much for your responses.
I confirm, Free is a host and it offer 1 Go like web space.
Sorry for my english

#15: 21-Apr-2006, 04:51 PM

Marketing & Design Team

davidm
MODx evangelist
Posts: 7,073

The best way to predict the future is to invent it

WWW
I think it's an edition where the installer was patched to handle the French mysql error messages for the French "Free" hosting service. Davidm knows more about it.

You can find the Free Edition thread here. Of course, it's in french, but you'll see there that this version has been downloaded almost 600 times....

Actually the problem with MySQL error message happened with all french host set up to display error message in French (with is now solved with the mysql Errno fix) ... Free was another problem which you helped me fix, Susan :
chmod "locked" by hosting at 700 and 644 : possible to run MODx ?

You might not remember but you helped me fix all the includes path, a pretty daunting task which I never updated for 0.9.1

Would it be fair to guess that patching MODx 0.9.0 document.parser.class is perfectly safe ?
Didn't check but was there a change here between 0.9.0 and 0.9.1 ?
« Last Edit: 21-Apr-2006, 05:02 PM by davidm »
.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez à l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net

#16: 21-Apr-2006, 05:04 PM

Coding Team
netnoise
Posts: 215

WWW
If you're currently using version 0.9.0, you should also apply this patch, to avoid a XSS vulnerability that has been fixed in 0.9.1.

#17: 21-Apr-2006, 05:13 PM

Marketing & Design Team

davidm
MODx evangelist
Posts: 7,073

The best way to predict the future is to invent it

WWW
Thanks for the tip Timon, I had forgotten about this...

I'll post something to have MODx 0.9.0 "Free Edition" users patch their installs.
And I'll patch the package so that new downloads are covered Smiley
.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez à l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net

#18: 21-Apr-2006, 07:41 PM

Coding Team

sottwell
Posts: 10,556

WWW
Would it be fair to guess that patching MODx 0.9.0 document.parser.class is perfectly safe ?
Didn't check but was there a change here between 0.9.0 and 0.9.1 ?

It's not that difficult to patch any version. The pre-.9 versions use a slightly different function, but the switch is much the same, and it's not at all hard to add the validity checks. I did it a bit differently; instead of the cryptic NaN message I just throw the would-be hacker back to the home page. I would feel better about if if the security gurus would verify that this will solve the problem.

FOR PRE-0.9x INSTALLS ONLY!!!! DO NOT APPLY THIS PATCH TO A 0.9X INSTALLATION!!!
Code:
function getDocumentIdentifier($method) {
// function to test the query and find the retrieval method
switch($method) {
case "alias" :
return mysql_escape_string($_REQUEST['q']);
break;
case "id" :
  if(is_numeric($_REQUEST['id'])) {
    return $_REQUEST['id'];
} else {
    return $this->config['site_start'];
}
break;
case "none" :
return $this->config['site_start'];
break;
default :
return $this->config['site_start'];
}
}
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#19: 22-Apr-2006, 04:31 AM

Coding Team
netnoise
Posts: 215

WWW
Even if it sounds paranoic Grin it's important to use:
Code:
return intval($_REQUEST['id']);

#20: 22-Apr-2006, 04:34 AM

Coding Team

sottwell
Posts: 10,556

WWW
Even if it sounds paranoic Grin it's important to use
Code:
return intval($_REQUEST['id']);
So that should be
Code:
case "alias" :
return intval($_REQUEST['q']);
break;
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
Pages: [1] 2  All   Go Up
0 Members and 1 Guest are viewing this topic.