question
stringclasses
1 value
answer
stringlengths
443
1.77k
source
stringclasses
1 value
No question: Moodle
com - 402 : information security and privacy 0x01 cyber threats mathias payer ( infosec. exchange / @ gannimo ) learning goals learn basic properties of security and privacy get an overview of cyber threats break cyber attack lifecycle into different steps differentiate classes of cyber threats 2 basic principles 3 bas...
EPFL CS 402 Moodle
No question: Moodle
action / statement approach : add a signature as proof of origin 8 there ’ s a recording of the conversation basic privacy properties : confidentiality keep information of the data subject ( i. e. the person mentioned in the data ) secret ( e. g. age, opinions, health ) give ( limited ) access only to those who need to...
EPFL CS 402 Moodle
No question: Moodle
it is in a company ’ s interest to have good security protecting the privacy of its customers does not always have a benefit for a data owner : some make money by abusing privacy ( facebook? ) we need strong laws to force companies to protect user privacy ( e. g. gdpr ) privacy by design : choose a design that achieves...
EPFL CS 402 Moodle
No question: Moodle
access to a machine through openssh attack steps : ● identify target in the supply chain ( liblzma / xz ) ● the attacker “ jia tan ” contributed for 3 years to gain community trust ● the attacker gained maintainer access ● push the backdoor to liblzma liblzma serves as the compressing / decompressing components for cri...
EPFL CS 402 Moodle
No question: Moodle
, pollution, earthquakes, cosmic radiation, war - like events, riots loss of essential services : power, cooling, communication technical failures : disk failure cyber : malicious software, denial of service, social engineering, software vulnerabilities / exploits this lecture focuses on cyber threats! 24 motivation fo...
EPFL CS 402 Moodle
No question: Moodle
##ki / advanced _ persistent _ threat cyber attack lifecycle phase 2 : maintain access ● strengthen foothold : persistence, lateral movement ● expand access, obtain credentials phase 3 : complete mission ● exfiltrate data ● manipulate, sabotage data phase 4 : cover tracks ● delete log files 28 https : / / en. wikipedia...
EPFL CS 402 Moodle
No question: Moodle
, lulzsec ) ● anonymous publication of confidential data ● distributed denial of service ( ddos ) 32 https : / / www. spiceworks. com / it - security / cyber - risk - management / articles / what - is - hacktivism / examples of hacktivism panama papers ( 2016 ) : somebody stole and published documents about 214, 000 of...
EPFL CS 402 Moodle
No question: Moodle
: hides presence of malware on computer ransomware : encrypts files and requests payment for decryption nation state malware : malware developed by a nation - state 35 botnets : compute for hire mirai botnet consists of 150k iot cameras used to sell compute for, e. g., distributed denial of service attacks ( ddos ) den...
EPFL CS 402 Moodle
No question: Moodle
a change in behaviour insecure file operations : incorrect assumptions about ownership, location or attributes side - channel leakage : leaking information via time, power, sound, etc. weaknesses in the implementation of access control : authentication and authorization flaws 39 summary a threat is an unwanted action t...
EPFL CS 402 Moodle
No question: Moodle
crypto ● 1970s rivest, shamir, adleman rsa ● 1985 elliptic curve crypto ( ecc ) ● 1990s md5, sha - 1 hash algorithms ● 2001 sha - 2 ● 2001 advanced encryption standard ( aes ) ● 2015 sha - 3 5 how do you deploy new algorithms? how do you sunset old algorithms? brief look at the present / future if quantum computers eve...
EPFL CS 402 Moodle
No question: Moodle
disadvantages : ● requires truly uniform random one - time pad values ● key must not be used more than once ● key length depends on the message length e. g., it needs a 1tb key to encrypt a 1tb disk 8 perfectly secure but impractical symmetric crypto 9 symmetric crypto encryption and decryption are done with the same k...
EPFL CS 402 Moodle
No question: Moodle
bit in the plaintext ● e. g., if you know which bit encodes the sign of a value you can change a payment of $ 100 to - $ 100 ● you should always add an integrity check when encrypting data! cipher reuse : if two cleartexts are encrypted with the same cipher - stream, then : ⊕ = ⊕ ● if you know some bits of one message,...
EPFL CS 402 Moodle
No question: Moodle
bytes multiple rounds ensure thorough shuffling https : / / en. wikipedia. org / wiki / advanced _ encryption _ standard 15 modes of operation : ecb ecb : encrypt each block separately, with the same key 16 plaintext ciphertext block cipher encryption key electronic codebook ( ecb ) mode encryption plaintext ciphertext...
EPFL CS 402 Moodle
No question: Moodle
following blocks? ● does it only affect the current block? ● none of the above? 21 modes of operation : cbc a whole block is garbled, one bit of the next block is inverted 22 plaintext ciphertext block cipher encryption key initialization vector ( iv ) cipher block chaining ( cbc ) mode decryption block cipher encrypti...
EPFL CS 402 Moodle
No question: Moodle
output cryptographers say they map a ‘ preimage ’ to an ‘ image ’ 26 e8927ahk03bc9f.. data of arbitrary length fixed length hash ( digest ) message hash function preimage image properties of hash functions preimage resistance : ● given a hash h, it is difficult to find a message for which h = hash ( ) ● this implies th...
EPFL CS 402 Moodle
No question: Moodle
random function that generates 160 bit outputs ( e. g., sha - 1 )? what is the complexity of randomly finding a collision in sha - 1? nb : if the hash function has some weaknesses, the complexity might be lower 30 collisions in naively, 2 ^ 160 ops better : 2 ^ 80 ops * in practice, it took 2 ^ 63. 1 operations to find...
EPFL CS 402 Moodle
No question: Moodle
exchange, a correct mac proves : ● that the message was not created by a third party ( authentication ) ● that the message has not been modified ( integrity ) 33 message authentication codes typically based on a hash function ( e. g. hmac sha - 2 ) or on block ciphers ( e. g. cbc - mac - aes ) 34 “ alice ” “ bob ” mali...
EPFL CS 402 Moodle
No question: Moodle
##1305 and aes - siv ) 38 initialization vector ( iv ) counter 0 counter 1 counter 2 incr block cipher encryption block cipher encryption ciphertext plaintext 1 auth data 1 h h block cipher encryption ciphertext plaintext 2 h auth tag incr public - key cryptography 39 public - key cryptography solves the problem of hav...
EPFL CS 402 Moodle
No question: Moodle
providing provably secure cryptosystems, changing this ancient art into a science. ” 41 original primitives public and private key ● two keys : public is widely distributed, private is kept secret ● must be hard to derive private from public ● may be easy to derive public from private operation : encryption and decrypt...
EPFL CS 402 Moodle
No question: Moodle
computer can verify that the update indeed comes from the developer and that it has not been altered on its way authenticated email ● if alice knows bob ’ s public key, she can verify bob ’ s signature on messages contracts ● in switzerland you can sign contracts with digital signatures 44 diffie - hellman key exchange...
EPFL CS 402 Moodle
No question: Moodle
, p = rand ( size ) ; - - - a = g ^ a % p k1 = x ^ a % p b = rand ( size ) ; - - - b = g ^ b % p k2 = x ^ b % p a, g, p x m = rand ( size ) ; - - - x = g ^ m % p k1 = a ^ m % p k2 = b ^ m % p x, g, p b diffie - hellman : man in the middle 52 must authenticate each other using, e. g., public keys mitm may break diffie -...
EPFL CS 402 Moodle
No question: Moodle
can be broken by factoring. use a number of 3072 bits or more ( for 128 bits of security ). scheme above is trivially insecure. use a padding scheme ( preferably rsa - oaep ). elliptic curve cryptography ( ecc ) based on elliptic curves over finite fields used everywhere, e. g., can adapt diffie - hellman with differen...
EPFL CS 402 Moodle
No question: Moodle
comparison asymmetric is powerful but orders of magnitude slower than symmetric crypto asymmetric used to exchange a symmetric key, then symmetric takes over all these algorithms are only safe with long enough keys ( for 128 bits of security ) : ● symmetric : 128 to 256 bits ● asymmetric : rsa 3072 bits, ecc 256 bits ●...
EPFL CS 402 Moodle
No question: Moodle
the certificate ● the public key of the subject ● the signature by the ca 60 example certificate hexhive ’ s certificate is signed by let ’ s encrypt uses rsa + sha256 61 example “ root ” certificate let ’ s encrypt certificate is signed by … isrg 62 hierarchy of trust current browsers know a set of root cas ( 144 root...
EPFL CS 402 Moodle
No question: Moodle
tls is to provide a secure channel between two communicating peers ” ietf rfc 8846 basic idea : ● build your client - server app without security, add tls, et voila! history : ● tls 1. 0, 1999, rfc 2246 ● tls 1. 1, 2006, rfc 4346 ● tls 1. 2, 2008, rfc 5246 ● tls 1. 3, 2019, rfc 8846 67 tls building blocks the server is...
EPFL CS 402 Moodle
No question: Moodle
s ha256 ● tls _ aes _ 128 _ ccm _ sha256 ● tls _ aes _ 128 _ ccm _ 8 _ sha256 ● that ’ s it! 70 ( some ) tls v1. 2 suites ● tls _ ecdhe _ rsa _ with _ aes _ 128 _ gcm _ sha256 ● tls _ ecdhe _ ecdsa _ with _ aes _ 128 _ gcm _ sha 256 ● tls _ ecdhe _ rsa _ with _ aes _ 256 _ gcm _ sha384 ● tls _ ecdhe _ ecdsa _ with _ ae...
EPFL CS 402 Moodle
No question: Moodle
with _ aes _ 128 _ cbc _ sha ● tls _ ecdhe _ ecdsa _ with _ aes _ 128 _ cbc _ sha ● … ( 37 total suites!!! ) simplicity is key! tls 1. 3 removes old, no - longer - safe cipher suites, remove compression remaining cipher suites all use aead handshake ● can be shorter in some cases ● is partially encrypted key exchange i...
EPFL CS 402 Moodle
No question: Moodle
it holds the private key ● elliptic curve diffie hellman is used to exchange a symmetric key symmetric crypto : ● aes block cipher is used in gcm mode for encryption ● sha hash is used for hmac, for key derivations 75 historical weaknesses of tls downgrade attacks ( by a man - in - the - middle ) ● trick server into us...
EPFL CS 402 Moodle
No question: Moodle
’ t tls use the starttls command on the standard protocol ● e. g., esmtp ( extended smtp ) on port 25 ● client types starttls if it wants to start a handshake ● opportunistic encryption, no guarantees ● mitm can pretend starttls is not supported 77 deploying tls on the internet 78 increasing usage of tls using https ev...
EPFL CS 402 Moodle
No question: Moodle
to https the mitm doesn ’ t show you the redirect, your browser continues to use http ● or, attacker replaces https with http in the links of the pages that you visit you connect to the mitm with http, attacker connects to the site with https 82 you have no alert, as your browser doesn ’ t know that you should be using...
EPFL CS 402 Moodle
No question: Moodle
trusted certificate in the name of any server using this, the server can intercept the traffic without you knowing 85 untrustworthy cas reasons for a ca to hand out fake certs ● the ca has been hacked ( 2011 comodo was hacked, certificates were generated for, e. g., www. google. com, login. yahoo. com, login. skype. co...
EPFL CS 402 Moodle
No question: Moodle
in the client if the server shows a certificate which is not signed by this pin, it does not accept to connect, e. g., a mobile e - banking application only trusts certificates signed by an intermediate ca of the bank there was a proposal to enable pinning in browsers with an http header ( hkpk ) but it did not work ou...
EPFL CS 402 Moodle
No question: Moodle
logs : 92 tls summary 93 tls summary tls authenticates the server ( and possible the client ) and protects confidentiality and integrity of data using a combination of symmetric and asymmetric crypto a public key infrastructure ( pki ) distributes public keys using certificates this does not work on the internet, becau...
EPFL CS 402 Moodle
No question: Moodle
understand the value of authentication protocols and delegated authentication 3 authentication 4 what is authentication? 5 authentication is the process of verifying someone's or something's identity identification is the act of identifying a particular user, often through a username. hi, i ’ m mathias! show me the pro...
EPFL CS 402 Moodle
No question: Moodle
google ) 8 truth : passwords are still the main form of authentication on the web “ no other single technology matches their combination of cost, immediacy and convenience ” ( c. herley, p. van oorschot ) ( bill gates, 2004 ) ( ibm, 2011 ) ( h. adkins, manager of information security at google, 2013 ) even strong passw...
EPFL CS 402 Moodle
No question: Moodle
e. g., lastpass ) browser plug - in or app downloads credentials and decrypts them locally you must trust them to not steal your master password ● best of both : the password manager comes with an open source server that you can host where you want ( e. g., bitwarden ) 10 authentication / session cookies after logging ...
EPFL CS 402 Moodle
No question: Moodle
owns the phone ( or sim card, secure hardware? ) 13 something you own a private key in a hardware token ● token signs a challenge ● different keys for different websites ● proof that user owns the token ● secure hardware ● universal 2nd factor ( u2f ) standard 14 oath, generation of otp oath is a standard that describe...
EPFL CS 402 Moodle
No question: Moodle
the fido alliance latest version is fido2 for each application, the token generates a key pair and gives the public key to the server ● on login, the server sends a random challenge to the client ● the client signs ( the challenge + the domain name of the server + a signature counter ) ● the client sends the data and s...
EPFL CS 402 Moodle
No question: Moodle
assertion contains information whether the user ● was present ( e. g., clicked on a button ) ● was verified ( e. g., pin or fingerprint ) u2f, fido2 ( webauthn ) 20 u2f, fido2 pros no problem if the server gets hacked : ● it is an asymmetric system. the information stored on the server cannot be used to log in no probl...
EPFL CS 402 Moodle
No question: Moodle
’ t frr false rejection rate : the system declares a non - match although it was a match eer equal error rate, when the system is tuned such that far = frr 24 biometrics : fingerprints the fingerprint is read by a sensor an image of the ridges is created the minutiae are extracted at ● termination of a ridge ● bifurcat...
EPFL CS 402 Moodle
No question: Moodle
to store the biometric data locally in protected hardware ● example : biometrics are stored in passports, not at the customs offices smartphones store fingerprint data in separate, secure hardware ● some sensors can be fooled or replaced ● not ideal for remote authentication rather use it for local access to authentica...
EPFL CS 402 Moodle
No question: Moodle
basics 34 security policy access rights ( aka permissions, privileges ) describe which subjects can do what operations on what objects a security policy is a collection of access rights. security policies can be represented as an access control matrix 35 https : / / dl. acm. org / doi / 10. 1145 / 775265. 775268 securi...
EPFL CS 402 Moodle
No question: Moodle
typically enforced with ● network equipment : firewalls ● the servers : local firewall on the server ( e. g., ufw in linux ) configuration of the server software 38 what are the tradeoffs of filtering at the different levels? multiple ( confusing? ) levels of access control access control at the operating system ● whic...
EPFL CS 402 Moodle
No question: Moodle
users can be added to groups ● examples : debian / ubuntu : audio group can access mic and loudspeakers, wireshark group can sniff network traffic windows : " remote desktop user " group can access desktop remotely which groups does your user belong to? rbac implementation 43 $ id gannimo uid = 1000 ( gannimo ) gid = 1...
EPFL CS 402 Moodle
No question: Moodle
departments ● for “ manager ” roles, in general, is a finance it manager the same as a marketing it manager? rbac cons discretionary access control ( dac ) access control is at the discretion of the object owner ● owner specifies policies to access resources it owns access control matrix represents rules ● stored by co...
EPFL CS 402 Moodle
No question: Moodle
, e ( x ) ecute ● for directories : r : directory can be listed w : directory can be modified ( create, delete, rename files ) x : directory can be accessed by the cd command the three rights and three groups are stored in 9 bits ● represented as three octal digits ● owner rwx, group rx, others r : rwx | r - x | r - - ...
EPFL CS 402 Moodle
No question: Moodle
gufw / app _ profiles / ssh. gufw _ service - rw - r - - r - - 1 root root 213 mai 24 2017 gufw / app _ profiles / ssh. gufw _ service acls in unix : setuid / setgid if a program has setuid bit set, it will be run with the permissions of the owner of the file instead of the permissions of the user running the program v...
EPFL CS 402 Moodle
No question: Moodle
: 51 $ ps - ef | grep passwd root 16003 26651 0 09 : 26 pts / 1 00 : 00 : 00 passwd the setgid bit does the same for groups : the group of the process running the program is set to the group of the owner of the program setuid and setgid is displayed as s instead of x in the access rights of the file example : this prog...
EPFL CS 402 Moodle
No question: Moodle
: ● cap _ chown : make arbitrary changes to file user id and group id ● cap _ dac _ override : bypass file read, write, and execute permission checks ● cap _ sys _ boot : use reboot or kexec ( load a new kernel ) example : dumpcap is the program used by wireshark to sniff network traffic ● it can only be run by user ro...
EPFL CS 402 Moodle
No question: Moodle
root! pros ● flexible ● intuitive ● easy to manage ( owners get to set the permissions themselves ) dac pros and cons 56 cons ● depends on the owners judgment ● only works if programs are benign and users make no mistakes ● vulnerable to the " trojan " / declassification problem * * a malicious program run by an author...
EPFL CS 402 Moodle
No question: Moodle
documents? 59 remember the order of “ secrecy ” : unclassified, confidential, secret, top - secret. a secret subject may read a secret file and write the contents into a confidential file, thereby reclassifying the secrecy level and downgrading it. this is also called the “ no - write - down ” problem. mac confidential...
EPFL CS 402 Moodle
No question: Moodle
, ports and other objects can be labeled with name, role and type ● rules can be defined to allow certain actions selinux is leveraged in android : better isolation of apps and generic services 62 mac linux examples : apparmor ● also based on lsm ● uses profiles to define access rights to files, network and capabilitie...
EPFL CS 402 Moodle
No question: Moodle
insufficient? ● sending passwords over network is risky, leaks to adversary when the network is compromised ● attacker may break encryption ● server may be compromised or even store passwords too ● challenge - response authentication why do we need authentication protocols? ● standardization and save duplicated efforts...
EPFL CS 402 Moodle
No question: Moodle
) ● wifi wpa, wpa2, and wpa3 challenge - response protocols may be eavesdropped or suffer cracking attacks ● the attacker records a challenge and a response ● they try all possible passwords to find which would yield the same response 70 kerberos kerberos provides authentication and authorization across a network subje...
EPFL CS 402 Moodle
No question: Moodle
the as for each service access. instead, the tgt can be used multiple times to request service - specific tickets from the tgs. 74 delegated authentication 75 oauth2 kerberos is a great but targets the intranet. following the idea of delegated auth … oauth2 ( rfc 6749 ) is used for delegated authentication on the inter...
EPFL CS 402 Moodle
No question: Moodle
● the authentication code is not sufficient to get access to the resources ● it can only be used by the client and nobody else oauth2 can be used by browsers or in apps ● in an app a redirection for authentication can be either opening a browser within the app ( called a webview ) ■ not very safe as the app could be sp...
EPFL CS 402 Moodle
No question: Moodle
##rberos use symmetric crypto authentication summary 81 for the homework you will play with cookie for authentication ● cookie tampering ( attack ) ● hmac for cookies ( defense ) you will get confident with the otp algorithm internals ● hotp algorithm, based on hmac algorithm ● totp algorithm, an extension of the hotp ...
EPFL CS 402 Moodle
No question: Moodle
store ● what are security requirements of db systems? ● what are main attack vectors of db systems? ● what are main protections of db systems? typical setups 4 internet firewall database web server farm on premises internet database website instances in the cloud / paas ( platform - as - a - service ) multitier archite...
EPFL CS 402 Moodle
No question: Moodle
the files the sysadmin can access the files database db administrators use privileged db accounts for maintenance they can access all data network the application tier uses a tcp connection to talk to the db hackers could connect to the db remotely application uses a db account to access the data of the application use...
EPFL CS 402 Moodle
No question: Moodle
/ var / lib / mysql / total 110660 drwx - - - - - - 2 mysql mysql 4096 feb13 23 : 13 com402 drwx - - - - - - 2 mysql root 4096 feb13 22 : 49 mysql drwx - - - - - - 2 mysql mysql 4096 feb13 22 : 49 performance _ schema the data of the com402 db is stored in directory com402 only user mysql is allowed to access this dire...
EPFL CS 402 Moodle
No question: Moodle
database tables create view year _ 2024 as select * from com402. students where academic _ year = 2024 ; grant select on year _ 2024 to bob @ localhost ; role - based db access control sql databases also support role based access control roles are created very much like users ● privileges can be granted to roles ● then...
EPFL CS 402 Moodle
No question: Moodle
2. 2. 33 application access control applications usually have their own layer of users and privileges ● they use one or few db accounts to interact with the db example : an e - banking application has 1k customers and three tables : ● a customer table with all customers and their password hashes ● an account table with...
EPFL CS 402 Moodle
No question: Moodle
# given by user stmt = " select name, grade from students where name ='" + param + "'" cursor. execute ( stmt ) param = " peter " # given by user stmt = " select name, grade from students where name = % s " cursor. execute ( stmt, ( param, ) ) back to application level access control to limit the impact of sql injectio...
EPFL CS 402 Moodle
No question: Moodle
control 23 layer function protect against hardware / os data is encrypted when read / write to disk stealing of disk / cloning virtual machines database db encrypts when read / write to file access by os users / admins network db encrypts when read / write to network ( e. g., tls ) hackers cannot sniff data in transit ...
EPFL CS 402 Moodle
No question: Moodle
● certificate pinning : the client ( db ) can be given a copy of the server certificate or its ca ● it will refuse to connect if the server presents a different certificate ( no need for 200 cas as in web browsers ) 25 encrypting data in use by the application with encryption at rest and in motion, data is still in cle...
EPFL CS 402 Moodle
No question: Moodle
to protect data ● transparent data encryption protects at os and physical levels ● network traffic encryption is a must ● some data can be encrypted by the application, but you lose functionalities like search, sort, compare, etc. 28 password storage 29 password leaks are common source : troy hunt january 2019 30 the 7...
EPFL CS 402 Moodle
No question: Moodle
memory to speed - up cracking 34 the importance of salt 35 smbv1 ( microsoft ) does not salt their passwords. don ’ t be like microsoft. salt usage and examples salt : random data concatenated as an additional input to the hash function : pw _ hash = h ( password, salt ) examples ● wpa and wpa2 use the ssid as salt, an...
EPFL CS 402 Moodle
No question: Moodle
has the same hash “ 9cc2ae8a1ba7a93da39b46fc1019c481 ” ● if attackers had enough memory, they could calculate all hashes in advance and store them in a great big table eight mixed case characters plus digits : 62 ^ 8 2. 2 * 10 ^ 14 passwords we need 24 bytes to store a password and a hash ● the table would be 4. 7pb bi...
EPFL CS 402 Moodle
No question: Moodle
idea : trade more time of cracking a password for a smaller table can we crack two passwords from one password - hash pair? 41 password hash password hash p0 h0 p7 h7 p1 h1 p64 h64 p2 h2 p11 h11 … … … … pn / 2 pn / 2 pm hm h h h h h h h h???? ● number of passwords : n ● memory required : 1 / 2 * n * ( password _ len + ...
EPFL CS 402 Moodle
No question: Moodle
hash to password should be unique - ish ) ● output is reasonably uniformly distributed ● does not require any specific structure password cracking : time - memory trade - offs basic idea : trade more time of cracking a password for a smaller table 44 password hash p0 h0 p7 h7 p1 h1 p64 h64 p2 h2 p11 h11 … … … … pn / 2 ...
EPFL CS 402 Moodle
No question: Moodle
hl pq hq h h h h r r r r h h h h r r r r h h h h r r r r h h h h r r r r h h h h password cracking : time - memory trade - offs challenge : reduction function may collide result in identical chains, which is a waste of the table space 46 password hash p0 h0 p7 h7 p4 h4 p42 h42 p35 h35 p1 h1 p64 h64 p23 h23 p6 h6 p32 h3...
EPFL CS 402 Moodle
No question: Moodle
##n hn pm hm pt ht pl hl pq hq h h h h r1 r1 r1 r1 h h h h r2 r2 r2 r2 h h h h r3 r3 r3 r3 h h h h r4 r4 r4 r4 h h h h storing hashes with salt and iterations 48 the classical way using salt adding a random value ( salt ) to the hash function prevents the two issues : ● you cannot crack multiple hashes with a single ha...
EPFL CS 402 Moodle
No question: Moodle
g., 0. 05s instead of 0. 00001s ) ● cracking will be 5, 000 times slower ( e. g., 2 years instead of 4 hours ) 51 salt and iterations : standards there is an official standard for using salt and iterations in hash functions the current version is password based key derivation function 2 ( pbkdf2, rfc 8018 ) used for ex...
EPFL CS 402 Moodle
No question: Moodle
calculate the result ● but you have to recalculate intermediate values again and again typical memory hard hash functions can be parameterized : ● choose the amount of memory needed ● choose the number of steps to calculate 55 memory hard password hash functions scrypt ● invented in 2012 by colin percival and standardi...
EPFL CS 402 Moodle
No question: Moodle
not, use pbkdf2 password storage in linux most distributions switched to yescrypt ( a memory hard function ) the salt and hash are stored in / etc / shadow : ● $ 1 $ is message digest 5 ( md5 ) ● $ 2a $ is blowfish ● $ 5 $ is 256 - bit secure hash algorithm ( sha - 256 ) ● $ 6 $ is 512 - bit secure hash algorithm ( sha...
EPFL CS 402 Moodle
No question: Moodle
a good start pbkdf2 is the standard way of doing it ● memory hard functions are better they are more expensive to parallelize ( gpus and fpgas have little internal memory ) examples : yescrypt, scrypt, or argon2 59 secure remote password protocol ( srp ) 60 introduction secure remote password protocol ( srp ) : a passw...
EPFL CS 402 Moodle
No question: Moodle
it contributes to the calculation of the key the client will need to know the salt to calculate, so it first asks for this x = h ( s | h ( u ) | ’ : ’ | p ) v = gx mod n b = ( gx + gb ) mod n srp exchange 63 bob alice knows username and password ( u, p ) ask for salt of user u knows username, salt, and gx ( u, s, gx ) ...
EPFL CS 402 Moodle
No question: Moodle
message or a mac to prove that they succeeded in calculating the key 64 summary data security touches three kinds of data : at rest, in transit, and in use data must be protected throughout all layers ( from hardware to app ) passwords may never be stored in cleartext hashing with salt is key, ideally using a memory ha...
EPFL CS 402 Moodle
No question: Moodle
- the - wild ” vulnerabilities 6 memory safety violations are most common 7 https : / / syzkaller. appspot. com / upstream a major portion ( 147 / 442, ~ 33 % ) of bugs found by syzbot is still memory corruption errors. ( 24. 09. 2024 ) memory safety 8 76 % of android vulnerabilities in 2019 24 % of android vulnerabili...
EPFL CS 402 Moodle
No question: Moodle
? type system 13 logical system that assigns a type to every term ( variable, expression, function ) type of a value specifies which operations can be applied to it type of a variable limits values that it can be assigned type of an expression / function delimits values it accepts and can produce many different type sy...
EPFL CS 402 Moodle
No question: Moodle
##ch is typing error dynamic type system tracks types of objects at runtime and prevents improper operations from being applied to them static / dynamic typing pros / cons 16 static – checked at compile time ● no runtime overhead ( memory or time ) ● find errors before program runs ● find all errors ● better for buildi...
EPFL CS 402 Moodle
No question: Moodle
; strcpy ( & str - > first, s ) ; return str ; } printf ( “ % s \ n ”, ( char * ) ( & ( str - > first ) ) ) strict / relaxed ( or weak ) c is not strict! it “ trusts ” programmer - supplied type conversions. 18 danger zone! put string inline in struct! what ’ s up with c ’ s type system? 19 c was a thin layer over asse...
EPFL CS 402 Moodle
No question: Moodle
allocation. type confusion bugs in c 22 # define name _ type 1 # define id _ type 2 struct messagebuffer { int msgtype ; union { char * name ; int nameid ; } ; } ; int main ( int argc, char * * argv ) { char * defaultmessage = " hello world " ; struct messagebuffer buf = {. msgtype = name _ type,. name = defaultmessage...
EPFL CS 402 Moodle
No question: Moodle
valid objects are accessed ● the underlying object has not been freed memory corruption unintended modification of memory location due to missing / faulty safety check 26 void vulnerable ( int user1, int * array ) { / / missing bound check for user1 array [ user1 ] = 42 ; } spatial memory safety error the pointer is up...
EPFL CS 402 Moodle
No question: Moodle
check for array access spatial memory safety : array access int array _ access ( int array [ ], int size, int index ) { if ( index > size ) return 0 ; else / / * ( array + i * sizeof ( int ) ) return array [ index ] ; } pub fn access _ slice ( bytes : & [ u8 ], index : usize ) - > u8 { return bytes [ index ] ; } access...
EPFL CS 402 Moodle
No question: Moodle
/ cost - of - safety - in - java / [ 3 ] griffin smith, how much does rust's bounds checking actually cost?, november 2022. https : / / blog. readyset. io / bounds - checks / overhead for enforcing spatial memory safety for c code is significant ● softbound reported 67 % overhead [ 1 ] ● “ unfortunately, c's arbitrary ...
EPFL CS 402 Moodle
No question: Moodle
availability concern ● basis for denial - of - service attacks ( out - of - memory ) https : / / book. hacktricks. xyz / binary - exploitation / libc - heap / double - free 35 reference counting every block of memory maintains a count of numbers of pointers to it ● one when block allocated ● copying pointer increments ...
EPFL CS 402 Moodle
No question: Moodle
2 1 x y last list object instance global frame 40 reference counting example x = [ 1, 2, object ( ) ] y = x last = x [ - 1 ] x. pop ( ) del last 2 1 x y list global frame 41 garbage collection ( gc ) when program is running out of free memory, stop and run collector to find unreachable objects pauses program execution ...
EPFL CS 402 Moodle
No question: Moodle
reference counted pointers, similar to those used in python. ● weak _ ptr : used together with shared _ ptrs to break reference cycles. 44 c + + smart pointers : example 45 class smartptr { int * ptr ; / / actual pointer public : explicit smartptr ( int * p = null ) { ptr = p ; } / / destructor ~ smartptr ( ) { delete ...
EPFL CS 402 Moodle
No question: Moodle
0 ] ) ; 47 error : use of moved value : ` v ` println! ( " v [ 0 ] is : { } ", v [ 0 ] ) ; variables own the value they are bound to ( contain ) when variable goes out of scope, value is deallocated key restriction : exactly one variable can be bound to a value a step forward from c + + smart pointers, as the compiler ...
EPFL CS 402 Moodle
No question: Moodle
, need mutable reference if foo changes v1 or v2 borrowing example fn main ( ) { let mut x = 5 ; let y = & mut x ; / / removing this line works / / single mutable borrow dbg! ( & x ) ; * y + = 1 ; } 50 read / write restriction cannot have mutable and immutable borrow to a value at the same time rust ownership pain “ im...
EPFL CS 402 Moodle
No question: Moodle
a mutable borrow to both neighbors. ● still needs to implement a custom destructor to avoid memory leak. ● bad performance due to multiple layers of wrapping. 53 struct node { data : i32, prev : option < rc < refcell < node > > >, next : option < rc < refcell < node > > >, } 54 rust also allows unsafe code that would n...
EPFL CS 402 Moodle
No question: Moodle
. as _ ptr ( ) as * mut u8 ; unsafe { alloc : : realloc ( old _ ptr, old _ layout, new _ layout. size ( ) ) } } ; } 56 rewrite everything in rust? in many cases, simply not possible. ● chromium is over 33 million lines of code. ( mostly c + + ) ● the linux kernel is around 30 million lines of code ( mostly c ) ● simply...
EPFL CS 402 Moodle
No question: Moodle
wikipedia. org / wiki / thread _ safety dirty cow a local privilege escalation attack that exploits a race condition in the linux kernel memory - management subsystem. cow : copy on write, a mechanism for efficiently sharing modifiable data. used extensively in the mmap and fork syscall. with the right timing, a read -...
EPFL CS 402 Moodle
No question: Moodle
end of the channel to another. it ’ s possible to send pointers, but that once again may create issues. 63 func main ( ) { / / creates a channel messages : = make ( chan string ) / / creates a new goroutine / / sends data into the channel ( goroutine thread ) go func ( ) { messages < - " ping " } ( ) / / receives data ...
EPFL CS 402 Moodle
No question: Moodle
wrapped = arc : : new ( mutex : : new ( vec! [ 1, 2, 3 ] ) ) ; let copy = wrapped. clone ( ) ; thread : : spawn ( move | | { dbg! ( copy. lock ( ). unwrap ( ) ) ; } ) ; wrapped. lock ( ). unwrap ( ). push ( 3 ) ; } sandboxing & compartmentalization 68 principle of least privilege 69 the principle of least privilege ens...
EPFL CS 402 Moodle
No question: Moodle
the implementation of the sandbox. bugs may still lead to sandbox breaches 71 flash and vba macros used to be security nightmares ( now phased out ) javascript engine bugs remain a source of critical browser vulnerabilities sandboxing : hard to get right 72 compartmentalization 73 compartmentalization can enforce princ...
EPFL CS 402 Moodle
No question: Moodle
increasing safety in the programming languages paradigm by converting c code to rust code using safe code practices concerning ● external code ● memory pointers ● union types ● global variables ● name mangling securing unsafe code with compile - time checks or runtime fails ● stack spatial safety ● stack temporal safet...
EPFL CS 402 Moodle
No question: Moodle
##asp top 10 ● tool : zed attack proxy ( zap ) ● method : owasp testing guide the “ top 10 ” project documents the 10 most critical security risks to web apps ● updated frequently, current : 2021 ● https : / / owasp. org / top10 / ● cross - references cwes 4 cve : common vulnerabilities and exposures cwe : common weakn...
EPFL CS 402 Moodle
No question: Moodle
post / v7 / writesubmission? _ reqid = 4786040 & rt = j http / 1. 1 host : classroom. google. com f. req = [ [ 3 ], [ [ [ " 18537069787 ", [ " 46653220298 ", [ " 41400909728 " ] ] ], [ [ " 18537069787 ", [ " 46653220298 ", [ " 41400909728 " ] ] ], null, null, null, [ [ null, null, " 1h8trewm8cp6bsv24bwmlimfrj3w1d7sdpxy...
EPFL CS 402 Moodle