Tips, Tricks & Howto's Found a different way of using WHMCS or something that you think would help others? If so, post elsewhere and we'll move it here. (closed to new threads)

Reply
 
Thread Tools Display Modes
  #1  
Old 03-15-09, 03:15 PM
WebWorker WebWorker is offline
Senior Member
 
Join Date: Feb 2009
Posts: 118
Exclamation Close .tpl access with .htaccess

The index.php in the template directory only protects you if someone enters the root of a particular directory. However if they know the exact file name they are looking for, it is very possible that the contents of the file will be output into the browser. Particularly for Smarty .tpl files.

I only thought about this because I saw that someone had found my website using the phrase "Powered by WHMCS" coupled with the fact that it seems that many are using the Smarty {php} tag (not recommended by Smarty authors btw) which could include sensitive information.

Anyway the fix is simple, here is the quick way if you are using an apache server with .htaccess enabled.

Put this into your .htaccess file in the web root of your site.
Code:
<Files ~ "\.tpl$">
Order allow,deny
Deny from all
</Files>
Reply With Quote
  #2  
Old 03-15-09, 04:36 PM
redrat redrat is offline
Senior Member
 
Join Date: Apr 2008
Location: Bristol, UK
Posts: 838
Default

That's very useful. Thanks.
Reply With Quote
  #3  
Old 03-16-09, 01:56 PM
sparky sparky is offline
Senior Member
 
Join Date: Sep 2007
Location: Jimboomba, Qld. AU
Posts: 1,602
Default

If you search the forums you would have found that this has been already posted a few times
http://forum.whmcs.com/showthread.php?p=71423#post71423
http://forum.whmcs.com/showthread.php?p=81891#post81891
Reply With Quote
  #4  
Old 03-16-09, 05:04 PM
WebWorker WebWorker is offline
Senior Member
 
Join Date: Feb 2009
Posts: 118
Default

Considering I just googled someone's template files, I think it is worth mentioning. Glad there are other people who think this is an important fix.
Reply With Quote
  #5  
Old 03-23-09, 03:12 PM
inverter inverter is offline
Junior Member
 
Join Date: Mar 2009
Posts: 3
Default robots

You can also control this to a point in your robots.txt if the search engine bot uses robot rules.

robots.txt
-------------------------------
User-agent: *
Disallow: /*.tpl$
-------------------------------

without the --------- lines

Quote:
Originally Posted by WebWorker View Post
The index.php in the template directory only protects you if someone enters the root of a particular directory. However if they know the exact file name they are looking for, it is very possible that the contents of the file will be output into the browser. Particularly for Smarty .tpl files.

I only thought about this because I saw that someone had found my website using the phrase "Powered by WHMCS" coupled with the fact that it seems that many are using the Smarty {php} tag (not recommended by Smarty authors btw) which could include sensitive information.

Anyway the fix is simple, here is the quick way if you are using an apache server with .htaccess enabled.

Put this into your .htaccess file in the web root of your site.
Code:
<Files ~ "\.tpl$">
Order allow,deny
Deny from all
</Files>
Reply With Quote
  #6  
Old 03-25-09, 06:30 PM
openmind openmind is offline
Senior Member
 
Join Date: Aug 2007
Location: UK
Posts: 452
Default

Anyone got the equivalent for doing this in IIS?
__________________
Cheers, Phil

UK Based VPS and Dedicated Servers
Reply With Quote
  #7  
Old 03-25-09, 06:55 PM
WebWorker WebWorker is offline
Senior Member
 
Join Date: Feb 2009
Posts: 118
Default

I thought IIS 6.0 blocks unknown file extensions by default and you had to specify if you wanted to allow a file extension.

Check this by browsing to your template directory in your browser : http://yourdomain.com/whmcs/template...ult/banned.tpl and see if you can see the template contents.
Reply With Quote
  #8  
Old 03-25-09, 07:29 PM
openmind openmind is offline
Senior Member
 
Join Date: Aug 2007
Location: UK
Posts: 452
Default

Yes you are quite right, I had a brain fart and completely forgot this...
__________________
Cheers, Phil

UK Based VPS and Dedicated Servers
Reply With Quote
  #9  
Old 03-25-09, 08:28 PM
mylove4life mylove4life is offline
Senior Member
 
Join Date: Feb 2008
Posts: 499
Default

about about 7, is there any new stuff that helps even more?
Reply With Quote
  #10  
Old 03-25-09, 10:17 PM
WebWorker WebWorker is offline
Senior Member
 
Join Date: Feb 2009
Posts: 118
Default

It's not a matter of helping more or not. Simply perform the test that I illustrated a couple messages above and see if you can browse your way to one of your site's templates. If you can see the template code as text then you need to close this hole. If you cannot see the template code then you are as helped as possible.

Code:
http://yourdomain.com/whmcs/templates/default/banned.tpl

PS. The only IIS users that would be affected is 5 and below. In IIS 6 and higher they blocked access to most filetypes by default and you would only need to worry about this if something you changed on the IIS server allowed you to browse to the URL example I provided above.
Reply With Quote
  #11  
Old 03-26-09, 12:37 PM
Roger Roger is offline
Senior Member
 
Join Date: Dec 2005
Location: Henderson, KY
Posts: 589
Default

Quote:
Originally Posted by mylove4life View Post
about about 7, is there any new stuff that helps even more?
IIS7 is a totally different animal... even the admin interface guii. I've only seen it in some training with no hands on. So I can't be more specific.
__________________
Pray Harder ... Time is Short
WHMCS since 2005
ver 4.2.1
Reply With Quote
  #12  
Old 03-26-09, 10:19 PM
pure|ws pure|ws is offline
Junior Member
 
Join Date: Oct 2008
Posts: 6
Default

Will this htacess setting prevent access on the tpl files on a https?
__________________
pure|ws
http://www.purews.com
Reply With Quote
  #13  
Old 03-26-09, 10:24 PM
WebWorker WebWorker is offline
Senior Member
 
Join Date: Feb 2009
Posts: 118
Default

Yes it does. I think it would be a more complicated rule to make it only apply to http vs https.
Reply With Quote
  #14  
Old 03-26-09, 10:28 PM
WebWorker WebWorker is offline
Senior Member
 
Join Date: Feb 2009
Posts: 118
Default

Quote:
Originally Posted by inverter View Post
You can also control this to a point in your robots.txt if the search engine bot uses robot rules.
The rule in .htaccess will block access from browsers or bots. Not all search bots follow the rules you place in robots.txt either

Personally I'm somewhat hesitant to place rules in robot.txt for files that I am trying to obscure. Anyone can read this robots.txt file and gain insight into what you are trying to protect, although security via obscurity really is a bad policy to begin with.
Reply With Quote
  #15  
Old 03-27-09, 06:32 AM
pure|ws pure|ws is offline
Junior Member
 
Join Date: Oct 2008
Posts: 6
Default

Quote:
Originally Posted by WebWorker View Post
Yes it does. I think it would be a more complicated rule to make it only apply to http vs https.
It does not appear to be.
If I use http, it blocks it but if I am over my https, the contents of the .tpl files are being displayed.
__________________
pure|ws
http://www.purews.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:01 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.