l string analysis - uc santa barbara
TRANSCRIPT
![Page 1: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/1.jpg)
![Page 2: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/2.jpg)
l Givenastringmanipulatingprogram,stringanalysisdeterminesallpossiblevaluesthatastringexpressioncantakeduringanyprogramexecution
l Usingstringanalysiswecanverifypropertiesofstringmanipulatingprogramsl Forexample,wecanidentifyallpossibleinputvaluesof
sensitivefunctionsinawebapplicationandthencheckwhetherinputsofsensitivefunctionscancontainattackstrings
![Page 3: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/3.jpg)
¡ Configurations/Transitionsarerepresentedusingwordequations
¡ Wordequationsarerepresented/approximatedusing(aligned)multi-trackDFAswhichareclosedunderintersection,union,complementandprojection
¡ Operationsrequiredforreachabilityanalysis(suchasequivalencechecking)arecomputedonDFAs
![Page 4: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/4.jpg)
¡ LetX(thefirsttrack),Y(thesecondtrack),betwostringvariables
¡ λ:apaddingsymbolthatappearsonlyonthetailofeachtrack(aligned)
¡ Amulti-trackautomatonthatencodesX=Y.txt
(a,a), (b,b) …
(t, λ) (x, λ) (t, λ)
![Page 5: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/5.jpg)
¡ Computethepost-conditionsofstatementsGivenamulti-trackautomataMandanassignmentstatement:X:=sexpPost(M,X:=sexp)denotesthepost-conditionofX:=sexpwithrespecttoM
Post(M,X:=sexp)=(∃X,M∩CONSTRUCT(X’=sexp,+))[X/X’]
![Page 6: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/6.jpg)
¡ Weimplementasymbolicforwardreachabilitycomputationusingthepost-conditionoperations
¡ Theforwardfixpointcomputationisnotguaranteedtoconvergeinthepresenceofloopsandrecursion
¡ Weuseanautomatabasedwideningoperationtoover-approximatethefixpoint§ Wideningoperationover-approximatestheunionoperationsandacceleratestheconvergenceofthefixpointcomputation
![Page 7: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/7.jpg)
¡ Thealphabetofann-trackautomatonisΣn
§ Thesizeofmulti-trackautomatacouldbehugeduringcomputations
§ Ontheotherhand,wemaycarrymoreinformationthanweneedtoverifytheproperty
¡ MoreAbstractions:§ WeproposealphabetabstractiontoreduceΣ§ Weproposerelationabstractiontoreducen
![Page 8: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/8.jpg)
¡ Selectasubsetofalphabetcharacters(Σ’)toanalyzedistinctlyandmergetheremainingalphabetcharactersintoaspecialsymbol(u)
¡ Forexample:LetΣ={<,a,b,c}andΣ’={<},L(M)=a<b+,
wehave:αΣ,Σ’(M)=Mα
andγΣ,Σ’(Mα)=Mγ,whereL(Mα)=u<u+,andL(Mγ)=(a|b|c)<(a|b|c)+
![Page 9: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/9.jpg)
¡ WeuseanalphabettransducerMΣ,Σ’toconstructabstractautomata§ αdenotesanycharacterinΣ’§ βdenotesanycharacterinΣ\Σ’
(β,u)
(α,α)
(λ,λ)
(λ,λ)
![Page 10: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/10.jpg)
b a b <
(a,u), (b,u), (c,u)
(<,<)
(λ,λ)
(λ,λ)
(b,*) (a,*) (b,*) (<,*)
u u u <
(b,u) (a,u) (b,u) (<,<)
α
M Mα
MΣ,Σ’
![Page 11: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/11.jpg)
a,b,c a,b,c a,b,c <
(a,u), (b,u), (c,u)
(<,<)
(λ,λ)
(λ,λ)
(a,u), (b,u), (c,u) (<,<)
u u u <
(*,u) (*,u) (*,u) (*,<)
MγMα
MΣ,Σ’
(a,u), (b,u), (c,u)
(a,u), (b,u), (c,u)
γ
![Page 12: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/12.jpg)
1:<?php 2: $www = $_GET[”www”]; 3: $l_otherinfo = ”URL”; 4: $www = str_replace(<,””,$www); 5: echo ”<td>” . $l_otherinfo . ”: ” . $www . ”</td>”;
6:?>
¡ Considertheaboveexample,choosingΣ’={<,s}(insteadofallASCIIcharacters)issufficienttoconcludethattheechostringdoesnotcontainanysubstringthatmatches“<script”
![Page 13: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/13.jpg)
¡ Considerthefollowingabstraction:Wemapallthesymbolsinthealphabettoasinglesymbol
¡ Theautomatonwegeneratewiththisabstractionwillbeaunaryautomaton(anautomatonwithaunaryalphabet)
¡ Theonlyinformationthatthisautomatonwillgiveuswillbethelengthofthestrings
¡ Soalphabetabstractioncorrespondstolengthabstraction
![Page 14: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/14.jpg)
¡ Selectsetsofstringvariablestoanalyzerelationally(usingmulti-trackautomata),andanalyzetherestindependently(usingsingle-trackautomata)
Forexample,considerthreestringvariablesn1,n2,n3.¡ Letχ={{n1,n2},n3}andχ’={{n1},{n2},{n3}}¡ LetM={M1,2,M3}thatconsistsofa2-trackautomaton
forn1andn2andasingletrackautomatonforn3¡ Wehave αχ,χ’(M)=Mα
γχ,χ’(Mα)=Mγ,where
![Page 15: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/15.jpg)
¡ Mα={M1,M2,M3}suchthatM1andM2areconstructedbytheprojectionofM1,2tothefirsttrackandthesecondtrackrespectively
¡ MΥ={M’1,2,M3}suchthatM’1,2isconstructedbytheintersectionofM1,*andM*,2,where§ M1,*isthetwo-trackautomatonextendedfromM1witharbitraryvaluesinthesecondtrack
§ M*,2isthetwo-trackautomatonextendedfromM2witharbitraryvaluesinthefirsttrack
![Page 16: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/16.jpg)
(a,a)
(b,b) (c,c)
a
b
c
(a,*)
(b,*) (c,*)
(*,a)
(*,b) (*,c)
(a,a)
(b,b) (c,c)
(b,a)
(a,b)
M1,2 M1,M2
M1,*
M*,2
M’1,2
α
γ
![Page 17: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/17.jpg)
1:<?php 2: $usr = $_GET[“usr”]; 3: $passwd = $_GET[“passwd”]; 4: $key = $usr.$passwd; 5: if($key = “admin1234”) 6: echo $usr; 7:?>
¡ Considertheaboveexample,choosingχ’={{$usr,$key},{$passwd}}issufficienttoidentifytheechostringisaprefixof“admin1234”anddoesnotcontainanysubstringthatmatches“<script”
![Page 18: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/18.jpg)
¡ Bothalphabetandrelationabstractionsformabstractionlattices,whichallowdifferentlevelsofabstractions
¡ Combiningtheseabstractionsleadsaproductlattice,whereeachpointisanabstractionclassthatcorrespondstoaparticularalphabetabstractionandarelationabstraction§ Thetopisanonrelationalanalysisusingunaryalphabet§ Thebottomisacompleterelationalanalysisusingfullalphabet
![Page 19: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/19.jpg)
( ȤŎ , ıŎ )
( ȤŎ , ıŏ )( Ȥŏ , ıŎ )
( Ȥŏ , ıŏ )
size analysis
relationalsize analysis
string analysis
relationalstring analysis
. . .
Someabstractionfromtheabstractionlatticeandthecorrespondinganalyses
![Page 20: l string analysis - UC Santa Barbara](https://reader034.vdocuments.us/reader034/viewer/2022050512/6271cc32fbe8123f5a102688/html5/thumbnails/20.jpg)
¡ Selectanabstractionclass§ Ideally,thechoiceshouldbeasabstractaspossiblewhileremainingpreciseenoughtoprovethepropertyinquestion
¡ Heuristics§ Letthepropertyguidethechoice§ Collectconstantsandrelationsfromassertionsandtheirdependencygraphs▪ Itformsthelowerboundoftheabstractionclass▪ Selectaninitialabstractionclass,e.g.,charactersandrelationsappearinginassertions
▪ Refinetheabstractionclasstowardthelowerbound