11/26/19
K.Chan:CSE435:SoftwareEngineering 1
IntroductiontoSecurityKiraChan
K.Chan:CSE435:SoftwareEngineering
Softwareexpectation
• Inaregularmessagingapplication,whatdoyouexpect?• Let'sassume youwanttouseittomeetyourfriend forFridaynightdinner.• Messagesaredelivered• Deliverswithinatimelimitthreshold• Nooneelseisreadingyourmessages• Messageisnotaltered• Applicationdoesnot“lag”• Etc
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 2
Terminology
• “Acomputeris secure ifyoucandependonit anditssoftwaretobehaveasyouexpect (intent).” • ‘Trust describesourlevelofconfidencethata computersystemwillbehaveasexpected.’ (intended)
[Garfinkel & Spafford, Kasten]K.Chan:CSE435:SoftwareEngineering
Whyshouldweconsidersecurity?
• Canyoubuildamessagingapplicationthatsatisfiesrequirements• Whoaretherequirementsmadefor?
• Stakeholders?• Users?
• Doeseveryuserconformtotheexpectationsyouhaveset?• Resourcesandinformationcontainmonetaryorothervalues• Securitybreachescouldbedamagingtoyourreputation• Whenissecurityusually takenintoconsideration?• Securityisoftenanafterthought• Addedontoasystem,itmaynotfullyaddresstheunderlying issue• Lotsofnew“Band-Aids”topatchanissue,causesinefficiency
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 3
Potentialimpact• Wannacry
• Encryptsuserdataanddemandransomtodecrypt it• https://www.symantec.com/blogs/threat-intelligence/wannacry-ransomware-attack
• SayIencryptedyourlaptop,yourfinalexamistomorrow• Ransomiseveryassetyouhave• Doyoupayit?
• Safety?• Whatifcriticalsystemsarecompromised?
K.Chan:CSE435:SoftwareEngineering
Definition(NIST)
• Computersecurityistheprotectionaffordedtoanautomatedinformationsysteminordertoattaintheapplicableobjective ofpreservingtheintegrity,availabilityandconfidentialityofthesystem’s resources• https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-14.pdf
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 4
Confidentiality,IntegrityandAvailability
• Confidentiality:informationarenotdisclosed tounauthorizedparties• Integrity:assurethatinformationandprogramareonlychangedinanauthorizedmanner• Amessageisactuallyfromwhereitclaimstohavecomefrom• Mailmandeliversyouamailfromyourbestfriendoverseas,howdoyouknowifthismessagehavenotbeenmodified?
• Availability:assuresthatthesystemsworkpromptly, andservicesarenotdeniedtoauthorizeduserswhentheyrequestthem
K.Chan:CSE435:SoftwareEngineering
Castleanalogy
Img source:McCallumK.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 5
Securitychallenges.
• Defendingasystemishardsincewemustsecureallweakpoints• Attackeronlyneedstofindoneexploit• Usersdonotlikecomplicatedsystems• Benefitofsecurityisnotconsidereduntilabreachoccurs• ITtechperson,whydoweevenhirethisguy?
• Impedimenttotheuser
K.Chan:CSE435:SoftwareEngineering
Terminology
• SecurityPolicy:asetofrulesandpracticesthatspecify orregulatehowasystemprovides securityservices toprotectsensitiveandcriticalsystemresources• Vulnerability:aflaworweaknessinasystemthatcanbeexploited• Threat:apotentialviolationofsecurity;apossible dangerthatmightexploitavulnerability• Attack:anassaultonthesystemthatderives fromathreat.• Threatscarriedout
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 6
Threats
• Hardware:physicaldevices– easytarget• “Involuntarycomputer-slaughter”• Accidentalactsnotintendedtodoharm• E.g.Spillingadrinkoncomputer
• “Voluntarycomputerslaughter”– machinicide:• Purposelybreakamachine
• Software:equipmentworthlesswithoutsoftware• Deletion• Modification• Theft
SlideprovidedfromDr.ChengK.Chan:CSE435:SoftwareEngineering
Whyarewetalkingaboutthis?
• Timeismoney• Organizationswantaproductthatmakesmoney, sotimespentnotmakingmoneyproducingsoftwareiswastedtime.• Monetory consequences areoftennotconsidereduntilabreach.• Example:CSE3xxprograms.• Didyouconsidersecuritywhenyoudevelopedyourprograms?
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 7
Patches
K.Chan:CSE435:SoftwareEngineering
Patches
• Changesmadetofix, improveorupdateyoursystem• Whatarepatchesused for?• Bug-fixes• Improvements• Newfeatures
• Whycanwenotjustpatchsecurityissues away?
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 8
Whentousepatchesforsecurity
• Securityshould bedefinedinyouroriginaldesign• Patchesshouldonlybegivenasemergencysolution• Userignorespatchesalotoftime
• Patchesmaynotfixthefundamentalissues
K.Chan:CSE435:SoftwareEngineering
Howdoweprovidesecuritytoasystem?
• Easiestway:noaccess.• Challengeistopreventunauthorizedaccesstosystem,whilecausingtheleastamountofimpedimenttolegitimateusers.
Userexperience
Security forsystem
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 9
Howtodesignyoursystem?• Designofsecurityshould beassmallandsimple asneeded• Easytotest/verifyitsstrength,fewerflaws
• OpenDesign:securitymechanismshould notbeasecret!• Why?• Expertscanreviewandpointtoflaws• Reverseengineeringcanexposeyour software• Youwillnotknowifyoursoftwarehavebeencompromised
K.Chan:CSE435:SoftwareEngineering
Howtodesignyoursystem(cont.)
• Psychological acceptability:thesecuritymechanisms shouldnotinterferewiththeworkoftheuser• Considerourmessagingapp
• Asksforuserpasswordevery30seconds• Lessextremeofanexample:requirerestartevery 12hours• Userwilldisarmifnot!
• Layering:Multiplelayersofsecurity.Failureatonepointwillnotleaveyoursystemcompromised• Example:messagingapplication
• Encryptstoredmessages• Ensureotherapplicationsonsamedevicecannotaccessthosefiles
• Leastastonishment:nosurprises!• Functionsshouldconformtouserexpectation
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 10
Remainderofpresentation
• Iwillfocus onwhatyoucandoasadevelopertohelpsecureyoursystem• Whattodoandwhatnottodo
K.Chan:CSE435:SoftwareEngineering
RiskAssessment
• Threequestions toanswer:• What amItryingtoprotect?• Whatdo Ineed toprotectagainst?• Howmuchtime,effort,andmoneyamIwillingtospendtoobtaintheseprotection?
• Threekeysteps:• Identifyassets• Identifythreats• Calculaterisks
• Risk:expected lossfromtheprobability thatathreat thatwillexploit avulnerability inthesystem
SlideprovidedfromDr.ChengK.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 11
IdentifyAsset
• Whatareyoutryingtoprotectagainst?RecallCIA• Data?• Messageconfidentiality?• Systemresources?• Availability?• Categoriesofvulnerabilities:• Corruption (lossofintegrity)• Leaky(lossofconfidentiality)• Unavailableorslowaccess(lossofavailability)
K.Chan:CSE435:SoftwareEngineering
IdentifyThreats
• Whatisthethreat?• Hackers?• Politicalopponents• Rivalcompanies• Activist
• Whatistheintent/objective ofthethreat?
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 12
3classesofintruderskilllevel
• Apprentice:minimaltechnicalskills• Useexistingtechnologies• Mostintrudersbelonginthiscategory• Easytodefend
• Why?
• Journeymen:modifiesandextendsattacktoolkits• Master:high-level technicalskills• Capableofdiscoveringnewattacks• Understandsunderlyingprotocolused• Writestheirownattacksandtoolkits• Hardesttodefendagainst
K.Chan:CSE435:SoftwareEngineering
Calculatingrisk
• Howlikelyisaparticularthreat?• WhatisthechancethatXwillhappen, andwhatistheconsequenceofit?• Ifaneventhappens onregularbasis, youcanestimatebasedonprevious experiences.
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 13
Differentkindofattacksyoumayconsiderasadeveloper
K.Chan:CSE435:SoftwareEngineering
DenialofService(DoS)
• Attackonavailabilityofasystem• Denylegitimateusertheabilitytouseasystemoritsresources• DistributedDenialofServiceattack(DDoS)
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 14
Quickoverviewofhowthewebworks
• Verysimplified• Yourclientconnectstoa“socket”ofaserverandthatsocketservesyou• Imagineaparkinglotconnectedtoamall.• Youcanonlyaccessthismallafterparkingatthelot• Eachparkingspot(socket)servesonecar(yourcomputer)only
K.Chan:CSE435:SoftwareEngineering
SimpleImplementation
• Nofeeorregistration• Letanyoneinwhentheyshowupatthegate• Onlyonecarcanpassthroughthegateatatime
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 15
in out
10(reservedport)
2 3 … 65535
Oneserver
K.Chan:CSE435:SoftwareEngineering
ClassicPingofdeathattack(moreinfo)
• Spampingtraffictothevictim,whichaffectsthenetworkperformance.• Notveryeffectivefromonecomputer• Itwillalsocrippletheattackingdevice,sinceyoualsomustsendthepackets.
• Canuseabotnet(abunchofcompromised computers)topingthesamevictim
Regular internettrafficisabout10kbpsDuringDoSattack,thisspikesto32Mbps
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 16
12…
cars
K.Chan:CSE435:SoftwareEngineering
Signatures
• Ifapersongeneratesaticketthatuses thesamecarmodel, yearfor60,000cars,itisprobablynotlegit.
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 17
Naïveprotocol
• 3Wayhandshake• Clientrequestsconnection• Serverresponsewithasynack• Allocateresourcesfortheclient
• Clientresponsewithanacktoack
Clienthello
Server ack
Clientack
Connectionestablishedhere
K.Chan:CSE435:SoftwareEngineering
in out
10(reservedport)
2 3 … 65535
Oneserver
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 18
Naïveparkinglot
• Driverrequestticketonline• Wereservetheparkingspaceforthem• Savedetailsofcarmodel,makeandyear
• Drivershowsup,inputs theticketandenterstheparkinglot• Theyfinish theirbusiness inthemallandleavesthelot(disconnect)• Theirspot canthenbereservedagainfornextcar
K.Chan:CSE435:SoftwareEngineering
Websiteattacks
• Consumeawebserver’sentirecapacity• Newlegitusersareunabletoestablishaconnection• Fairlycommon;youmayhaveencounteredoneorwillencounterone• Example:TCPsynattack(moreinfo)• RecentDDoSattacks:Github2018,WikipediaSep2019• Consequences?
• Damagetoreputation• Whatifthishappened toonline sellingplatform?• Consider ifyouareamazon,andthis happensduringblackfriday
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 19
TCPsynattack
• Taketicketonline• Parkinglotreservesaspotforyou
• Nevershowuptoclaimthespot
Clienthello
Server ack
Clientack
Connectionestablishedhere
K.Chan:CSE435:SoftwareEngineering
HowtodefendagainstDoSattacks?
• Youcannotpreventtheseentirely!• Highvolumesoftrafficmaybecompletelylegit• Thinkoftrafficamazon.com.Itmaybethatabunchofuserswanttobuyatthesametime(CyberMonday, lastminuteholidayshopping)
• HowtominimizeimpactofDoSattacks• Defensesatmultiplelayer• TCPconnections:usemodifiedTCPconnectioncode.
• UseTCPsyncookies• Dropanentryforincomplete connection fromTCPconnection tablewhenoverflowing
• Useofcaptcha• Useofmirrorsandreplicatedservers
• Disadvantage?
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 20
TCPsyncookieusingparkinglot
• Drivertakesaticket,theinformationofthevehicleisembeddedintheticket• Addsomeinformation thatwewanttotheticket• Spotisnotreserveduntilthecararrivesandentersthetickettothegate• Ifacarisidlefortoolong,kickitout
• Again,thisissimplified
K.Chan:CSE435:SoftwareEngineering
SlowLoris
• AnotherformofDoSattack• Sendalittlebitofdataatatime• Alegitclientmighthaveslowconnection• Onlyuses verylittlebandwidth andprocessing powerofattacker• Serverlosesabilitytoservenewclients• HowdowedefendagainstSlowLoris?
PictureCredit:Tilo NadlerK.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 21
Dynamicservers• Ideacamefromanonlinemultiplayergames• Hardwarehostmadetoaccountnormalleveloftraffic• Duringpeaktime(whenpeoplegetoffwork),dynamically spinupmoreserveroncloud
Server 1 …
1
65535
CloudServer n …
1
CloudServer 1 …
1
65535
CloudServer 2 …
1
65535
…
K.Chan:CSE435:SoftwareEngineering
Otherresourcesifyouarehostingyourownwebsite• https://www.cloudflare.com/• OrsimilarserviceswhocanprovideyouDDoSprotection• Ifyouhostyourownwebsiteasasmallbusiness, DDoSattackscanbedetrimental(sinceyouhavetopayforeachpacketsenttoyou)
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 22
Phishing
K.Chan:CSE435:SoftwareEngineering
Phishingattacks
• Socialengineeringattack• Aimstogetuserstocompromise theirownsystem• Verydangerous• Wecannotpatchthisaway
• Masqueradeasatrustedsource(looks legit)• Usespsychology tricks• Timeisrunningout,resetyourpasswordsoon
• Spear-phishing:emailspecificallycraftedforatarget
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 23
Source:CameronCampK.Chan:CSE435:SoftwareEngineering
Howtodefend?
• Knowledgeisessential• Checkdomain nameofemail(e.g.www.chasbank.com, [email protected])• Ifyoudoneedtoresetapassword, gotothewebsitedirectlyandresetitthroughtheirportal.Emaillinksaredangerous!• Ifanemailhasasenseofurgency,proceedcautiously• Ex:“Updateyourpaymentinformationoryourserviceswillbeterminated”
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 24
Passwords(Important!)
K.Chan:CSE435:SoftwareEngineering
Passwords
• Commonly used• Useraccountsmusthaveanassociatedpasswordwithit• Howdowestoretheseinadatabase?• Plaintext?• Encrypted?
• Keyconcept:developerneverneedtoknowauser’spassword!• Thefollowing conceptwillattempttodeteranattackonyoursystembutmaynotcompletelydefendagainstallattacks!• Entitieswithlargeresourcesandtimecancrackpasswords• IfIwanttoknowacertainpassword,Icantryallcombinationpossibleusingmanycomputers
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 25
Standardapproachestostoringpasswords
1. Taketheinputandhashit.• Ahashfunctiontakesanylengthinputandconvertsittoafixedlengthstringthatisdifferentforevery input.(SHA256,SHA512)
• Issue?• Someusersuseweakorcommonpasswords• Attackercanprecomputethehashedvalueofcommonpasswordsandcomparewithcompromiseddata
• Rockyou.txt2. Useasalt (randomstring)
• Tosolvethis,weappenda“salt”ofrandomstringstotheuserpassword,thenhashtheconcatenatedstring.Wethenstorethepasswordandsaltnexttoeachother
• Eachtimetheuserenterstheirpassword,addthesaltbeforeyouhashandcompare
K.Chan:CSE435:SoftwareEngineering
Cont.
3. Usea“pepper”(randomstring)• Similarconcepttoasalt,butthesamestringfortheentiresite• Aimtoslowdownattacker
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 26
Example
1. Input:password ->sha512(password)• B109F3BBBC244EB8244…
2. Saltandpassword:sha512(password +103FD07)• AB8B060C7283E36D93E…
3. Saltandpepper:sha512(sha512(password+salt), pepper)• Thisispainfulforanattackertocrack,especiallyiftheyaretryingtoexecuteabroadcomparisonagainstadatabaseofpasswords
K.Chan:CSE435:SoftwareEngineering
ExampleTableID Name Username Password Salt
1 JonDoe [email protected] NVSQY8ZBod… JLDq1RBXzN
2 WolfgangMozart wolfzart fgKotr16PM… jWTNN7kXhm
3 JohannPachelbel jpach 0iJExGx74e… yO1HoxSdoK
4 ClaudeDebussy debussy Y4hAdMD6Mr… 7Xz4iH0XMP
5 … … … …
Sitepepper(Notstoredindatabase):UW2vdTKmZN
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 27
Fromanattacker’sperspective
• Let'sconsider theotherperspective• Ifyouwanttoobtainapassword,howwouldyou?
• Phish• Tryallcommonpasswords• Eavesdropping• Tryallpossible combinations
K.Chan:CSE435:SoftwareEngineering
Howtosecureyourownpasswords
• Donotusethesamepasswordformultiple sites• Ifonesiteiscompromised,thenextone istoo• Somesitesmaystorepasswordsinplaintext(thereisno federalregulations)
• Donotusesimpleorcommonpasswords• Trytofinditinrockyou.txt
• Use:passphrases• myFavoriteBookIsGreatGatsby!
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 28
Passwordinputs
K.Chan:CSE435:SoftwareEngineering
SQLinjectionattacks(SQLi)
• Oneofthemostdangerousformofattacks• Asof2017,51%ofcyberattacksonwebappsarefromSQLi• https://www.akamai.com/de/de/multimedia/documents/state-of-the-internet/q2-2017-state-of-the-internet-security-report.pdf
• Userenterscodeintotheinputboxes• Servertakestheinputandruns it• Damages:unauthorizedlogin,unauthorizedchangestotable,droptables…
• Code….TakeUserInputDirectly…Code
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 29
Example
• UseofTautology(makecondition alwaysequaltotrue)• Inputpasswordas1’OR‘1’=‘1
• Useofcommentmark“--”• Subsequentcode (passwordcheck)ignored• https://www.w3schools.com/sql/trysql.asp?filename=trysql_comment_single_2
• Piggybackqueries• InsertSQLcodeafterinput• userPassword+;+DROPtable…• SELECT*FROMUSERSWHERE…..;DROPTABLEUSERS;--…..
• ExamplestakenfromDr.ScottTu
K.Chan:CSE435:SoftwareEngineering
Relevantxkcd
https://xkcd.com/327/K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 30
DefensesagainstSQLi
• ALLINPUTSAREEVIL!!• Sanitizeinput(afunction providedbyphp)• Stripsoutanycommentmarksandquotations
• Makesurethatinputconforms toexpectedinput• Parameterizedinputs• “preparestatements”:SELECTFROM?• Placeholdersareusedforparametersandvaluesaresuppliedatexecutiontimes
• Taketheseas“plaintext”anddonot runanythingthatresemblescommands• “Preattack”yoursystem
K.Chan:CSE435:SoftwareEngineering
Otherthingsthatyoumayencounter
• Redteamvsblueteam• Redteamisthe“adversary”• Theyattempttobreakintothesystem
• PenetrationTesters• Identifiesweaknessinasystem(mightbethecompany)• CouldbeapersondisguisedasITsupport toseeifemployeeswillfallforit
• Ethicalhackers
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 31
ConfidentialityandIntegrity
K.Chan:CSE435:SoftwareEngineering
Confidentiality
• Wedonotwantathirdpartylisteningtoourcommunications• Bankpassword?• Example:wireshark
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 32
K.Chan:CSE435:SoftwareEngineering
Communication betweenAliceandBob
Alice Bob
Let’smeet forcoffeetomorrowat7
Eve
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 33
AliceBob
PlaintextM EncryptionAlgorithm
CiphertextC DecryptionAlgorithm
PlaintextM
K.Chan:CSE435:SoftwareEngineering
Encryption
• Caesarcipher:earliestandsimplestcipher(moreinfo)• Shifteachcharacterbyafixednumbern.• Ifn=5• Attackatdawn->fyyfhp fy ifbs
• Strength?• Weak• Attackeronlyneedstotry26combinationstoobtaintheplaintextmessage.
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 34
Encryptionusedtoday
• Basedonmathematics• Typicallyuses a“ClassicFeistelNetwork”• Usessubstitution andtransposition• Substitution:replacexwithy• Transposition:switchbitsaround
K.Chan:CSE435:SoftwareEngineering
Disclaimer!
• Donottrytoimplementyourownencryption algorithm!• Youwillprobably doitwrongorleavesecurityflawsbehind• Useexistingones
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 35
SymmetricvsAsymmetric
• Symmetricencryptionuses thesamekeytoencryptanddecrypt• Ex:DES,3DES,AES
• Asymmetricencryptionuses privatekeyandpublickey• Encryptingwithprivatekeymeansonlypublickeycandecrypt• Encryptingwithpublickeymeansonlyprivatekeycandecrypt• Userkeepsprivatekeyprivate,publickeycanbesenttoanyone• What'sthepointofencryptingwithprivatekey?• Ex:RSA
K.Chan:CSE435:SoftwareEngineering
Symmetricencryption
AliceBob
PlaintextM AESencrypt Ciphertext C AESdecrypt PlaintextM
KeyA KeyA
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 36
Asymmetricencryption
AliceBob
PlaintextM RSAencrypt Ciphertext C RSAdecrypt PlaintextM
Bob’s Public Key Bob’s PrivateKey
K.Chan:CSE435:SoftwareEngineering
BlockCiphers
• Chopmessagesintoblocks offixedsize• Runencryptionalgorithmsontheseblocks• Permutatethekeysoweuseadifferentoneperblock• How?• Hash(key+1),Hash(key+2)…
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 37
Symmetricencryption:DES(moreinfo)
• DataEncryptionStandard• Keylength:56bits• 16rounds• Developedinearly1970s• UsestheFeistelfunction topermutateandaddkeyhalfblock atatime• Insecuresince thekeyisshort.• Proven in1998,keycanbediscovered in56hours.
• UsedinWEPandWPAwifi encryption(donotusethese)
K.Chan:CSE435:SoftwareEngineering
Source:MattCryptoK.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 38
HowdoweaddressweaknessesofDES?
• HardwareismadeforDES,expensivetoreplace.• Solution: 3DES• Encryption:C=Encrypt(K3,Decrypt(K2,Encrypt(K1, Plaintext)))• Decryption:P=Decrypt(K1,Encrypt(K2,Decrypt(K3,Ciphertext)))• Variablekeylengthof168, 112,56bits• WhyEncrypt->Decrypt->Encrypt?
K.Chan:CSE435:SoftwareEngineering
Symmetricencryption:AES(moreinfo)
• 3DESisnotapermanentsolution• AdvancedEncryption StandardakaRijndael• ReplacedDES(2001)• Inputblocksize:128,192or256bits• 10,12and14rounds respectively• Mostpopularformofsymmetricencryption• UsedforWPA2
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 39
EachroundofAES(Verysimplified)
1. Substitution: Replaceeachdatawithrespecttoatable(S-box)2. Shiftrows:Performcircularshiftoneachrow3. MixColumn:UseofGaloisfinitefieldmultiplication4. Addroundkey:XORwiththekey
https://www.commonlounge.com/discussion/e32fdd267aaa4240a4464723bc74d0a5
K.Chan:CSE435:SoftwareEngineering
Img fromstallingandbrowntextbookK.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 40
Asymmetricencryption:RSA(moreinfo)
• Rivest,Shamir,andAdleman MITin1977• Bestknownandwidelyusedpublickeyalgorithm• Usesprivateandpublickeys• Securityreliesondifficultyoffactoringaprime
K.Chan:CSE435:SoftwareEngineering
Howtogeneratekeys
1. Selecttwoprimes pandq,say17and112. Calculatep*q=17*11=1873. Calculateφ(n)=(p-1)*(q-1) [Euler’sproductformula] =16*10=1604. Selectpublic keyesuch thateisrelativelyprimetoφ(n)andlessthan
φ(n).Wechoosee=75. Determineprivatekeydsuch thatd*emodφ(n)=1.d=23• 23*7=161
Example fromDr.ScottTuK.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 41
RSAFactoringChallenge
• Suppose attackerhavepublickeyandencryptedmessageC• TodecryptC,theymustinferprivatekeyd• Todoso,theymustcalculated=(k*φ(n)+1)/e• Musttryeverypossiblecombination
• Calculatingφ(n) isinNP• Weuseextremelylargeprimenumbersfordande
K.Chan:CSE435:SoftwareEngineering
Whichencryptionschemeshouldyouuse?
• YougenerallywanttouseRSAorAES• Otherconceptsrelatedtokeysifyouareinterested• TransportLayerSecurity(TLS)• https
• DiffieHellmanKeyExchange
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 42
Malware
K.Chan:CSE435:SoftwareEngineering
Definitionfrom[NISTIR7298]
• Aprogramthatisinsertedintoasystem,usually covertly,withtheintentofcompromising theConfidentiality, Integrity,orAvailabilityofthevictim’s data,apps,OSorotherwiseannoying/disruptive.
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 43
Virus
• Infectsprograms(usually executables)• Needsahosttoinfect• Whenattachedtoanexecutable(.exefile),avirus candoanythingthattheprogramcando• OSspecific!• Howtodefendagainstthistypeofattack?• Useofantivirus,theycanlookforknowvirussignatures
K.Chan:CSE435:SoftwareEngineering
Worms
• Similartovirus, spreadsthroughnetworkconnection, email…• STANDALONEPROGRAM• Activelyseeksoutmorehosts toinfectandeachinfectedmachineservesasaplatformtolaunchfurtherattacks.• Examples:• ILOVEYOU(2000s)• Conflicker worm(2008)• Wannacry (2017)• Petya(2016)
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 44
MorrisWorm
• WrittenbyRobertMorristohighlightsecurityflawsoftheinternet• Wasnotmeanttobeanactualattack• Worminfectssamecomputermultiple times,causingaforkbomb• Resultinginadenialofserviceattack
• SpreadthroughtheUSandtookdowntheentireinternet• Funtrivia:“TheWormBeforeChristmas”
K.Chan:CSE435:SoftwareEngineering
Bots
• Usuallycreatedfromaworm• Acompromised computer• Botnet:anetworkofcompromised computers• Attackcansendcommandstothem
• Example:conflicker worm• Infectsacomputer• Computer thentakescommandsfromsomecentrallocation• 10,500,000+infected(source)
K.Chan:CSE435:SoftwareEngineering
11/26/19
K.Chan:CSE435:SoftwareEngineering 45
Keytakeaways
• Securityshould beconsidered asanintegralpartofyoursystem• Itshouldbeapartofyourdesigndocument
• Donotwaituntilyouhavebeencompromised• Stayvigilantandlookoutforpossible attacks• Expecttheunexpected!• Wedesignprogramsforthemajorityofuser.Thisistotallyvalid• Butthe“edgecases”isoftenavulnerability
• Knowhowtostorepasswords• Whatisthedifferencebetweenasaltandpepper?• Whydoweusesaltandpepper?
K.Chan:CSE435:SoftwareEngineering
Keytakeaways(cont.)
• ALLINPUTSAREEVIL!• Username:youexpectusertotypeinlegitusernames
• Trueformostofthetime• ButSQLinjection attacksrelyoninputting different inputs
• KnowwhatSQLi attacksareandhowtopreventthem!• Thisisimportant,youcangetinlegaltroubleifsoftwareyouwroteisleftvulnerabletoattacks.
• Whatdoes encryptingamessagewithaprivatekeyensure?• Encryptingwithapublickey?
• Ifyouneedtouseencryption,AESandRSAarethecurrentstandards
K.Chan:CSE435:SoftwareEngineering
Top Related