Problem/Motivation

After upgrading our application to Drupal 10.6.12, our custom REST resources started failing intermittently.

The same endpoint sometimes returns a successful response (HTTP 200), while the next request returns 400 Bad Request or Access Denied.

Drupal logs consistently report:

Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException:
in Drupal\Core\Routing\AccessAwareRouter->checkAccess()

The failing requests are logged as:

User: Anonymous (not verified)

even though the requests originate from an authenticated browser session.

Our REST resources are configured to use both cookie and basic_auth authentication.

The issue started only after upgrading Drupal and is reproducible in both Test and Production environments.

Why now?

This issue did not exist before upgrading to Drupal 10.6.12. We are trying to determine whether there were any changes in Drupal's authentication, session handling, REST routing, or access checking that could cause authenticated requests to intermittently be treated as anonymous users.

Steps to reproduce

  1. Upgrade an existing Drupal site to Drupal 10.6.12.
  2. Enable a custom REST resource using cookie and basic_auth authentication.
  3. Authenticate in the browser.
  4. Call the REST endpoint multiple times.
  5. Observe that some requests succeed while others return Access Denied or HTTP 400.
  6. Check Drupal logs and observe CacheableAccessDeniedHttpException with the user shown as Anonymous.

Proposed resolution

Investigate whether Drupal 10.6.x introduced any changes related to:

  • Cookie authentication
  • Session handling
  • REST authentication
  • AccessManager
  • AccessAwareRouter
  • Cacheable access checks

Any guidance on where to investigate further would be appreciated.

Remaining tasks

  • Identify why authenticated requests are intermittently treated as anonymous.
  • Determine whether this is a Drupal core regression or a configuration issue introduced after the upgrade.
  • Verify whether the issue can be reproduced on a minimal Drupal installation.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

CommentFileSizeAuthor
#5 SC-1.png168.49 KBnikhil_110

Comments

nikhil_110 created an issue. See original summary.

cilefen’s picture

Component: other » rest.module
Issue tags: -REST API +Needs issue summary update

Would you please improve the issue summary? It reads "10.x to Drupal 10.6.x", which is imprecise. Because you are asking if there have been any changes to components, state the precise Drupal versions. Additionally, you can check change records and release notes.

longwave’s picture

Priority: Critical » Normal

This does not appear to meet the criteria for a critical bug, downgrading for now.

Reiterating #2: we need to know exactly which versions you upgraded from and to.

nikhil_110’s picture

Issue summary: View changes
nikhil_110’s picture

StatusFileSize
new168.49 KB

I have attached the relevant screenshots for reference.

After upgrading our application to Drupal 10.6.12, we started experiencing intermittent access issues with our custom REST resources.

The same endpoint sometimes returns a successful response (HTTP 200), while subsequent requests return **400 Bad Request** or **Access Denied**. The Drupal logs consistently show the following exception:

```
Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException
in Drupal\Core\Routing\AccessAwareRouter->checkAccess()
```

For the failed requests, the logs also show:

```
User: Anonymous (not verified)
```

even though the requests are coming from an authenticated browser session.

The issue is reproducible in both the Test and Production environments and started only after upgrading Drupal. Our REST resource is configured to use both `cookie` and `basic_auth` authentication.

Could someone please help identify whether this is a known issue or if there were any changes in Drupal 10.6.x related to authentication, session handling, or access checks that could cause this behavior?

cilefen’s picture

What was the prior version of Drupal that didn’t have the error? You are asking questions that only be answered with that information. As I mentioned in comment #2, you can seek the answers too.

nikhil_110’s picture

@cilefen I was previously using Drupal 9.5.x, and this issue did not occur there. The problem started only after upgrading to Drupal 10.6.x. I have already checked our custom REST resource configuration and permissions, but the issue persists. I'm trying to understand whether there were any changes in Drupal 10.6.x related to authentication, session handling, or access checks that could cause this behavior.

longwave’s picture

Status: Active » Postponed (maintainer needs more info)

9.5 to 10.6 is quite the jump, that's a two year period where lots of changes have been made to core and there's not enough information here to help pinpoint exactly where the problem might be.

I would try intermediate versions of core such as e.g. 10.3 to see if the problem exists there - you should be able to narrow it down to a much smaller version range where the problem started, which will make it easier to track down the actual cause.

nikhil_110’s picture

A fix has been found. The issue is related to the Flood module, which blocks certain IP addresses when multiple sites access the same URL, due to real-time data fetching.

can close this issue ? Thanks

longwave’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Thanks for getting back to us.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

longwave’s picture

Category: Bug report » Support request