Skip to content

Sicurezza Web: Introduzione

La sicurezza web è fondamentale per proteggere dati, utenti e applicazioni. Conoscere le vulnerabilità comuni è il primo passo per difendersi.

Vulnerabilità comuni (OWASP Top 10)

1. SQL Injection

php
// ❌ SBAGLIATO
$query = "SELECT * FROM users WHERE id = $_GET['id']";

// ✅ CORRETTO (prepared statements)
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = :id');
$stmt->execute(['id' => $id]);

2. XSS (Cross-Site Scripting)

javascript
// ❌ SBAGLIATO
element.innerHTML = userInput;

// ✅ CORRETTO
element.textContent = userInput;

3. CSRF (Cross-Site Request Forgery)

Utilizzare token CSRF per proteggere le form:

html
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['token']; ?>">

Best practice di sicurezza

  1. Validare sempre l'input - Non fidarsi mai dei dati utente
  2. Usare HTTPS - Crittografare le comunicazioni
  3. Aggiornare le dipendenze - Mantenere software e librerie aggiornate
  4. Password hashing - Usare password_hash() in PHP
  5. CORS configurato - Limitare le origini permesse

Strumenti utili

  • Burp Suite - Testing di sicurezza
  • OWASP ZAP - Scanner di vulnerabilità
  • Nmap - Network scanning
  • SQLMap - Testing SQL injection

Conclusione

La sicurezza non è un optional. Ogni sviluppatore deve conoscere le vulnerabilità comuni e implementare le difese appropriate.

Made with ❤️ by PeterDev
'Ho mio cuGGGino che lo sa fare' cit.