Audit follow-up: Cached Contentlet instances mutated during relationship hydration
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Parent epic: #36004
Finding
ContentUtils.addRelationships appears to mutate the Contentlet backing map in place via contentlet.getMap().putAll(...). The audit says cached contentlets are stored/returned by reference, so Story Block hydration can add request-scoped relationship/render keys to shared cached instances.
Report references: dotCMS/src/main/java/com/dotmarketing/portlets/contentlet/util/ContentUtils.java:844, ContentletCacheImpl around lines 75 and 91
Potential impact
Concurrent renders may pollute shared cached contentlets, causing nondeterministic rendered output and bloated cache entries under load.
Suggested validation
Render the same cached contentlet concurrently with different relationship/story-block hydration contexts and inspect cached map contents / output variation.
Possible fix
Operate on a defensive copy, for example new Contentlet(contentlet), before adding relationship/render attributes.
Caveat
This was AI-found by Claude from .scratch/audit/REPORT.md. Please perform secondary validation of correctness, severity, and value before actioning.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ContentUtils.java around line 844 and inspect ContentletCacheImpl around lines 75 and 91 to verify whether cached Contentlet maps are shared by reference. Run the proposed concurrent hydration/render validation and inspect cached map contents and output variation; done means the mutation risk is confirmed or ruled out with coverage for the resulting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100