Caching Case-sensitivity Problem
Issue As Reported By Client:
Recently we have a problem: some pages return error 404. These pages however exist and published in dotCMS and we can see them in preview mode. After cache flushing or republishing of page the problem is solved. But after a while the problem appears again.
We’ve researched the problem and found that cache contains value "NOTFOUND*" for these pages. When we try to load page by the link containing characters in wrong case (for example www.site.com/somepage instead of www.site.com/somePage) dotCMS can't find it and puts "NOTFOUND*" in cache. But search in cache is case-insensitive. And when next time we try to open the page from cache using right case we also receive the error. If page doesn't exist in cache, dotCMS at first tries to find it's identifier (com.dotmarketing.cache.LiveCache method getPathFromCache(String URI, String hostId, Long languageId) line 254 in dotCMS 2.5.4). And dotCMS makes request to DB to get identifier (com.dotmarketing.business.IdentifierFactoryImpl method findByURI(String hostId, String uri) line 146 in version 2.5.4) "from identifier in class com.dotmarketing.beans.Identifier where parentpath = ? and assetname = ? and host_inode = ?". This request will work only for right case.
So we think it's a bug. It can be reproduced as follows:
- Clear cache.
- Try to open the page by the link containing characters in wrong case.
- This page returns 404 in any cases and you can fix it only by flushing cache or by republishing.
This bug can cause serious problems:
- User can use wrong case accidentally and page becomes unavailable.
- We think that bug can be considered as vulnerability. A malefactor can make some pages unavailable.
We have fixed it in our project by making request to Identifier table case-insensitive. All pages and resources become available without dependence on case. We modified method com.dotmarketing.business.IdentifierFactoryImpl.findByURI(String hostId, String uri). See the patch in attachment. This code is the same in the latest versions.
I have recreated in 3.0 locally.
Depending on the code fix, I will probably want it fixed in 2.5.7 too.
+1 this is biting support in a 2.5.6 impl right now
@dsilvam @brentgriffin @wezell gentlement, please check your mail. I sent you a hotfix with a potential fix for this issue we recently deployed in a client and works as expected.
Hey @joseorsini, I have a question about the change in method "protected List
merged into master-3.1
Working as expected. Pages are available without dependence on case. Tested on nightly build 3.1 (01/06) // H2 // Chrome