Skip to content

A11y scan hardening: block non-AJAX mobile nav callback access - #5642

Open
accesswatch wants to merge 4 commits into
mainfrom
accessibility-fixes-mobile-nav-callback
Open

A11y scan hardening: block non-AJAX mobile nav callback access#5642
accesswatch wants to merge 4 commits into
mainfrom
accessibility-fixes-mobile-nav-callback

Conversation

@accesswatch

Copy link
Copy Markdown
Contributor

Summary

  • Prevents non-AJAX crawling of the mobile navigation callback endpoint.
  • This endpoint is intended to return Drupal AJAX commands, not standalone HTML documents.

Issue types targeted from CSV

  • html-has-lang
  • document-title
  • label

These were reported on /az_core/mobile_nav_callback/... URLs where scanners treated AJAX payloads as full pages.

Change

  1. modules/custom/az_core/src/Controller/MobileNavController.php
    • Injects request_stack and checks isXmlHttpRequest().
    • Returns 404 for non-AJAX requests.
    • Preserves current AJAX behavior for legitimate mobile menu requests.

Impact

  • Impacted files: 1
  • Scope: high-confidence endpoint hardening for crawler-facing false-positive reduction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@accesswatch
accesswatch requested a review from a team as a code owner May 28, 2026 01:26
Copilot AI review requested due to automatic review settings May 28, 2026 01:26
@accesswatch
accesswatch requested a review from a team as a code owner May 28, 2026 01:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens the az_core.mobile_nav_callback controller endpoint so it only serves Drupal AJAX command payloads to legitimate AJAX requests, reducing accessibility scanner false-positives caused by crawlers treating the callback response as a standalone page.

Changes:

  • Inject request_stack into MobileNavController.
  • Reject non-AJAX requests by throwing NotFoundHttpException (404) before building the AJAX response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tadean
tadean self-requested a review August 7, 2026 18:12
@accesswatch
accesswatch requested a review from joeparsons August 7, 2026 19:40
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@az-digital-bot

Copy link
Copy Markdown
Contributor

Tugboat has finished building the preview for this pull request!

Link:

Dashboard:

@bberndt-uaz

Copy link
Copy Markdown
Contributor

The proposed solution does not appear to work. Try clicking on this and observe that you don't get a 404: https://pr5642-n4xghjxwthnpt0xaj2ad8ovkksksbpgg.tugboatqa.com/az_core/mobile_nav_callback/main/Main%20Menu.

The isXmlHttpRequest() method merely checks for a X-Requested-With header which may or may not be present with AJAX requests. Also, I don't see this method being used this way in Drupal core. Moreover, as far as I can tell, there is no reliable way to determine if a request was made with AJAX. We could explore some kind of alternate solution in the future, but I think this pull request can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants