Short-lived permission cache ignores its 60s TTL and isn't cleared on permission save or publish: a transient "deny" persists until Flush All Caches
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
調査の方向性
Start with PermissionBitAPIImpl.doesUserHavePermission(), PermissionCacheImpl.putUserHavePermission(), and CaffineCache.put() to trace how the short-lived entry gets its TTL. Then inspect the permission-save and contentlet/Site publish paths named in the issue, along with their cluster invalidation messages. Add integration coverage for TTL expiry and invalidation after commit on all nodes; done means each acceptance criterion passes, including the existing flush behavior.
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
PermissionBitAPIImpl.doesUserHavePermission() caches every yes/no permission decision in the PermissionShortLived cache group. The group is configured to keep each decision for 60 seconds:
## Cache doesUserHavePermission calls for 60 seconds
cache.permissionshortlived.seconds=60
cache.permissionshortlived.size=100000
Two defects mean a single wrong decision, including a transient "deny", is kept indefinitely on the node that computed it:
1. The 60-second TTL is never applied.
PermissionCacheImpl.putUserHavePermission()stores the decision withcache.put(key, hasPermission, shortLivedGroup)(PermissionCacheImpl.java:155on main).- That call reaches
CaffineCache.put(group, key, content), which callsput(group, key, content, Long.MAX_VALUE)(CaffineCache.java:97-98). DynamicTTLCacheuses the TTL stored with each entry (expireAfterCreatereturnsvalue.getTtlInMillis()). The group default built fromcache.permissionshortlived.secondsis used only byDynamicTTLCache.put(key, value), which this path never calls.- So entries never expire. They are removed only by size eviction (100,000 entries) or by a flush of the group.
2. Nothing that changes the inputs to the decision clears it.
On main, flushShortTermCache() is called only from RoleFactoryImpl (L338 and L458): role grant, role revoke and role-tree moves (#35458, #38521). None of the following clear the cached decisions:
- saving, resetting or cascading permissions on an asset (
PermissionBitFactoryImpl.savePermission/assignPermissions,RoleAjax.saveRolePermission,PermissionAjax.saveAssetPermissions,PUT /api/v1/permissions/...). These evict only the primaryPermissionCacheentry for the asset; - saving, publishing or unpublishing a contentlet or Site. The anonymous READ decision depends on whether the asset is live (
PermissionBitAPIImplchecksisLiveContentlet()for the CMS Anonymous role); - the cluster cache invalidation messages that other nodes receive for those changes.
Because respectFrontendRoles is part of the key, anonymous and front-end traffic is hit hardest: one cached false for (asset, READ, anonymous, true) denies every anonymous request for that asset on that node.
#35458 (first in v26.11.11-01) made "Flush Permission Cache" (PermissionCacheImpl.clearCache()) also flush shortLivedGroup. On older versions, including 24.12 LTS, only Flush All Caches clears these decisions.
Production impact (Freshdesk #41409, 24.12.27 LTS, 2 nodes on Kubernetes)
- Both nodes restarted at 05:05 UTC after a deployment.
- 05:06:13: a deployment step saved and published a Site record on node B.
- 05:06:14.984, about 1.7 s later: node A still saw the Site as not live (its cached Site and version info briefly disagreed during cross-node invalidation). It logged:
WARN business.PermissionBitAPIImpl - User 'anonymous' cannot verify READ permissions on Contentlet '<site-id>' because it is not live. ERROR business.HostAPIImpl - User 'null' does not have READ permissions on Site '<site>' - Node A cached that
false. Every anonymous request to the Site on node A was denied for the next 43 minutes, including all$webapi.getAssetPath("//<site>/application/config/...")calls in/api/vtl/*endpoints, which then returned empty responses. Node B, which had cachedtrue, served the same requests normally, so clients saw intermittent failures. - Re-saving CMS Anonymous permissions on the Site (on node A) had no effect. Only Flush All Caches resolved it.
- The "not live" warning is logged only when the decision is computed, not on cache hits. After the first request there was no log trail explaining the denials.
The DB grant (CMS Anonymous READ on the Site, individual permission) was present throughout. The transient "not live" window is expected to self-correct within milliseconds. It became an outage only because the decision was cached with no expiry.
Steps to Reproduce
A. Single node: the TTL is ignored and a permission save doesn't clear the decision
- Create a Site or folder with a file under it, and make sure CMS Anonymous does not have READ on it.
- As an anonymous user, request the file, or call a VTL/page that resolves it with
$webapi.getAssetPath("//<site>/<path>"). The request is denied, anddoes not have READ permissionsis logged. - As an admin, grant CMS Anonymous READ on the Site or folder (Permissions tab → Save, or Roles → Permissions with cascade).
- Wait more than 60 seconds (longer than
cache.permissionshortlived.seconds). - Repeat the anonymous request.
Expected: allowed after the save, or at most 60 seconds later.
Actual: still denied indefinitely. It is fixed only by Flush All Caches (or "Flush Permission Cache" on versions that include #35458).
B. Cluster: a Site publish poisons another node
- Run two nodes behind a load balancer. CMS Anonymous has READ on Site X.
- Keep anonymous traffic going to both nodes for an endpoint that reads Site X (for example a
/api/vtl/*endpoint calling$webapi.getAssetPath("//X/...")). - On node B, edit and publish the Site X record (Sites → Edit → Save/Publish).
- Within about 2 seconds, send an anonymous request for Site X directly to node A, for example with
kubectl port-forward.
Expected: at most a momentary denial that clears within 60 seconds.
Actual: if node A computes the decision while it still sees Site X as not live, it logs the cannot verify READ ... because it is not live warning once, then denies all anonymous requests for Site X until Flush All Caches. Node B is unaffected.
Note: B depends on timing and may need several attempts. A is deterministic and shows the core defect on its own.
Acceptance Criteria
- Entries in
PermissionShortLivedexpire aftercache.permissionshortlived.seconds(default 60). A cachedfalsestops being served within that window without any manual flush. - Saving, resetting or cascading permissions on an asset invalidates the cached decisions for that asset, after the transaction commits, on all cluster nodes. A request repeated immediately after the save reflects the new permissions.
- Saving, publishing, unpublishing, archiving or deleting a contentlet or Site invalidates the cached decisions for that asset on all nodes, so a transient "not live" decision cannot outlive the publish.
- "Flush Permission Cache" continues to clear the short-lived decisions (regression guard for #35458).
- Integration tests cover:
- expiry after the configured TTL;
- invalidation on permission save, run after commit, not inside the transaction;
- invalidation on contentlet/Site publish.
- Optional: log at DEBUG, or rate-limited WARN, when a cached
falseis served for CMS Anonymous on a Site, so a stuck denial leaves a trail.
dotCMS Version
Reported on 24.12.27 LTS v15.
- Confirmed by code review on
main@245acad(2026-11-16): defects 1 and 2 are both still present.
Severity
High - Major functionality broken
Links
Freshdesk: #41409
- Related: #34467 ("Cache Not Flushed After User Permission Update", open): likely the same missing clear-on-save
- Related: #35458 (merged):
clearCache()now flushesshortLivedGroup; role grant/revoke flush it after commit. Origin: private-issues#567 - Related: #38521 (merged): flushes short-lived decisions on role-tree moves
- Related, different path: #35680 / #35684 (merged): an empty permission list cached in the primary
PermissionCacheduring push publishing
- 主要言語
- Java
- スター
- 972
- フォーク
- 493
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 228
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotCMS/core のほかの issue
-
dotCMS : UVE OKR : Customer Support Team : Maintenance Type : Defect
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
OKR : Customer Support Team : Maintenance Type : Defect
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
Opening content from Content Search replaces the "Search" breadcrumb in the new Edit Content screenオープンdotCMS: New Edit Contentlet OKR : Customer Support Team : Falcon Type : Defect
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
Escape the Binary field hint in the legacy content editor so an apostrophe doesn't break the fieldオープンOKR : Customer Support Team : Maintenance Type : Defect
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信
-
dotCMS : Permissions OKR : Customer Support Team : Maintenance Type : Defect
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
desktop grp:about type:graphics-bug ui-public
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
it-at-m/Wahllokalsystem#3846 ·
メンテナーはふだん 2 日以内に返信
-
Area/Connector module/solace Priority/Low Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
ballerina-platform/ballerina-library#9849 ·
メンテナーはふだん 1 日以内に返信