fix(security): sanear idioma de URL para cerrar XSS reflejado
El parametro ?idioma= llegaba crudo (la query string se reenvia entera a slug.php via .htaccess) y se reflejaba sin escapar en RUTA_RAIZ/ROOT, lang="..." y variables JS de las plantillas -> XSS reflejado explotable en cualquier web (p.ej. ?idioma=';alert(document.cookie);// en contexto JS). - variables.php: allowlist de idiomas antes de definir constantes/render; cualquier valor desconocido se descarta. - footer.tpl/header.tpl: json_encode en los sinks JS (defensa en profundidad).
This commit is contained in:
@@ -61,6 +61,14 @@
|
|||||||
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ru/") $_REQUEST["idioma"]="ru";
|
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ru/") $_REQUEST["idioma"]="ru";
|
||||||
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ni/") $_REQUEST["idioma"]="ni";
|
if (substr($_SERVER["REQUEST_URI"],0,4)=="/ni/") $_REQUEST["idioma"]="ni";
|
||||||
|
|
||||||
|
// Seguridad: el idioma puede llegar crudo por ?idioma= (la query string se
|
||||||
|
// reenvia entera a slug.php via .htaccess). Se refleja sin escapar en varias
|
||||||
|
// plantillas (RUTA_RAIZ/ROOT, lang="...", vars JS) -> XSS reflejado. Se valida
|
||||||
|
// contra un allowlist antes de definir constantes y renderizar: cualquier
|
||||||
|
// valor que no sea un idioma conocido se descarta.
|
||||||
|
$__idiomasValidos = array("en","es","de","fr","pt","se","cat","it","ko","ch","nu","ru","ni");
|
||||||
|
if (!in_array(@$_REQUEST["idioma"], $__idiomasValidos, true)) $_REQUEST["idioma"] = "";
|
||||||
|
|
||||||
if (@$_REQUEST["idioma"]) define("RUTA_RAIZ","/".$_REQUEST["idioma"]); else define("RUTA_RAIZ","");
|
if (@$_REQUEST["idioma"]) define("RUTA_RAIZ","/".$_REQUEST["idioma"]); else define("RUTA_RAIZ","");
|
||||||
|
|
||||||
if (@$_REQUEST["idioma"]) define("ROOT","/".$_REQUEST["idioma"]); else define("ROOT","");
|
if (@$_REQUEST["idioma"]) define("ROOT","/".$_REQUEST["idioma"]); else define("ROOT","");
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ if (!@$_REQUEST["viewAMP"]){
|
|||||||
Resource::link('/css/cesta.css', true);
|
Resource::link('/css/cesta.css', true);
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
var RUTA_RAIZ = '<?=RUTA_RAIZ;?>';
|
var RUTA_RAIZ = <?=json_encode(RUTA_RAIZ);?>;
|
||||||
var ENLACE_CESTA = '<?=t(@$apartadoCesta, "enlace");?>';
|
var ENLACE_CESTA = '<?=t(@$apartadoCesta, "enlace");?>';
|
||||||
var TEXTOS_CESTA = {
|
var TEXTOS_CESTA = {
|
||||||
productoAnadido: '<?=t_var("Producto añadido");?>',
|
productoAnadido: '<?=t_var("Producto añadido");?>',
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
var hooksToken = '<?=sha1(session_id().$_SERVER["HTTP_HOST"]);?>';
|
var hooksToken = '<?=sha1(session_id().$_SERVER["HTTP_HOST"]);?>';
|
||||||
var language = '<?=@$_REQUEST['idioma']?:'www'?>';
|
var language = <?=json_encode(@$_REQUEST['idioma']?:'www')?>;
|
||||||
{CMSAPI_JS}
|
{CMSAPI_JS}
|
||||||
</script>
|
</script>
|
||||||
<?
|
<?
|
||||||
|
|||||||
Reference in New Issue
Block a user