Page 1 of 3 123 LastLast
Results 1 to 15 of 43

Thread: Close .tpl access with .htaccess

  1. #1

    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>

  2. #2
    Join Date
    Apr 2008
    Location
    Bristol, UK
    Posts
    848

    Default

    That's very useful. Thanks.

  3. #3
    Join Date
    Sep 2007
    Location
    Jimboomba, Qld. AU
    Posts
    2,293

  4. #4

    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.

  5. #5
    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>

  6. #6
    Join Date
    Aug 2007
    Location
    UK
    Posts
    897

    Default

    Anyone got the equivalent for doing this in IIS?
    Cheers, Phil
    Open Mind Hosting | w: openmindhosting.co.uk
    Servers | VPS

  7. #7

    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.

  8. #8
    Join Date
    Aug 2007
    Location
    UK
    Posts
    897

    Default

    Yes you are quite right, I had a brain fart and completely forgot this...
    Cheers, Phil
    Open Mind Hosting | w: openmindhosting.co.uk
    Servers | VPS

  9. #9
    Join Date
    Feb 2008
    Posts
    903

    Default

    about about 7, is there any new stuff that helps even more?

  10. #10

    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.

  11. #11
    Join Date
    Dec 2005
    Location
    Henderson, KY
    Posts
    778

    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.
    “An elective despotism was not the government we fought for. ” ~Thomas Jefferson
    ver 5.2.4
    WHMCS since 2005

  12. #12

    Default

    Will this htacess setting prevent access on the tpl files on a https?

  13. #13

    Default

    Yes it does. I think it would be a more complicated rule to make it only apply to http vs https.

  14. #14

    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.

  15. #15

    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.

Page 1 of 3 123 LastLast

Similar Threads

  1. Client Field access in ViewTicket.tpl
    By othellotech in forum Feature Requests
    Replies: 0
    Last Post: 09-20-12, 02:51 AM
  2. Access to support ticket departments on homepage.tpl
    By Nullified in forum Customisation & Integration Questions
    Replies: 2
    Last Post: 08-16-12, 12:06 AM
  3. tpl file variable access
    By sLIVER in forum Customisation & Integration Questions
    Replies: 1
    Last Post: 12-12-07, 08:47 PM