The error
message is not very intuitive; this is purposeful, because it makes it harder for an
attacker to determine the reason why they are receiving the error.
if(!JRequest::getVar(JUtility::getToken(), false, 'POST'))
{
JError::raiseError('403', JText::_('Request Forbidden'));
}
Chapter 11
[ 329 ]
Code Injection
Code injection occurs when code is included in input. The injected code, if not
properly sanitized, may end up being executed on a server or on a client. There
are a number of different ways in which injected code can compromise a Joomla!
installation or a system with which we are interacting.
We will take a look at the two most common forms of code injection used to attack
Joomla!: PHP and SQL code injection.
PHP Code Injection
We should use JRequest and, in some cases, REs to ensure that the input data that
we are handling is valid. Most data validation is very simple and doesn't require
much effort.
Even when data comes from an XHTML form control that is restricted to specific
values, we must still validate the data.
Pages:
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456