The Seven Turrets of Babel: Parser anti-patterns & how to expunge them
Sergey Bratus with Falcon Momot Sven Hallberg Meredith L. Patterson
The Seven Turrets of Babel: Parser anti-patterns & how to - - PowerPoint PPT Presentation
The Seven Turrets of Babel: Parser anti-patterns & how to expunge them Sergey Bratus with Falcon Momot Sven Hallberg Meredith L. Patterson Economics Pen test, code audit "2+2" : 2 persons, 2 weeks Attackers have
Sergey Bratus with Falcon Momot Sven Hallberg Meredith L. Patterson
weakness is evident
practices is more helpful than proof of exploitability
code / data format design:
input validation" etc.
2009$CWE/SANS$Top$25$ 2010$CWE/SANS$Top$25$ 2011$CWE/SANS$Top$25$ (and$s6ll$current)$
SQL, and web contexts (CWE-{78,79,89})
design, not description of one.
for security". But what does it mean?
running valid C on your system is not safe!
active, must be made "inert" to be safe
very hard, unless they are very simple.
can be verified
complete programs can't be verified
automatically verified
"Data format is code's destiny" "Everything is an interpreter (=parser)" "Every sufficiently complex input processor is indistinguishable from a VM running inputs as bytecode"
"trouble"/ weakness
Your program is a CPU/VM for adversary-controlled inputs You must prevent run-away computation (a.k.a. exploit) You must formulate & verify assumptions Even strict C.A.R. Hoare-style verification is brittle if any assumptions are violated
"Failure to communicate assumptions to interacting modules" P {M1 } R P' {M2} R' P'' {M3} R'' P''' {M4} R'''
Is the P { Q } R chain like this:
Input&
Processing:&&
no&raw&inputs&& &
Recognizer& for&input& language& Language grammar& Spec& Reject&& invalid& inputs& Only&valid/expected&inputs,& semanCc&acCons&past&this&line&
handing
invalid input
Christopher Ulrich, "Alchemy"
and spread across processing code
considered fully checked & safe to operate on
checked & which have been checked
SSL3_RECORD
HeartbeatMessage
hbtype payload
computation on my program?"
"regular or context-free, syntactically valid == safe"
complexity (Chomsky hierarchy)
Turing-complete inputs. Don't even try!
consume input, validate it (correctly) & deserialize it
create well-typed objects
handling code (even if "sanitized")
given away to attacker
Egor Homakov ("Don't let YAML.load close to any user input"), ...
parameter to a string before passing it to Active Record"
CVE-2014-6271, CVE-2014-6277, CVE-2014-6278, CVE-2014-7169, CVE-2014-7186, CVE-2014-7187
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self- contained-tags
message is
CA sees (and signs) a different CN in CSR than client in the signed cert
different package structure than C++ installer (~signed vs unsigned ints in zipped stream)
(must deal with complexity of unzip before validating!)
P {Q} R chain of assumptions & checks breaks
is involved
computational behavior on your system.
become a part of the attacker's exploit machine
Don't give the attacker any of it.
handing
invalid input
Christopher Ulrich, "Alchemy"
"The Seven Turrets of Babel: A Taxonomy of LangSec Errors and How to Expunge Them",
Falcon Darkstar Momot, Sergey Bratus, Sven M. Hallberg, Meredith L. Patterson, in IEEE SecDev 2016, Nov. 2016, Boston
http://langsec.org/papers/langsec-cwes- secdev2016.pdf
Input&
Processing:&&
no&raw&inputs&& &
Recognizer& for&input& language& Language grammar& Spec& Reject&& invalid& inputs& Only&valid/expected&inputs,& semanCc&acCons&past&this&line&
4th IEEE Security & Privacy LangSec Workshop May 25, 2017 San Jose, CA http://spw17.langsec.org http://langsec.org Join us for