Applications of Symbolic Finite Automata
Margus Veanes
VSSE'14, Grenoble, France 1 April 5, 2014
Symbolic Finite Automata Margus Veanes April 5, 2014 VSSE'14, - - PowerPoint PPT Presentation
Applications of Symbolic Finite Automata Margus Veanes April 5, 2014 VSSE'14, Grenoble, France 1 Overview Are SFAs applicable to analysis of software evolution? automata modulo theories S ymbolic Finite Automaton (SFA) Main
VSSE'14, Grenoble, France 1 April 5, 2014
– Testing (unit, fuzz) – Regex processing – Web security – SMT theory plugin – backend for MSO
– look-ahead – trees – registers
April 5, 2014 VSSE'14, Grenoble, France 2
SFA with symbolic outputs automata modulo theories Boolean closed, succinct for large
April 5, 2014 VSSE'14, Grenoble, France 3
April 5, 2014 VSSE'14, Grenoble, France 4
April 5, 2014 VSSE'14, Grenoble, France 5
Prog.v1 = loop{t=now; critical_code; save(now-t)} Prog.v2 = loop{t=now; critical_code_upd; save(now-t)}
SFA1: 0-255 0-255 regex: [\0-\xFF]+ trace: [56,150,500] L(SFA1)
April 5, 2014 VSSE'14, Grenoble, France 6
'a' 'b' 'c' 'd'
7
even(x)
p q even(x)
1 2 5 3 p p q p p
April 5, 2014 VSSE'14, Grenoble, France
April 5, 2014 VSSE'14, Grenoble, France 8
April 5, 2014 VSSE'14, Grenoble, France 9
April 5, 2014 VSSE'14, Grenoble, France 10
p q {a,b} {a} {b}
c
April 5, 2014 VSSE'14, Grenoble, France 11
April 5, 2014 VSSE'14, Grenoble, France 12
April 5, 2014 VSSE'14, Grenoble, France 13
April 5, 2014 VSSE'14, Grenoble, France 14
April 5, 2014 VSSE'14, Grenoble, France 15
April 5, 2014 VSSE'14, Grenoble, France 16
April 5, 2014 VSSE'14, Grenoble, France 17
April 5, 2014 VSSE'14, Grenoble, France 18
Concrete transitions: p q Symbolic transition: ‘\x80’/ “\xC2\x80” … ‘\x7FF’/ “\xDF\xBF” q p x. 8016 ≤ x ≤ 7FF16/ [C016|x10,6, 8016|x5,0] guard bitvector
1920 transitions
VSSE'14, Grenoble, France 19 April 5, 2014
20
even(x)/[x, x]
p q even(x)/[]
1 2 5 3 p p q p p Input tape Output tape 2 2 4 2
April 5, 2014 VSSE'14, Grenoble, France
April 5, 2014 VSSE'14, Grenoble, France 21
– s is a string of Unicode characters (16-bit bit-vectors)
April 5, 2014 VSSE'14, Grenoble, France 23
bool IsValidEmail(string s) { string r1 = @"^[A-Za-z0-9]+@(([A-Za-z0-9\-])+\.)+([A-Za-z\-])+$"; string r2 = @"^\d.*$"; if (System.Text.RegularExpressions.Regex.IsMatch(s, r1)) if (System.Text.RegularExpressions.Regex.IsMatch(s, r2)) return false; //branch 1 else return true; //branch 2 else return false; //branch 3 }
Solve: sL(r1)L(r2) [eg. s = “3@a.b”] Solve: sL(r1)\L(r2) [eg. s = “a@b.c”] Solve: sL(r1) [eg. s = “a@..c”]
April 5, 2014 VSSE'14, Grenoble, France 24
req = http://www.x.com/%c0%ae%c0%ae/%c0%ae%c0%ae/private/
Windows 2000 vulnerability: http://www.sans.org/security-resources/malwarefaq/wnt-unicode.php Apache Tomcat vulnerability: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2008-2938
1) security check: req must not contain "../" 2) dir = utf8decode("%c0%ae %c0%ae/%c0%ae%c 0%ae/private/") = "../../private/"
access granted to "../../private/" Analysis question: Does utf8decode reject overlong utf8-encodings such as "%C0%AE" for '.'?
VSSE'14, Grenoble, France 25 April 5, 2014
Accepts “../../” Rejects “..%C0%AF../” p q x. 8016 ≤ x ≤ BF16 x. C216 ≤ x ≤ DF16 x. 0 ≤ x ≤ 7F16
VSSE'14, Grenoble, France 26 April 5, 2014
VSSE'14, Grenoble, France 27 April 5, 2014
April 5, 2014 VSSE'14, Grenoble, France 28
April 5, 2014 VSSE'14, Grenoble, France 29
– Input: valid utf16 encoded string – Output: equivalent utf8 encoded string For example utf8encode(“\uFF28\uFF29”) = “\xEF\xBC\xA8\xEF\xBC\xA9” 5 states & 11 transitions
transducer has 216 transitions
VSSE'14, Grenoble, France 30 April 5, 2014
program smileycipher(w) { return iter(c in w) { case(true): yield(0xD83D,(c - 'a') + 0xDE00); }; }
http://www.rise4fun.com/Bek/ZH0
April 5, 2014 VSSE'14, Grenoble, France 31
April 5, 2014 VSSE'14, Grenoble, France 32
April 5, 2014 VSSE'14, Grenoble, France 33
“input string” A not idempotent A A A A A “input string” A and B not commutative B A B A A B A B
Does there exist an input x that causes a "cat" in the
http://www.rise4fun.com/Bek/nDx
April 5, 2014 VSSE'14, Grenoble, France 34
April 5, 2014 VSSE'14, Grenoble, France 35
VSSE'14, Grenoble, France 36 April 5, 2014