1 / 32

Biztonsági szempontból veszélyes programozói hibák

Biztonsági szempontból veszélyes programozói hibák. ITEM pályázata támogatásával BME Informatikai Központ Idealab project. Árendás Csaba, M.Sc. Miről is lesz szó?. A biztonság jelenlegi helyzete az Interneten Támadási lehetőségek, fenyegettségek

alima
Télécharger la présentation

Biztonsági szempontból veszélyes programozói hibák

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Biztonsági szempontból veszélyes programozói hibák ITEM pályázata támogatásávalBME Informatikai Központ Idealab project Árendás Csaba, M.Sc.

  2. Miről is lesz szó? • A biztonság jelenlegi helyzete az Interneten • Támadási lehetőségek, fenyegettségek • Biztonsági szempontból veszélyes programozói hibák • Egyes biztonsági hibák ismertetése • Demo • Védekezési lehetőségek osztályozása • Konklúzió

  3. A biztonság jelenlegi helyzete az Interneten

  4. Támadási eszköztár • Lehallgatás • Titkosítás megfejtése • Protokoll tervezési hiba kihasználása • Véletlenszám-generátor megtörése • Jelszótörés • Social engineering • Speciális programozói hibák, lyukak kihasználása (hacker-ek legpreferáltabb játéka) • Stb.

  5. Biztonsági szempontból veszélyes programozói hibák • Veremtúlcsordulás (stack overflow) • Halom túlcsordulás (heap overflow) • Méretbeli egész túlcsordulás (widthness integer overflow) • Aritmetikai túlcsordulás (arithmetical overflow) • Előjeles hiba (signedness bug) • Formázó karakter sebezhetőség (Format string vulnerability) • Tömbindexelési hiba (array indexing error) • Karakterméret hiba (unicode bug)

  6. Program memóriatérképe

  7. Buffer overflow - Public Enemy #1 void hibas_fuggveny(char* input) { a=1; b=2; c=3; char buffer[12]; strcpy(buffer,input); printf("%s",buffer); }

  8. Buffer overflow hiba kihasználása

  9. A hiba kihasználása… "\x31\xc0\x31\xdb\x31\xd2\x53\x68\x20\x44\x53\x52" "\x68\x66\x72\x6f\x6d\x68\x62\x6f\x62\x20\x89\xe1" "\xb2\x0f\xb0\x04\xcd\x80\x31\xc0\xb0\x01\xcd\x80" A jobbik eset: „Itt járt Bob!!!” Rosszabb: rm –R /*

  10. Milyen módon használhat ki a támadó ilyen jellegű hibát? • Exploit írása (támadó program) • Vírus írása

  11. 2003. január 5. (szombat) 05:29:00 MS-SQL worm-mel fertőzött gépek száma: 0 2003. január 5. (szombat) 06:00:00 MS-SQL worm-mel fertőzött gépek száma: 200 000 A végeredmény…

  12. Egy támadás tipikus lépései • Könnyű célpont keresése • Célpont feltérképezése • Behatolás • Nyomok eltüntetése, álcázás (root-kit telepítése) • Innentől szabad a pálya… • Több feltört gép, több lehetőség…

  13. Méretbeli túlcsordulás intmain(int argc, char *argv[]){ int i = atoi(argv[1]); unsignedshort s = i; char buf[80]; if(s >= 80) { return -1; } printf("s = %d\n", s); memcpy(buf, argv[2], i); buf[i] = '\0'; printf("%s\n", buf); return 0; }

  14. Méretbeli túlcsordulás • Widthness integer overflow occurs if astored integer value is copied to a smaller value. In this case truncation is necessary which could lead to data loss. If a length condition checking is based on the new value, but the data copying function uses the original value, under special circumstances (if the original data is big enough) an overflow could be caused.

  15. Méretbeli túlcsordulás

  16. Aritmetikai túlcsordulás int catvars(char *buf1, char *buf2, unsignedint len1, unsignedint len2){ char mybuf[256]; if((len1 + len2) > 256) { return -1; } memcpy(mybuf, buf1, len1); memcpy(mybuf + len1, buf2, len2); do_some_stuff(mybuf); return 0; }

  17. Aritmetikai túlcsordulás • In this case the problem originates in the overflow of an arithmetic operation, where without the extra bits of the overflow valid, but erroneous results will be taken into consideration. Similar problems could arise also from multiplication, not just addition.

  18. Aritmetikai túlcsordulás

  19. Előjeles hiba int copy_something(char *buf, int len) { char kbuf[800]; if(len > sizeof(kbuf)) { return -1; } returnmemcpy(kbuf, buf, len); }

  20. Előjeles hiba • Signedness bug is almost the same as the pervious bug, although in this case the difference between signed and unsigned integer values is also important, where signed integers are stored in two’s complement. The source of the problem is that we can interpret a signed number as an unsigned one as well, which means a huge number, since in two’s complement negative numbers start with bit ‘1’.

  21. Előjeles hiba

  22. Konklúzió, védekezési lehetőségek • A legveszélyesebb hibacsalád • Tudni kell róla, gondolni kell rá • Védekezni lehet és kell ellene!!! • Számos védelmi megoldás elérhető

  23. Védekezési lehetőségek

  24. Veszélyes függvények • Strcpy(char *dest, const char *str) • Strcat(char *dest, const char *src) • Getwd(char *buf) • Gets(char *s) • Scanf(const char *format,…) • Realpath(char *path,char resolved_path[]) • Sprintf(char *str, const char *format,…)

  25. Program memóriatérképe

  26. Kernel stack randomization

  27. Strcpy implementációja Char *strcpy(char * dest,const char *src) { char *tmp=dest; while ((*dest++=*src++)!=’0’) /*nothing*/ return tmp; }

  28. Safelib javított változat • Char *strcpy(char *dest,const char *src) • { • ... • if ((len=strlen(src,max_size))==max_size) • _libsafe_die(„Overflow caused by strcpy()”); • real_memcpy(dest,src,len+1); • return dest; • }

  29. Forráskód elemző: Flowfinder • test.c:49: [4] (buffer) _mbscpy: Does not check for buffer overflows when copying to destination. Consider using a function version that stops copying at the end of the buffer. • _mbscpy(d,s); /* like strcpy, this doesn't check for buffer overflow */ • test.c:52: [4] (buffer) lstrcat: Does not check for buffer overflows when concatenating to destination. • lstrcat(d,s); • test.c:45: [2] (buffer) char: Statically-sized arrays can be overflowed. Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. • char d[20];

  30. Problémák a biztonsági hibákkal • Nincs törvényi kényszerítő erő az eliminálásukra • Hatalmas komplexitás, biztos komponensek nélkül (ellentétben például az építészettel) • A nagy szoftverfejlesztő cégek nem érdekeltek a biztonságos termékek elkészítésében • Paradoxonos helyzet az egy termék, millió hacker felállással, eleve hátrányos helyzet • A szoftverfejlesztés célja általában a specifikáció szerinti funkcionális működés elérése, minden más másodlagos

  31. Mi jöhet (jön) még • Biztonsági hibák voltak, vannak és lesznek • Bármely területen megjelenhet a rossz célú kihasználásuk, ha az eladott eszközök száma eléri a kritikus tömeget • A jelenlegi megelőzési tendencia nem túl dicséretes, de valamivel jobb, mint korábban • A jelenlegi eszközök célzott, átgondolt alkalmazásával, a hibák nagy része nem kerülhetne kihasználásra • Elrettentés: mobil vírusok (lásd Japán, precedens jelleggel) • Katonai alkalmazás

  32. Köszönöm a figyelmet!

More Related