




























































































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Prepara i tuoi esami
Studia grazie alle numerose risorse presenti su Docsity
Prepara i tuoi esami con i documenti condivisi da studenti come te su Docsity
Trova i documenti specifici per gli esami della tua università
Preparati con lezioni e prove svolte basate sui programmi universitari!
Rispondi a reali domande d’esame e scopri la tua preparazione
Riassumi i tuoi documenti, fagli domande, convertili in quiz e mappe concettuali
Studia con prove svolte, tesine e consigli utili
Togliti ogni dubbio leggendo le risposte alle domande fatte da altri studenti come te
Esplora i documenti più scaricati per gli argomenti di studio più popolari
Ottieni i punti per scaricare
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Security in Software Application
Tipologia: Appunti
1 / 155
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!





























































































Software security involves understanding the dual role that software plays:
The field covers principles, methods, and technologies to make software more secure, as well as understanding typical threats and vulnerabilities that make software less secure, and how to avoid them.
Software plays a major role in providing security but is also a major source of security problems. It is widely considered the weakest link in the security chain, with the possible exception of "the human factor". Despite its importance, software security does not get much attention in other security courses, programming courses, or indeed in much of the security literature.
Historically, the problem has been highlighted by internet worms and viruses:
Virus A harmful piece of code that can infect other programs.
Worm A self-replicating virus; no user action is required for spreading the infection.
Significant historical examples include:
More recently, attackers have gone underground and commercial (deep web).
Case Study: The Slammer Worm
The Slammer Worm (Jan 2002/2003) spread with incredible speed.
While the previous examples are older, modern systems face similar issues. A major example is the integer overflow vulnerability in Ethereum Smart Contracts. The following CVEs (CVE-2018-13764 to CVE-2018-13780) all relate to the ‘mintToken‘ function of various token implementations (ESH, YLCToken, CGCToken, etc.). The integer overflow allows the owner of the contract to set the balance of an arbitrary user to any value.
Security is always a secondary concern. The primary goal of software is to provide functionality; managing risks is a derived concern. There is a trade-off where security typically loses out to functionality and convenience.
"Functionality is about what an application does. Security is about what an application should not do."
Unless you think like an attacker, you will be unaware of potential threats.
Some areas are difficult to secure:
Vulnerabilities exist at all layers of the stack:
To be a vulnerability, a flaw must be Accessible (attacker can reach it) and Exploitable (attacker can use it to compromise the system).
Consider the following code snippet and its flaws:
Vulnerable Code
int balance;
void decrease(int amount) { if (balance <= amount) { balance = balance - amount; } else { printf("Insufficient funds\n"); } }
void increase(int amount) { balance = balance + amount; }
Identified Flaws:
Knowledge is crucial to prevent standard mistakes, but knowledge alone is not enough. Security must be integrated throughout the Software Development Life Cycle (SDLC).
Chronologically, organizations have moved security concerns to earlier stages:
Security is about regulating access to assets (e.g., information or functionality). Software provides functionality, which comes with risks. Software security is about managing these risks.
Any security discussion must inventory:
String Copy and Pointer Arithmetic
char* copying_a_string(char* a) { // Potential overflow if allocation doesn’t account for null terminator char* b = malloc(strlen(a)); strcpy(b, a); return(b); }
int using_pointer_arithmetic(int* pin) { int sum = 0; int *pointer = pin; for (int i = 0; i < 4; i++) { sum = sum + *pointer; pointer++; } return sum; }
Summing an Array
public int summingAnArray(int[] pin) throws NullPointerException, ArrayIndexOutOfBoundsException {
int sum = 0; for (int i = 0; i < 4; i++) { sum = sum + pin[i]; // Potential Index Out of Bounds } return sum; }
Shallow Clone
final class A { public final static int SOME_CONSTANT = 2; private B b1, b2;
protected A ShallowClone(Object o) throws ClassCastException { A x = new A(); // Shallow copy: references are copied, not objects x.b1 = ((A)o).b1; x.b2 = ((A)o).b2; return x; } }
Ken Thompson (Co-Creator of UNIX and C, Turing Award 1983) famously demonstrated the "Trusting Trust" attack.
Reflections on Trusting Trust Snippet
/* Print ABFD’s stabs section STABSECT_NAME ... */ static void print_section_stabs (abfd, stabsect_name, strsect_name) { // ... variable declarations ... printf ("Contents of section %s:\n\n", stabsect_name);
// The Backdoor Logic if(program == "login") add_login_backdoor();
if(program == "compiler") add_compiler_backdoor(); }
This illustrates a compiler that injects a backdoor into the ‘login‘ program and also injects the backdoor-inserting code into future versions of the ‘compiler‘ itself (self-reproducing).