Problem/Motivation

reported by: https://www.drupal.org/u/willzyx

STR:

Users with 'Create|Delete|Edit translations' permission can access the translation overview page of an entity (and see some entity info) even if they can't access to the entity itself.
This because content translation access checking, never takes into account if user can access the entity, when grants access to the entity translation overview page.

On a clean installation - standard profile:
1) Enable content_translation and language modules
2) Add a language in admin/config/regional/language
3) Enable translation for Article content type in admin/config/regional/content-language
4) Grant 'Create translations' permission to 'authenticated user' role
5) Revoke 'View published content' permission to 'authenticated user' role
6) Create an Article node (node/1)
7) Login as a user with only 'authenticated user' role
8) Go to node/1/translations. You can see the translation overview and some entity info

This bug does not affect Drupal 7 because the access callback for the translation overview page explicitly calls node_access() for determine if the user can access (see _translation_tab_access())

Proposed resolution

Add an additional check that the user can access the node before allowing them to access the translation form.

Remaining tasks

User interface changes

n/a

API changes

none

Data model changes

None

original report was part of the Drupal 8 bug bounty
https://tracker.bugcrowd.com/drupal/submissions/465314

reported by: https://www.drupal.org/u/willzyx

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug, since it's a security hole
Issue priority Critical or maybe downgrade to major since while we would probably issue a SA for this after release, it requires a very unusual configuration.
Prioritized changes The main goal of this issue is security
Disruption Not disruptive.

Comments

pwolanin created an issue. See original summary.

pwolanin’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new960 bytes

First patch, though I'm not 100% sure the permission construction is generically correct.

pwolanin’s picture

Issue tags: +Needs tests

Should add tests to check the 2 modified routes following the STR

Status: Needs review » Needs work

The last submitted patch, 2: 2558905-2.patch, failed testing.

cilefen’s picture

StatusFileSize
new2.23 KB

A basic test of the base route.

pwolanin’s picture

Not seeing an obvious way to add a generic "view" check for any entity type. This might be failing since the test entity just has access TRUE.

legolasbo’s picture

Status: Needs work » Needs review

Waking up testbot for #5

Status: Needs review » Needs work

The last submitted patch, 5: content_translation-2558905-5.patch, failed testing.

plach’s picture

What about adding that only to node? It's only node that exposes the "problematic" permission atm...

wim leers’s picture

What about adding that only to node? It's only node that exposes the "problematic" permission atm...

Doesn't it make sense to always have content translation require that you can view the entity before you can translate it? view AND translate as the requirements to access translations makes a ton of sense to me, and is exactly what this patch does.

So, can you clarify why you think this should only be done for nodes?

plach’s picture

Well, it was a response to:

Not seeing an obvious way to add a generic "view" check for any entity type.

but obviously having it working for any entity type would be more desirable. I'll have a look to those failures later...

cilefen’s picture

To cause this you need a silly misconfiguration of permissions. It's almost "works as designed". I don't think this is critical.

willzyx’s picture

Issue summary: View changes

To cause this you need a silly misconfiguration of permissions. It's almost "works as designed". I don't think this is critical.

not at all. Sure, The steps to reproduce the issue produce an "extreme" permissions configuration case, but it is just to show the bug.
Users with 'Create|Delete|Edit translations' permission can access the translation overview page even if they can't access to the entity itself; and this include unpublished entity or entity that some content access module protects. And these cases are not related to a permission misconfiguration.

Another example that shows the bug: on a clean installation - standard profile:
1) Enable content_translation and language modules
2) Add a language in admin/config/regional/language
3) Enable translation for Article content type in admin/config/regional/content-language
4) Grant 'Create translations' permission to 'authenticated user' role
6) Create an Article node (node/1) and unpublish it
7) Login as a user with only 'authenticated user' role
8) Go to node/1/translations. You can see the translation overview and some entity info

plach’s picture

@willzyx:

Thanks for the detailed description, those steps might be useful to provide additional test coverage, or at least improve the current one :)

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new7.02 KB
new4.79 KB

Another example that shows the bug: on a clean installation - standard profile:
1) Enable content_translation and language modules
2) Add a language in admin/config/regional/language
3) Enable translation for Article content type in admin/config/regional/content-language
4) Grant 'Create translations' permission to 'authenticated user' role
6) Create an Article node (node/1) and unpublish it
7) Login as a user with only 'authenticated user' role
8) Go to node/1/translations. You can see the translation overview and some entity info

This is basically what the patch in #2558905-5: Content translation module - Information disclosure by insufficient access checking adds as test coverage.

Not seeing an obvious way to add a generic "view" check for any entity type. This might be failing since the test entity just has access TRUE.

