You are on page 1of 1

BufferOverflowAttack

Explainwhatismeantbya"BufferOverrunAttack".(ZubinsPart)
Abufferisaregioninacomputersmemorywithfixedboundaries.Example:An
arrayincisallocatedconsecutiveblocksofmemory.Boundariesbeingfirstand
lastvalues.Nowassumingthatthesizeofintegeris4bytes,thetotalbuffersizeof
arris10*4=40bytes.(Iwillshowhowanarrayisstoredinmemory)
Overflowoccurswhendataiswrittentoeithersideofthebufferboundary.Ie
memorythatdoesnotbelongtothevariablecurrentlybeingused.Example:(I
willshowwhatitlookslikewhenananarrayiswrittenpastboundary)
Overflowscancausecrashesorunexpectedresults.Example:(Iwillusea
whiteboardexampleusingapasswordprogram)

Whatkindofcodeissusceptibletosuchanattack?(PhilsPart)
Cisverysusceptibletobufferoverflowattackssincecallowsdirectpointer
manipulationswithoutboundschecking.Thisisduetothefactthatperformance
wasmoreimportantthansafetyinC
Codecontainingarrays
Codeusingfunctions:gets,scanf,strcpy,strcat,sprintf(thesearen'tbounds
checked)(Maybewriteatableonwhiteboardwiththeequivalentsafefunctions?
seebelowforsafefunctionequivalents*)
Howcanyourewriteyourcodetoprotectitfromthisthreat?(PhilsPart)
Replacefunctionswithstrncpy,strncat,snprintf,fgets(*)
Ensurethatwhenwritingtoarraysyoucheckthatdataisbeingwrittenwithin
bounds.

You might also like