Categories
PHP Seguridad XSS

XSS o SQL Injection

Una pregunta hecha en un foro:

hola gente

normalmente mis sitios php incluyen en el index (el cual incluye las secciones) el siguiente codigo:

php:

foreach($_REQUEST as $nombre_campo => $valor){
   $asignacion = "$" . $nombre_campo . "='" . $valor . "';";
   eval($asignacion);
}

no hace mas que capturar todo el $_REQUEST y transformarlo en variables comunes.

intentando evitar ataques via XSS o SQL injection es el unico codigo que me resta por analizar, pero no logro llegar a la conclusion de si es o no peligroso o deberia escribir todas y cada una de las variables.

ustedes que opinan?

Categories
PHP Quiz Seguridad

Implicancias de la codificación del documento

En esta edición del quiz, un poco sobre la influencia que tiene la codificación de una página que se envía al cliente.

php:

<?php

$charset = 'utf-8';

/* Comprobación simple del charset: no debe contener caracteres raros  */
if ( !empty($_GET['charset']) && preg_match('/^[a-z\d-]+$/i', $_GET['charset']) )
        $charset = $_GET['charset'];
       
header('Content-type:text/html; charset=' . $charset);

?>
<html>

<head>
        <title>Test</title>     
</head>

<body>

<?php

if ( !empty($_GET['url']) )
        echo sprintf('<a href="%s">Enlace</a>', htmlentities($_GET['url']));

?>

</body>

</html>

¿Qué problema o problemas existen en el código mostrado?

Solución

Una alternativa de solución, es la que comenta Francesc, sin embargo la funcion htmlentities no acepta todos los encodings, lo que podría conllevar a que el código mostrado sea vulnerable a ataques XSS, para evitar esto, lo mejor es evitar que el usuario establezca el encoding del documento.

Categories
Varios

Microsoft Firefox 2007 professional edition

Algunas características de este navegador 😛 :

  • RSS (Real Simple Sex): RSS is a relatively new algorithmic technology fueled by the continued hot desires of many online web users. Accessed by an illuminating an icon on the toolbar - a single click allows you to view and optionally download anything that resembles a tit, a boob or a breast - rendered directly in the browser with speeds up to 10 times faster than the competition. Real Simple Sex can scan and arrange explicit images/pictures in order of quality and effectively filters out irrelevant content such as balloons or soccer balls.
  • 3rd Party Opt-in:
    Disables nearly all pre-installed non-Microsoft software to prevent potentially vulnerable controls from being exposed to attack. You can easily enable or disable required programs as needed through the Add-on Manager by using any valid credit card.
  • Security Status Bar:
    Enhances awareness of website security and privacy settings by displaying color-coded notifications next to the address bar. Microsoft Firefox changes the Address Bar to green for websites bearing the Microsoft Partnership Certificate, indicating the site owner has completed extensive identity and friendship verification checks. Googling Filter notifications, certificate names, and the gold padlock icon are now also adjacent to the address bar for better visibility.
  • Googling Filter: Proactively warns and helps protect you against potential or known fraudulent sites such as Google.com, blocks the site and shuts down your computer if necessary. The filter is updated several times per hour using the latest security information from Microsoft.
  • ...

Fuente: http://juanpe.lugcix.org/?p=52

Categories
Varios

Cheat sheet para PostgreSQL

PostreSQL Cheat Sheet

Fuente: http://www.alberton.info/postgresql_cheat_sheet.html

Categories
PHP Seguridad

Mensajes de error

Hace instantes, visitando un sitio con artículos sobre programación, me econtré con un curioso error al intentar acceder a un elemento inexistente (id=25).

code:

No exite la página 1 de resutados. Hay solo un total de 0

Al cambiar el valor esperado por 25', me muestra lo siguiente 😀 :

Ocurrió un error al ejecutar el query "SELECT COUNT(*) FROM articulos, creditos, temas, stats WHERE (articulos.fecha <= now() AND temas.id_cat = articulos.id_cat and creditos.id_autor = articulos.id_credito and articulos.clave = stats.id_nota) AND (articulos.id_cat <> 33 AND articulos.id_cat <> 34) AND articulos.id_credito = 25\' ORDER BY articulos.fecha DESC". La base dijo : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\' ORDER BY articulos.fecha DESC' at line 1.

Sin duda, es un gran descuido de la persona que hizo esto, porque muestra incluso la consulta SQL generada 😛 .

Obviamente no pondré la dirección de la página afectada, mientras no hayan corregido ese pequeño error.