Towards ¡improving ¡
So=ware ¡Security ¡
using ¡Language ¡Engineering ¡and ¡mbeddr ¡ ¡
So=ware Security using Language Engineering and mbeddr - - PowerPoint PPT Presentation
Towards improving So=ware Security using Language Engineering and mbeddr Markus Vlter, Zaur Molotnikov, Bernd Kolb voelter@acm.org www.voelter.de @markusvoelter
Towards ¡improving ¡
So=ware ¡Security ¡
using ¡Language ¡Engineering ¡and ¡mbeddr ¡ ¡
So=ware ¡ Security ¡
So=ware ¡security ¡refers ¡to ¡the ¡ security ¡proper8es ¡of ¡a ¡so9-‑ ¡ ware ¡system’s ¡implementa8on. ¡ ¡
¡
So=ware ¡security ¡
Techniques ¡ Process ¡ Programming ¡Language ¡ (and ¡the ¡wrong ¡use ¡of ¡it) ¡So=ware ¡security ¡
Techniques ¡ Process ¡ Programming ¡Language ¡So=ware ¡security ¡
Techniques ¡ Process ¡ Programming ¡Language ¡So=ware ¡security ¡
Techniques ¡ Process ¡Language ¡ Engineering ¡
Language ¡ Workbenches ¡
JetBrains ¡ ¡ MPS ¡
A ¡Language ¡Workbench ¡– ¡
a ¡tool ¡for ¡defining, ¡composing ¡ and ¡using ¡ecosystems ¡of ¡languages. ¡
Open ¡Source ¡ Apache ¡2.0 ¡ hMp://jetbrains.com/mps ¡
V ¡3.2 ¡ ¡ ¡ ¡ ¡ ¡is ¡current. ¡ V ¡3.3 ¡ ¡ ¡ ¡ ¡ ¡in ¡RC ¡– ¡Release ¡Q4 ¡2015. ¡
[Language ¡Workbench] ¡
+ Refactorings, Find Usages, Syntax Coloring, Debugging, ...Comprehensive ¡Support ¡for ¡ ¡ many ¡aspects ¡of ¡Language ¡DefiniJon. ¡
[Comprehensive ¡IDE ¡Features] ¡
For ¡End ¡Users ¡and ¡Language ¡Developers ¡
MPS ¡uses ¡a ¡ProjecJonal ¡Editor ¡
[ProjecJonal ¡EdiJng] ¡
A ¡ProjecJonal ¡Editor ¡modifies ¡the ¡AST ¡directly. ¡ No ¡grammars ¡or ¡parsers ¡are ¡involved. ¡Advantage: ¡SyntacJc ¡Flexibility ¡
[ProjecJonal ¡EdiJng] ¡
Advantage: ¡SyntacJc ¡Flexibility ¡/ ¡MPS ¡
[ProjecJonal ¡EdiJng] ¡
Advantage: ¡Language ¡ComposiJon ¡
[ProjecJonal ¡EdiJng] ¡
5+ ¡ ¡ ¡base ¡languages ¡ 50+ ¡extensions ¡to ¡C ¡ 10+ ¡extensions ¡to ¡requirements ¡lang. ¡Advantage: ¡Language ¡ComposiJon ¡
[ProjecJonal ¡EdiJng] ¡
L2 ¡ L1 ¡ in ¡order ¡to ¡use ¡them ¡together. ¡LHost ¡ LEmb ¡
+ ¡
Embedding ¡= ¡
LAdapt ¡ + ¡ LBase ¡ LExt ¡
+ ¡
Extension ¡= ¡
LBase ¡ LExt1 ¡
+ ¡
Extension ¡ComposiJon ¡= ¡
LExt2 ¡
+ ¡
Study ¡Results ¡on ¡Editor ¡Usability ¡
[ProjecJonal ¡EdiJng] ¡
Strongly ¡... ¡Neutral ¡... ¡Strongly ¡ agree ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡disagree ¡ People ¡prefer ¡MPS ¡over ¡convenJonal ¡IDEs ¡ MPS ¡more ¡is ¡more ¡efficient ¡than ¡normal ¡IDEs ¡ MPS ¡more ¡is ¡more ¡producJve ¡than ¡normal ¡IDEs ¡ MPS ¡makes ¡it ¡easier ¡to ¡create ¡correct ¡programs ¡ MPS ¡enforces ¡a ¡structurally ¡correct ¡AST ¡ People ¡benefit ¡from ¡language ¡modularity ¡ People ¡benefit ¡from ¡the ¡flexible ¡notaJons ¡ People ¡benefit ¡from ¡advanced ¡navigaJon ¡support ¡ The ¡experience ¡with ¡learning ¡MPS ¡is ¡mixed. ¡ It ¡takes ¡some ¡Jme ¡to ¡get ¡used ¡to ¡MPS ¡Further ¡Reading ¡
ProjecJng ¡a ¡Modular ¡Future ¡ Three ¡different ¡case ¡studies ¡of ¡using ¡MPS ¡ hRp://voelter.de/data/pub/projec8ngModuleFuture.pdf ¡ mbeddr ¡-‑-‑ ¡InstanJaJng ¡a ¡Language ¡Workbench ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡in ¡the ¡Embedded ¡So=ware ¡Domain ¡ ¡ Detailed ¡Discussion ¡of ¡mbeddr ¡(using ¡MPS ¡for ¡embedded ¡s/w ¡engineering) ¡ hRp://voelter.de/data/pub/voelteretal-‑mbeddr-‑AUSE.pdf ¡ Towards ¡User-‑Friendly ¡ProjecJonal ¡Editors ¡ Study ¡about ¡the ¡usability ¡of ¡projec8onal ¡editors ¡and ¡MPS‘ ¡„tricks“ ¡for ¡improving ¡it ¡ hRp://voelter.de/data/pub/projec8onalEdi8ng-‑sle2014.pdf ¡ The ¡State ¡of ¡the ¡Art ¡in ¡Language ¡Workbenches ¡– ¡LWC ¡Conclusions ¡ Systema8c ¡Comparison ¡of ¡different ¡language ¡workbenches ¡and ¡their ¡features ¡ hRp://voelter.de/data/pub/LWC13.pdf ¡mbeddr ¡
Tools ¡ Language ¡ ¡ Engineering ¡ Embedded ¡ So=ware ¡
An ¡extensible ¡set ¡of ¡integrated ¡languages ¡ for ¡embedded ¡so=ware ¡engineering. ¡ ¡
Open ¡Source ¡@ ¡eclipse.org ¡ Eclipse ¡Public ¡License ¡1.0 ¡ hMp://mbeddr.com ¡
developers ¡
7 ¡developers, ¡project ¡management ¡ 2 ¡developers, ¡verificaJon ¡support ¡ 1 ¡developer, ¡verificaJon ¡support ¡ 3 ¡developers, ¡C++ ¡ strategic ¡collaboraJon ¡with ¡Some ¡of ¡the ¡C ¡Extensions ¡
Units ¡ State ¡Machines ¡ Components ¡ ¡ Math ¡An ¡IDE ¡for ¡Requirements ¡
Requirements ¡ Rules ¡ Tracing ¡ VisualisaJons ¡Great ¡IDE ¡Support ¡
An ¡IDE ¡for ¡DocumentaJon ¡
SoluJon: ¡ Technique ¡
Code ¡Markup ¡and ¡Checking ¡ Robustness ¡ ¡ Security ¡ Layers ¡checking, ¡access ¡permissions ¡ „Units“ ¡for ¡saniJzed ¡or ¡encrypted ¡data ¡
Straighqorward ¡Language ¡Extensions ¡ Apple ¡GotoFail ¡bug: ¡ More ¡robust ¡construct: ¡
Straighqorward ¡Language ¡Extensions ¡ BeMer ¡than ¡macros: ¡
Amazon‘s ¡s2n ¡library ¡Danger: ¡ Macros ¡have ¡no ¡protecJon ¡against ¡ wrong ¡use; ¡Poor ¡man‘s ¡LE. ¡Real ¡LE ¡ ¡ is ¡more ¡robust/safer. ¡
AdapJng ¡SemanJcs ¡
When ¡leaving ¡the ¡funcJon, ¡k_clr ¡sJll ¡on ¡ the ¡stack ¡– ¡only ¡stack ¡pointer ¡moved. ¡ As ¡variables ¡leave ¡scope, ¡actually ¡wipe ¡ their ¡memory. ¡
BeMer: ¡
ExploiJng ¡the ¡GeneraJon ¡Step ¡ Timing ¡Side ¡Channel ¡AMacks: ¡ ¡ ¡ ¡ ¡Insert ¡random ¡waits. ¡
Amazon‘s ¡s2n ¡library ¡ Naming ¡convenJons ¡not ¡checkable. ¡ ¡ ¡ ¡ ¡SemanJc ¡AnnotaJons ¡beMer. ¡ ¡Then ¡insert ¡busy ¡wait ¡at ¡end ¡ enforce ¡constant ¡Jme. ¡
AddiJonal ¡Constraints ¡ Detect ¡insecure ¡C ¡funcJons: ¡ ¡ ¡ ¡ ¡ ¡strcpy ¡and ¡the ¡like. ¡ Mark ¡veMed ¡secure ¡funcJons ¡as ¡ SECURE ¡API ¡and ¡only ¡use ¡those. ¡ ¡Check ¡this ¡with ¡tool. ¡
VerificaJon ¡I ¡
Heartbleed ¡bug: ¡ The ¡above ¡code ¡is ¡invalid ¡in ¡C ¡
¡cannot ¡„dynamically“ ¡iniJalize ¡length. ¡Bug: ¡sizeof(payload) ¡!= ¡payload_length ¡
VerificaJon ¡II ¡
Find ¡Problem ¡via ¡formal ¡VerificaJon ¡
VerificaJon ¡III ¡
Even ¡beMer: ¡
First-‑class ¡message ¡concept ¡ ¡ that ¡handles ¡low ¡level ¡message ¡stuff. ¡SoluJon: ¡ Process ¡
BeMer ¡AbstracJon, ¡BeMer ¡Review ¡
This ¡is ¡beMer ¡than ¡a ¡switch-‑case: ¡
BeMer ¡NotaJon, ¡BeMer ¡Review ¡
Tracing ¡
Trace ¡from ¡every ¡program ¡element ¡to ¡requirements ¡ ¡ ¡ ¡(internal ¡or ¡external) ¡ ¡ Analyze ¡and ¡find ¡untraced ¡program ¡fragments. ¡ Different ¡kinds ¡of ¡traces ¡to ¡express ¡semanJcs. ¡Expressing ¡Security ¡Requirements ¡
Requirements ¡are ¡Prose, ¡plus ¡arbitrary ¡ formal ¡parts, ¡inline ¡in ¡the ¡document. ¡ Requirements ¡can ¡be ¡classified ¡as ¡secure. ¡
Different ¡review ¡policy, ¡cannot ¡be ¡changed ¡(see ¡next) ¡Code ¡Review ¡and ¡Security ¡Audits ¡
Track ¡review ¡state ¡in ¡the ¡code ¡ Assess ¡review ¡state ¡over ¡the ¡system: ¡
Code ¡Review ¡and ¡Security ¡Audits ¡
Track ¡review ¡state ¡in ¡the ¡code ¡ Assess ¡review ¡state ¡over ¡the ¡system: ¡
„Code“ ¡includes ¡requirements! ¡ Use ¡crypto ¡to ¡sign ¡the ¡review. ¡ Branching-‑safe, ¡because ¡in ¡the ¡code. ¡ Highlight ¡unreviewed ¡code. ¡ On ¡any ¡granularity. ¡ Can ¡be ¡exported ¡into ¡process-‑related ¡tools. ¡Discussion ¡
EvaluaJon ¡Looks ¡interes8ng, ¡real ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡evalua8on ¡is ¡s8ll ¡missing. ¡ Learning ¡Languages ¡have ¡to ¡be ¡learned. ¡ Developing ¡ ¡MPS ¡makes ¡this ¡very ¡simple. ¡ TrusJng ¡ ¡A ¡tool ¡qualifica8on ¡issue. ¡ Legacy ¡Code ¡Import ¡and ¡Refactor. ¡ Tool ¡Lock-‑in ¡Yes. ¡ Other ¡Languages ¡ ¡Works ¡in ¡Principle. ¡
s
r c e ¡
[Read ¡& ¡Learn] ¡
Thank you!
voelter@acm.org ¡ www.voelter.de ¡ @markusvoelter ¡