Support

Admin Tools

#30377 Correct permissions and exceptions

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by elementotango on Thursday, 18 October 2018 04:23 CDT

elementotango
Hello,

I would like to make sure I have done things right and specifically I don't create any security hole to my own J! installation.

Situation:

I have a php script that updates the .htaccess file of my installation.
This php script is in a folder in the root.

The folder permission is 755 and the php file permission is 644. Also the .htaccess file is 644.

Initially, I could not execute the php for example directly in the browser, like

mywebsite.com/scriptfolder/script.php because I was getting a 403 forbidden by AdminTools.

So I added the /scriptfolder/script.php into the AdminTool's .htaccess editor, under "EXCEPIONS - Allow direct access to this files".

Now I can run the script (no more 403 error) but is it the correct procedure ? Maybe I'm allowing now malicious people to modify the file and inject modifications into my .htaccess ?

What would be the correct way to proceed, to execute such file with maintaining the right level of security ?

Many thanks.

Regards Andrea.

https://www.elementotango.it

nicholas
Akeeba Staff
Manager
From a technical point of view, this is the only way to access this one particular .php file over a browser. It does not affect the security of anything else. It only allows access to that file.

However, if you ask me for a security advice I am a bit weary of what I read in your ticket.

I need to know more about what that script does. If it accepts unauthenticated, unvalidated input and dumps it into your .htaccess you have a massive security hole. Basing your security on an attacker not guessing a filename is very much like hoping that thieves won't enter your unlocked back door because they can't see it from the street.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

elementotango
Hi nicholas, thank-you for your fast reply.

The script basically is used to update the .htaccess file with a list of blacklisted IP addresses to block from accessing the website.
It is a free PHP file distributed by https://myip.ms/browse/blacklist/ and its original contents is attached.

What do you think ?

Thank-you!
Regards Andrea

https://www.elementotango.it

elementotango
Let me try to reattach the file.. It's a zip file - do you see it as I don't.

https://www.elementotango.it

nicholas
Akeeba Staff
Manager
I actually downloaded the file from the link you posted. We have disabled upload of ZIP files with executable code on our server.

You do not need to access this file over the web. You can trigger it periodically using CRON on your server. Since CRON runs from a command line context you do not need to make an exception in your .htaccess since that is only used for web access.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

elementotango
Hi,

I thought the same, but I see that in the control panel of my hosting, under "cron", I can't really specifiy a "real" cron command, like /etc/.... but the field says "URL to execute". Seems like they are providing a limited version of the cron, which expects to have an URL to execute.

That's why I thought I needed to put it into the exceptions..

If we assume, I do need to execute it as a "URL" and not as a real cron command, what is your opinion on the file safety ? Now that you have seen it, do you think it is safe ?

Thanks!

Regards AG

https://www.elementotango.it

nicholas
Akeeba Staff
Manager
"Safe" is a relative term. On the face of it, what it does is not outright dangerous. However I have some concerns.

When the blacklist is being fetched there is no SSL certificate validity check. This could allow a man in the middle attack. I'm personally not comfortable with that but I do understand that the chances for that happening are very slim (it'd require a targetted attack by an advanced adversary).

The code to replace stuff in the .htaccess is a bit optimistic. If your .htaccess doesn't follow the format it expects it will start overwriting stuff like there's no tomorrow. I practice defensive coding so I cringed a lot when I saw this script.

Finally, this script reads stuff from a remote URL and replaces stuff in your .htaccess file. Even assuming that it reads safe data and the replacement works great it does consume a bit of resources and does make blocking I/O operations on a file required to load any page or static resource of your site. If an adversary figures out the URL to that file they can call it hundreds of times, bringing your site down (DoS). The irony is that by doing that they are also overwriting the .htaccess so even if they only use a single IP address to attack you you can't easily block them (by blacklisting their IP in the .htaccess, since it's overwritten!). You'd have to delete the script and then block the attacker in the .htaccess.

On top of that, I also understand how these attacks work, how IPs can be spoofed or recycled, therefore why blacklisting IPs is useless except as something you should do temporarily when you are detecting active attacks against your site.

So, would I install that script? No. I can see no real benefit and a few potential problems.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

elementotango
Hi Nicholas,

thank-you very much for the time and efforts that you have put into the answer for me. It's clear you have dedicated time and energy to that.

Regarding the script and the matter itself, thanks a lot for sharing your thoughts. Looks like I need to reflect a bit on that, and make a decision taking into account all of these aspects.

Again many thanks, appreciated!

Regards Andrea.

https://www.elementotango.it

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!