Problem/Motivation

Originally reported privately and approved for a public issue by the security team
The original reporter likely used an LLM

Drupal's comment reply access check only verifies that the supplied parent comment is published and that its numeric entity_id matches the routed host entity. During validation, direct access to /comment/1 returned 403, but /comment/reply/node/1/comment/1 still loaded the reply form, rendered the hidden parent comment's subject and body, and accepted a child reply. The parent comment belonged to a different entity type that happened to share the same numeric ID. This shows the reply route bypasses the ordinary comment.view access model for the parent comment.
Impact

A user who can comment on one public entity can read and attach replies to published comments from a different hidden entity context when the numeric entity IDs collide.

Relevant vulnerable code blocks:

public function replyFormAccess(EntityInterface $entity, $field_name, $pid = NULL) {
  $access = AccessResult::allowedIfHasPermission($account, 'post comments');
  $access = $access->andIf(AccessResult::allowedIf($status == CommentingStatus::Open)
    ->addCacheableDependency($entity))
    ->andIf(AccessResult::allowedIf($entity->access('view')));

  if ($pid) {
    $access = $access->andIf(AccessResult::allowedIfHasPermission($account, 'access comments'));
    $comment = $this->entityTypeManager()->getStorage('comment')->load($pid);
    $access = $access->andIf(AccessResult::allowedIf($comment && $comment->isPublished() && $comment->getCommentedEntityId() == $entity->id()));
  }
  return $access;
}


case 'view':
  $access_result = AccessResult::allowedIf($account->hasPermission('access comments') && $entity->isPublished())
    ->cachePerPermissions()
    ->addCacheableDependency($entity)
    ->andIf($entity->getCommentedEntity()->access($operation, $account, TRUE));


Vulnerable code flow:

  • The reply route checks whether the host entity is viewable and whether the chosen parent comment is published.
  • For the parent comment, it compares only getCommentedEntityId() to the routed entity ID.
  • It does not verify the parent comment's entity type, field name, or comment.view access.
  • Once the route is granted, the reply form renders the parent comment directly and saves the new child comment with the forged pid.

The PoC demonstrates both unauthorized read and stored linkage. The hidden parent comment could not be viewed directly, but the reply route rendered its subject and body, and the form submission created a new child comment on the public node that remained attached to that foreign parent.

Prerequisites

  • A public node with comments open.
  • A second commented entity or comment field that is not viewable to the reproducing user.
  • A published parent comment on that hidden entity context.
  • A numeric entity ID collision between the public host entity and the hidden parent's real host entity.
  • A user who can post comments on the public node.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3642974

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

larowlan created an issue.

harjyottkaurr made their first commit to this issue’s fork.