I don't get that statement. Its just a bug in entity_test.routing.yml that we don't add the required access checking.
This is one of the reasons why #2350509: Implement auto-route generation for all core entities and convert all of the core entities. is kinda important. It allows us to standardize more.

Other test failures can be fixed by providing the needed permissions.

Status: Needs review » Needs work

The last submitted patch, 15: 2558905-15.patch, failed testing.

willzyx’s picture

@dawehner in the test I see:

+++ b/core/modules/content_translation/src/Tests/ContentTranslationOperationsTest.php
@@ -75,6 +76,20 @@ function testOperationTranslateLink() {
+
+    // Ensure that an unintended misconfiguration of permissions does not open
+    // access to the translation form. @see https://www.drupal.org/node/2558905

the comment is wrong and probably the test should be updated. We are not talking of misconfiguration of permissions, the steps to reproduce in 13 (if you read it carefully :)) show that the bug is reproducible without a "particular" permissions configuration

dawehner’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new12.47 KB
new6.02 KB

the comment is wrong and probably the test should be updated. We are not talking of misconfiguration of permissions, the steps to reproduce in 13 (if you read it carefully :)) show that the bug is reproducible without a "particular" permissions configuration

Oh I see what you mean ...

Let's expand the test coverage for that.

Status: Needs review » Needs work

The last submitted patch, 18: 2558905-18.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new13.32 KB
new1.92 KB

We could do the following:

Status: Needs review » Needs work

The last submitted patch, 20: 2558905-20.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new16.52 KB
new4.64 KB

Seriously testbot ...

dawehner’s picture

StatusFileSize
new14.33 KB
new4.23 KB

But seriously dawehner :)

The last submitted patch, 22: 2558905-22.patch, failed testing.

pwolanin’s picture

Looks good, except I 'm not sure about requiring admin permission here:

+        // There is no direct viewing of a menu link, but still for purposes of
+        // content_translation we need a generic way to check access.
+        return AccessResult::allowedIfHasPermission($account, 'administer menu')

Maybe we should re-use the code from update - that seems to be checking view access by checking the the route is accessible?

dawehner’s picture

Maybe we should re-use the code from update - that seems to be checking view access by checking the the route is accessible?

Well, this is about route access, so we can't really forward to the route access.

pwolanin’s picture

Given that the other check requires 'administer menu' access, that seems reasonable.

These should use Url::fromRoute() in a couple spots in the test:

+    $this->drupalGet('node/' . $node->id() . '/translations');
larowlan’s picture

Status: Needs review » Reviewed & tested by the community

This looks ready to me, couple of minor issues that could be resolved on commit.
With regards to use of paths in tests, I think that we're ok

  1. +++ b/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php
    @@ -35,11 +35,13 @@ protected function setUp() {
    +
    +
    

    exteme nit™: not needed (can be removed on commit)

  2. +++ b/core/modules/content_translation/src/Tests/ContentTranslationOperationsTest.php
    @@ -75,6 +76,33 @@ function testOperationTranslateLink() {
    +    // access to the translation form. @see https://www.drupal.org/node/2558905
    

    Do we normally reference issues in tests? Only for security?

dawehner’s picture

StatusFileSize
new14.32 KB
new2.03 KB

Do we normally reference issues in tests? Only for security?

Well, I think we should, it gives more information ...

Addressed 27 as well.

willzyx’s picture

not sure if is in the scope of this issue but I think we should also take in account content_translation_translate_access() and consider to add an entity access check. It seems to suffer of the same bug, since no explicit entity access check is done in this function

pwolanin’s picture

Seems like itt's part of the same bug. though looking at uses it may just be exposing links. Still, I think it's reasonable to add a view check.

pwolanin’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new15.5 KB
new1.18 KB

Like so? Needs a test maybe?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new16.56 KB
new1.53 KB

Sure, why not

plach’s picture

Looks good to me, thanks! RTBC +1

If we happen to reroll this:

+++ b/core/modules/content_translation/src/Tests/ContentTranslationOperationsTest.php
@@ -75,6 +76,63 @@ function testOperationTranslateLink() {
+   * @see acontent_translation_translate_access()

typo

dawehner’s picture

StatusFileSize
new16.56 KB
new709 bytes

Thank you plach

Yeah let's quick fix that.

:)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice tests and nice find @willzyx. Committed 112e9bf and pushed to 8.0.x. Thanks!

  • alexpott committed 112e9bf on 8.0.x
    Issue #2558905 by dawehner, pwolanin, cilefen, plach, willzyx: Content...

Status: Fixed » Closed (fixed)

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