Ticket #544 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Potentially unsafe global request data is accessible in Action::initialize() and View::initialize() and others

Reported by: david Owned by: david
Priority: high Milestone: 0.11
Component: _OTHER_ Version: 0.11.0RC5
Severity: major Keywords:
Cc: Patch attached:

Description

Not sure if we regard this a bug or not.

My suggestion is to lock the request for both, and also during other calls like isSecure() and getCredentials().

The reason why I think this needs fixing is that if we encourage people to change the output type in a view's initialize method based on request data, then there shouldn't be a way to access potentially insecure request data there.

I don't think there is a use case for accessing the request data in Action::initialize(), and most people probably did the right thing and used the container's request data in View::initialize() anyway, so there shouldn't be much BC breakage (we could label this a security fix and just forget about it, or make this "hardened" mode configurable).

Opinions please?

Attachments

ValidationRunTimeCache.patch Download (5.8 KB) - added by MugeSo 3 years ago.
This patch enables to validation anywhere in ActionFilterChain?
ValidationRunTimeCache.2.patch Download (6.0 KB) - added by MugeSo 3 years ago.
replace indent-space to tab.
addActionMethodsForUseRequestData.patch Download (8.7 KB) - added by MugeSo 3 years ago.
another solution. (add methods for safe handling request data)
addActionMethodsForUseRequestData.2.patch Download (9.0 KB) - added by MugeSo 3 years ago.
add parameter "AgaviRequestDataHolder? $rd" to request data safe methods.

Change History

follow-up: ↓ 2   Changed 3 years ago by MugeSo

I think it will be solved to run validaters in ExecutionContainer::execute(). Or create ValidationFilter? which runs Validaters and register it before SecurityFilter?.

Changed 3 years ago by MugeSo

This patch enables to validation anywhere in ActionFilterChain?

in reply to: ↑ 1   Changed 3 years ago by MugeSo

change in ValidationRunTimeCache?.patch is controller/ CHG:

AgaviExecutionContaioner?

ADD: validateRequestData: validate container's requestData

filter/ CHG:

AgaviExecutionFilter?

CHG: runAction: replace validation to using AgaviExecutionContaioner::validateRequestData

Example: class SomeAction? extends AgaviAction? {

public getCredentials() {

$container = $this->getContainer(); if($container->validateRequestData()) {

// validated, you can use requestData safe.

} else {

// not validated!! requestData is unsafe.

}

}

}

Changed 3 years ago by MugeSo

replace indent-space to tab.

Changed 3 years ago by MugeSo

another solution. (add methods for safe handling request data)

Changed 3 years ago by MugeSo

add parameter "AgaviRequestDataHolder? $rd" to request data safe methods.

in reply to: ↑ description   Changed 3 years ago by MugeSo

Example for addActionMethodsForUseRequestData.2.patch

class SomeAbstructAction extends AgaviAction
{
    /**
     * @var	  SomeModel a model instance
     */
    protected $myModel = null;

    /**
     * initialize $myModel, which is used by child classes.
     */
    public function initializeWithRequestData(AgaviRequestDataHolder $rd)
    {
	$name = $rd->getParameter('name');
	$this->myModel = $this->getContext()->getModel("SomeModel", null, array('name'=>$name));
    }

    /**
     * answer this action is secure or not, acording to request data
     */
    public function isSecureWithRequestData(AgaviRequestDataHolder $rd)
    {
	return $rd->getParameter('subject')=='secret-subject';
    }

    /**
     * answer this action is secure or not if validation fails
     */
    public function isSecure()
    {
	return false;
    }
    
    /**
     * answer credentials, acording to request data
     */
    public function getCredentialsWithRequestData(AgaviRequestDataHolder $rd)
    {
	return array('credential-' . $rd->getParameter('item_id'));
    }

    /**
     * answer credentials if validation fails
     */
    public function getCredentials()
    {
	return null;
    }
}

  Changed 2 years ago by david

(In [2108]) Controller now gives containers a copy of the global request data holder. This means "request_lock_barf" is no longer used; you can create containers in your code and they will have the actual request data in them. Rejoice. Refs #544. Also cleaned up the locking code and made it more secure. And did related bug fixes.

  Changed 2 years ago by david

(In [2114]) Do not store global request data copy in serialized execution containers, and restore current global request data if possible on wakeup. Refs #544

  Changed 2 years ago by david

(In [2115]) Made global request data copy unavailable from the outside of execution containers until cloned in execute(), refs #544

  Changed 2 years ago by david

  • status changed from new to closed
  • resolution set to fixed

(In [2117]) Fixed global request data being accessible in View::initialize() (and in the constructor), closes #544 (best we can do with our current architecture)

Add/Change #544 (Potentially unsafe global request data is accessible in Action::initialize() and View::initialize() and others)

Author


E-mail address and user name can be saved in the Preferences.


Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.