Joomla.it Forum

Non solo Joomla... => Sicurezza => : nomeutente 29 Dec 2009, 18:11:27

: Possibile problema di sicurezza in .htaccess modificato
: nomeutente 29 Dec 2009, 18:11:27
Per aumentare la sicurezza dei siti che gestisco, oltre al creare un nuovo superamministratore e al modificare il prefisso delle tabelle ho seguito le istruzioni presenti ad es. qui http://www.joomlapeople.com/6-Moving-the-location-of-admin-login.html (http://www.joomlapeople.com/6-Moving-the-location-of-admin-login.html)(ma poi copiate un po' dappertutto) per rendere la cartella administrator non accessibile direttamente, non volendo però proteggerla con password dal pannello di controllo.
La procedura è abbastanza semplice: si crea un altro file che imposta un cookie e redirige ad administrator; da .htaccess l'accesso ad administrator è permesso solo se esiste già il cookie.
Ho dovuto però pasticciare un po' nel file .htaccess perché, se inserivo il codice alla fine, la cartella /administrator continuava ad essere accessibile.
Spostando il codice sopra alla sezione sui SEF tutto funziona, evidentemente era un problema legato alla sintassi di ReWriteCond e ReWriteRule (che non conosco...)
Il mio dubbio però ora è di aver aperto qualche altro "buco", sempre per motivi di sintassi e conflitti con le altre regole presenti.
Mi sembrerebbe di no... ma non ne sono sicuro.
Qualche anima buona potrebbe verificare il codice e rassicurarmi? o eventualmente migliorarlo? Grazie!
Il file htaccess è quello standard 1.15, la parte aggiunta è la penultima sezione verso la fine, compresa fra commenti ACCESSO ADMINISTRATOR

:
##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
#  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On


########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

# RewriteBase /


########## Begin - ACCESSO ADMINISTRATOR
#
RewriteCond %{REQUEST_URI} ^/administrator
RewriteCond %{HTTP_COOKIE} !JoomlaAdminSession=111222333
RewriteRule .* - [L,F]
#
########## End - ACCESSO ADMINISTRATOR


########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
: Re:Possibile problema di sicurezza in .htaccess modificato
: 56francesco 30 Dec 2009, 21:17:55
benvenuto nel forum di joomla.it

se continua questa "sfida" sulla sicurezza la vedo brutta...

quei giocherelloni adorano predersela con chi li previene..

e comunque non mi pare una bella pensata rendere pubblico  il tuo htaccess
: Re:Possibile problema di sicurezza in .htaccess modificato
: mmleoni 30 Dec 2009, 22:03:52
in effetti si tratta di una soluzione già nota, come del resto dice anche nomeutente (che fantasia :( ), è sufficiente che il cookie sia MOLTO meno prevedibile.

sembra anche a me tutto a posto, e dove lo hai posto non mi pare che possa dare adito ad alcun problema.

ciao, marco
: Re:Possibile problema di sicurezza in .htaccess modificato
: nomeutente 02 Jan 2010, 13:47:20
grazie per la risposta.
nota:
l'.htaccess che ho reso pubblico è, come scrivevo, quello standard e il cookie vero ovviamente non è quello che ho riportato... e cambio per ogni sito. Poco esperto sì, ma non così sprovveduto!  :D

ho postato perché può essee un altro piccolo tassello da aggiungere per la sicurezza, in attesa della posssibilità di scegliere la cartella di amministrazione durenti l'installazione.

ri-grazie
 
: Re:Possibile problema di sicurezza in .htaccess modificato
: websitter 04 Jan 2010, 09:08:13
Perchè non provare questo: http://extensions.joomla.org/extensions/access-a-security/site-security/5809




Drawback:

Joomla has one drawback, any web user can easily know the site is created in Joomla! by typing the URL to access the administration area (i.e. www.site name.com/administration). This makes hackers hack the site easily once they crack id and password for Joomla!.

Information:

jSecure Authentication module prevents access to administration (back end) login page without appropriate access key.cut

: Re:Possibile problema di sicurezza in .htaccess modificato
: 56francesco 04 Jan 2010, 09:14:52
per cortesia, per la sicurezza  ;) del database del forum, evitiamo di postare km di codice o di altre pagine,
nel gergo della netiquette si chiama quoting,  ovvero le citazioni devono essere limitate alle parti interessate dal topic e non al 100% a tavoletta...

grazieeeee
: Re:Possibile problema di sicurezza in .htaccess modificato
: mmleoni 04 Jan 2010, 09:38:11
Joomla has one drawback, any web user can easily know the site is created in Joomla! by typing the URL to access the administration area (i.e. www.site name.com/administration)...
non so se questo componente faccia altro, andrò a vederlo, ma a parte qualche script kid alquanto imbranato un hacker impiega 15 secondi a capire che si trova di fronte ad un sito Joomla! ... e senza bisogno di vedere ove risieda l'interfaccia di amministrazione :(

mio pensiero:
security through obscurity it's NOT security

oltre a ciò la sicurezza dipenderebbe ancora da php ed introduci altro codice che può essere oggetto di hack od errori: meglio allora un approccio basato sull'autenticazione apache come quello proposto.

ciao,
marco