This issue description and patches are originally by tim.plunkett and are for the same security vulnerability as SA-CONTRIB-2014-054 - Views - Access Bypass in the D7 Views module:

view::_init_handler() retrieves the list of handlers from the display plugin, stores it on the view, and checks each for access. However, it does not update the display plugin with the filtered list.

Any code after that which uses view_plugin_display::get_handlers() will have an outdated list.

I discovered this via a custom area handler I was writing. It so happens that no area handlers I've found in the wild are exploitable here, since they either do not have a concept of access, or they manually check access in their render() methods (see views_handler_area_view in Views, or entity_views_handler_area_entity in Entity for examples).

Major code of concern (access plugins, field output) uses $this->view->$key, not $this->view->display_handler->get_handlers($key);, so it is no vulnerable.

Things I've found that are susceptible to this: area handlers, the get_field_labels() method, token replacement, and some relationship handling.

Thankfully the fix is easy.

The patch has already been reviewed on the security issue, but I'm marking as "Needs review" here for wider review.

Comments

Status: Needs review » Needs work

The last submitted patch, views-handler-access-D8.patch, failed testing.

dsnopek’s picture

Status: Needs work » Needs review
StatusFileSize
new3.64 KB

Hrm. Patch applies for me with a tiny bit of fuzz. Here's a re-roll!

dsnopek’s picture

StatusFileSize
new4.59 KB

Blergh! My re-roll was no good, it's missing an added file. This version should be good.

The last submitted patch, 2: views-handler-access-D8-2.patch, failed testing.

dawehner’s picture

+++ b/core/modules/views/tests/modules/views_test_data/lib/Drupal/views_test_data/Plugin/views/area/TestExample.php
@@ -19,11 +20,19 @@
+    $options['custom_access'] = array('default' => TRUE, 'bool' => TRUE);

we don't really need 'bool' => TRUE

xjm’s picture

dawehner’s picture

Status: Needs review » Needs work

Before we just fix this, we have to take into account all the bugs caused by this security fix.

dsnopek’s picture

@dawehner: can you give links to the bugs from this fix?

damiankloip’s picture

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new4.4 KB

Straight reroll. The end of may seems a long time ago

xjm’s picture

Since this has a disclosed SA, it should be an upgrade path blocker (per #2341575: [meta] Provide a beta to beta/rc upgrade path).

dawehner’s picture

  1. +++ b/core/modules/views/src/Tests/Handler/AreaTest.php
    @@ -113,6 +113,19 @@ public function testRenderArea() {
    +    $output = drupal_render($output);
    

    note: drupal_render() is already deprecated. use \Drupal::service('renderer')->render() instead.

  2. +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
    @@ -20,11 +21,19 @@
    +    $options['custom_access'] = array('default' => TRUE, 'bool' => TRUE);
    

    Note: this does not need 'bool' => TRUE any longer, but rather an update to the views schema for this plugin.

martin107’s picture

5 weeks is a long time in D8 development ...
Patch still applies, but I am not certain everything will be green

So retesting

devin carlson’s picture

StatusFileSize
new3.2 KB
new5.21 KB

An updated version of #11 with the changes from #13 (replacing drupal_render(), removing 'bool' => TRUE and adding a schema for views.area.test_example).

Status: Needs review » Needs work

The last submitted patch, 16: 2272001-psr4-reroll-16.patch, failed testing.

devin carlson’s picture

Status: Needs work » Needs review
StatusFileSize
new5.12 KB

Fixed wrong file location.

effulgentsia’s picture

+++ b/core/modules/views/src/Tests/Handler/AreaTest.php
@@ -113,6 +113,19 @@ public function testRenderArea() {
+    $this->assertFalse(strpos($output, 'a custom string') !== FALSE);

Testing a negative is always a little fragile, since there might be multiple reasons for a certain string to not appear, access being only one of them. Should we also add a test for turning access on and verifying that "a custom string" is present, thereby increasing our confidence that it not appearing was because of a properly functioning access checker?

effulgentsia’s picture

Also, I think it would be good for the issue summary to explain why the testing strategy employed here (render and check for what rendered) is different than what was committed to D7 Views. I think it's fine to use a different testing approach for the different versions, but since it's a security issue, I think having a documented record of the reason is valuable.

dawehner’s picture

Status: Needs review » Needs work
Issue tags: +Ghent DA sprint

The actual D7 commit had a really explicit test, we really should have that here.
Given that we should mark this issue as needs work, sorry.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

I wrote the original test, I should be able to recreate it for D8.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.8 KB
new6.07 KB
new1.66 KB

I left in the string-based check as well, but added the explicit checks, and included testing when access is allowed.

The last submitted patch, 23: 2272001-vdc-23-FAIL.patch, failed testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Alright, the tests now look a little bit more sane.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3dcbc22 and pushed to 8.0.x. Thanks!

  • alexpott committed 3dcbc22 on 8.0.x
    Issue #2272001 by dsnopek, Devin Carlson, tim.plunkett, xjm, martin107:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.