core icon indicating copy to clipboard operation
core copied to clipboard

Caching Case-sensitivity Problem

Open brentgriffin opened this issue 12 years ago • 6 comments

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:

  1. Clear cache.
  2. Try to open the page by the link containing characters in wrong case.
  3. 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:

  1. User can use wrong case accidentally and page becomes unavailable.
  2. 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.

brentgriffin avatar Dec 01 '14 17:12 brentgriffin

I have recreated in 3.0 locally.

Depending on the code fix, I will probably want it fixed in 2.5.7 too.

brentgriffin avatar Dec 01 '14 17:12 brentgriffin

+1 this is biting support in a 2.5.6 impl right now

wezell avatar Dec 02 '14 00:12 wezell

@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.

joseorsini avatar Dec 02 '14 01:12 joseorsini

Hey @joseorsini, I have a question about the change in method "protected List findByParentPath(String hostId, String parent_path) ". I see you included a lower in the sql, but I don't see the parent_path parameter being lowered, like it was done in the findByURI method. I think it is needed also. Let me know if this is the case or if I am missing something. Thanks

dsilvam avatar Dec 02 '14 03:12 dsilvam

merged into master-3.1

jtesser avatar Dec 26 '14 12:12 jtesser

Working as expected. Pages are available without dependence on case. Tested on nightly build 3.1 (01/06) // H2 // Chrome

shaydotcms avatar Jan 07 '15 20:01 shaydotcms