|
| 1 | + |
| 2 | +\section{Race condition} |
| 3 | + |
| 4 | +Questo attacco può essere molto pericoloso in alcune situazioni, come nel caso |
| 5 | +per esempio di computazioni eseguite su architettura \textit{CUDA}, in cui era |
| 6 | +possibile estrarre informazioni sensibili durante la computazione. In ambiente |
| 7 | +\textit{cloud} è importante assicurarsi che ci sia un \textit{hypervisor} che |
| 8 | +coordina tutte le computazioni. |
| 9 | + |
| 10 | +Una situazione del genere può accadere in società di esplorazione geologica (eni |
| 11 | +ad esempio) o in situazioni di sequenziazione genomica/proteica. |
| 12 | + |
| 13 | +\section{Messaggi d'errore troppo verbosi} |
| 14 | + |
| 15 | +A volte i messaggi di errore sono troppi verbosi, e possono far inferire delle |
| 16 | +informazioni. Un messaggio di errore troppo verboso è solitamente il form di |
| 17 | +login: in alcuni servizi sono presenti messaggi come ``password scorretta'', che |
| 18 | +permette all'attaccante di sapere che esiste un login con quell'indirizzo |
| 19 | +e-mail. |
| 20 | + |
| 21 | +\section{External Control of Path} |
| 22 | +Normalmente quando si ha un sito web bisogna settare i diritti. Se dall'esterno |
| 23 | +si può lanciare un file (per esempio un file word) si da una backdoor ad un |
| 24 | +potenziale attaccante.\todo{Sistema} |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +\section{Uso di software non fidato} |
| 29 | + |
| 30 | +Il software a volte installato dall'utente non è fidato, che può essere uno |
| 31 | +\textit{spyware} che si occupa di raccogliere informazioni a scopo pubblicitario |
| 32 | +o di profilazione. |
| 33 | + |
| 34 | +Il software free è sicuro? Sì, ma solo se è \textit{open-source} e ha un po' di |
| 35 | +``anzianità'' (viene utilizzato da un po' di tempo). |
| 36 | + |
| 37 | +\section{Problemi classici di sicurezza} |
| 38 | + |
| 39 | +Per esempio il codice: |
| 40 | +\begin{verbatim} |
| 41 | +Security() { |
| 42 | + String contents, environment; |
| 43 | + String spath = "security.dat" |
| 44 | + File security = new File(); |
| 45 | + if (security.open(spath) > 0) { |
| 46 | + contents = security.read(); |
| 47 | + environment = security.read(); |
| 48 | + } else |
| 49 | + print("Error: Security.dat not found"); |
| 50 | +} |
| 51 | +\end{verbatim} |
| 52 | + |
| 53 | +Questa porzione di codice contiene diversi errori: |
| 54 | +\begin{itemize} |
| 55 | +\item Errori troppo verbosi |
| 56 | +\item Il file viene salvato in chiaro |
| 57 | +\item Non viene chiuso il file dopo la lettura |
| 58 | +\item Non viene controllata la lunghezza della lettura del file |
| 59 | +\end{itemize} |
| 60 | + |
| 61 | +Un altro errore è: |
| 62 | +\begin{verbatim} |
| 63 | +purchaseProduct() { |
| 64 | + password =" |
| 65 | +} |
| 66 | +\end{verbatim} |
| 67 | +Un problema è la password \emph{hard-coded} del codice. |
| 68 | + |
| 69 | +Ci sono errori gravi in questo pezzo di codice: |
| 70 | +\begin{itemize} |
| 71 | +\item Le password vengono salvate sul codice (detto anche \textit{hardcoded}) |
| 72 | +\item Ci potrebbe essere un \textit{overflow}, che a volte potrebbe accadere uno |
| 73 | +\textit{swift-to-left} % correggete la mia scrittura REEEEEE |
| 74 | +\item Viene usata una routine locale per eseguire la criptazione dei dati, |
| 75 | +mentre si dovrebbe sempre utilizzare algoritmi standard |
| 76 | +\end{itemize} |
| 77 | + |
| 78 | + |
| 79 | +\paragraph*{Come evitare gli errori} Un modo per evitare questi errori è |
| 80 | +adeguatamente testare il software che viene scritto. Purtroppo non è possibile |
| 81 | +testare il programma con tutti gli input possibili, ed è quindi necessario |
| 82 | +controllare adeguatamente il software con una \textit{test-suite} adeguata. |
| 83 | +Anche il \textit{model-checking} è importante per analizzare il software. % |
| 84 | +controlla mirko perchè sto guardando un video su youtube contemporaneamente |
| 85 | + |
| 86 | + |
| 87 | +% ESERCIZIIIIIII |
| 88 | + |
| 89 | +Definition Matching: |
| 90 | + |
| 91 | +\begin{itemize} |
| 92 | +\item Whitelist |
| 93 | +\item Blacklist |
| 94 | +\item Nonce |
| 95 | +\item Jail |
| 96 | +\item Sandbox Environment |
| 97 | +\end{itemize} |
| 98 | + |
| 99 | +con: |
| 100 | + |
| 101 | +\begin{enumerate} |
| 102 | +\item a set of resource imposed on programs by the operating system kernel (e.g. |
| 103 | +disk quotas) |
| 104 | +\item Uses a time-sensitive mark to prevent packet replay (e.g. captcha) |
| 105 | +\item list of acceptable input |
| 106 | +\item a security mechanism for quarantining unstrusted running programs |
| 107 | +\item reject suspect input |
| 108 | +\end{enumerate} |
| 109 | + |
| 110 | +Soluzione: |
| 111 | +\begin{itemize} |
| 112 | +\item Whitelist: 3 |
| 113 | +\item Nonce: 2 |
| 114 | +\item Jail: 1 |
| 115 | +\item Sandbox: 4 |
| 116 | + |
| 117 | +\end{itemize} |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +% ALTRO ESERCIZIO |
| 122 | +A third part inserts attack data into another organization's html response. This |
| 123 | +is know as: |
| 124 | +\begin{itemize} |
| 125 | +\item cross-site scripting (soluzione corretta) |
| 126 | +\item blacklist |
| 127 | +\item race condition |
| 128 | +\item cleartext |
| 129 | +\end{itemize} |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +% Altro esercizio |
| 135 | + |
| 136 | +What technique would not be appropriate in avoiding % figa so mare |
| 137 | + |
| 138 | +\begin{itemize} |
| 139 | +\item Separate control information from data information |
| 140 | +\item Use library |
| 141 | +\item |
| 142 | +\item |
| 143 | +\end{itemize} |
| 144 | + |
| 145 | +% Altro esercizio |
| 146 | +Which of the following is the true concerning web servers? |
| 147 | +\begin{itemize} |
| 148 | +\item servers cannot retain web session state, and thus the client must do it |
| 149 | +\item the single best place to do input validatio and authentication is at the |
| 150 | +client-side |
| 151 | +\item using client as storage is safe if encryption and integrity checking are |
| 152 | +used (risposta esatta) |
| 153 | +\item The server can trust web input if it validates the data in the web form |
| 154 | +\end{itemize} |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | +% Altro esercizio |
| 159 | + |
| 160 | +\begin{itemize} |
| 161 | +\item Nonce |
| 162 | +\item Whitelist (risposta esatta) |
| 163 | +\item Blacklist |
| 164 | +\item Integrity Checking |
| 165 | +\item |
| 166 | +\end{itemize} |
| 167 | + |
| 168 | +%Altro esercizio |
| 169 | + |
| 170 | +Easter egg by Fede ;) |
| 171 | + |
| 172 | +The best implementation of access control would be: |
| 173 | +\begin{itemize} |
| 174 | +\item do not provide chaches for sensitive data |
| 175 | +\item always use minimal possible permission in code, for as short of a time as |
| 176 | +possible (risposta esatta) |
| 177 | +\item avoid using cookies and hidden filds |
| 178 | +\item never provide an authorization above guest to web users |
| 179 | +\end{itemize} |
| 180 | + |
| 181 | +% Altro esercizio |
| 182 | +SQL injection is the best protected against by using |
| 183 | +\begin{itemize} |
| 184 | +\item Cleartext |
| 185 | +\item Encrtption and Integrity Checking |
| 186 | +\item Sanitization (risposta esatta) |
| 187 | +\item ClClefly uch as UTF-8defined code suche as UTF-8 |
| 188 | +\end{itemize} |
| 189 | + |
| 190 | +% Altro esercizio |
| 191 | +The main way to avoid replay between a client and server is: |
| 192 | +\begin{itemize} |
| 193 | +\item Integrity checking |
| 194 | +\item whitelist Whitelist |
| 195 | +\item blacklist Blacklist |
| 196 | +\item Nonce (risposta esatta) |
| 197 | +\end{itemize} |
| 198 | + |
| 199 | + |
| 200 | +% Altro esercizio |
| 201 | +An attack that could cause the most problems includes |
| 202 | +\begin{itemize} |
| 203 | +\item hard-coded password (risposta esatta) |
| 204 | +\item race condition |
| 205 | +\item denial of service |
| 206 | +\item chatty error message |
| 207 | +\end{itemize} |
| 208 | + |
| 209 | +% Altro esercizio |
| 210 | +The best way to ensure no message modification occurs is |
| 211 | +\begin{itemize} |
| 212 | +\item Hashing (risposta esatta) |
| 213 | +\item Whitelist |
| 214 | +\item Blacklist |
| 215 | +\item Encryption |
| 216 | +\end{itemize} |
| 217 | + |
| 218 | +% Altro esercizio |
| 219 | + |
| 220 | +All of the following except which answer can result in invalid data and |
| 221 | +break-in? |
| 222 | +\begin{itemize} |
| 223 | +\item Non-random random number generator |
| 224 | +\item Buffer overflow |
| 225 | +\item Uninitialized variables resulting in error messages |
| 226 | +\item Race conditions (risposta esatta) |
| 227 | +\end{itemize} |
| 228 | + |
| 229 | +% ALLELUIA |
| 230 | + |
| 231 | +\part{Controlli di sicurezza} |
| 232 | + |
| 233 | +Questo modulo si concentra sui controlli di sicurezza del software. Per fare ciò |
| 234 | +dovremo vedere il ciclo di vita del software, con un occhio però alla sicurezza. |
| 235 | +Partiremo dall'analisi dei requisiti, per andare all'analisi del rischio e per |
| 236 | +finire con lo sviluppo del software. |
| 237 | +Anche l'ambiente produttivo richiede attenzione, è importante il mantenimento da |
| 238 | +parte di vista della sicurezza per non introdurre bug nel software. |
| 239 | + |
| 240 | +\chapter{Validazione degli input} |
| 241 | + |
| 242 | +\section{Validazione delle transazioni} |
| 243 | + |
| 244 | +Alcuni punti importanti riguardo la validazioni delle transazioni sono: |
| 245 | +\begin{itemize} |
| 246 | +\item Sequence Check: |
| 247 | +\item Limit o Range Check: |
| 248 | +\item Validity Check or Table Lookup: |
| 249 | +\item Reasonableness Check: |
| 250 | +Per esempio oggi come oggi il numero di pizze in america hanno poche grandi |
| 251 | +catene, e questo perchè? Perchè il sistema è diventato tutto informatizzato, ed |
| 252 | +è per questo che PizzaHat ha il monopolio in america, grazie alla sua |
| 253 | +applicazione. È per questo che il controllo sull'input è molto importante, |
| 254 | +perchè un possibile attacco di Denial Of Service sarebbe ordinare un numero |
| 255 | +incontrollato di pizze. |
| 256 | +\item Existence Check: |
| 257 | +\item Key verification: fare inserire due volte la mail (per esempio) |
| 258 | +\item Check digit: |
| 259 | +\item Completeness Check |
| 260 | +\item Duplicate Check: è importante che il sistemi controlli un possibile doppio |
| 261 | +acquisto da parte di un utente, che potrebbe eseguire un acquisto per errore. |
| 262 | +Anche questa tipologia di controlli dovrebbero essere eseguiti. |
| 263 | +\item Consistency or Logical Relationship Check: son difficili da eseguire in |
| 264 | +maniera automatizzata, e i controlli logici permettono di controllare per |
| 265 | +esempio se gli utenti stanno mentendo o meno. |
| 266 | +\end{itemize} |
0 commit comments