Infor­ma­ti­on secu­ri­ty has ente­red ever­y­day life. Many are now fami­li­ar with tech­ni­ques such as two-fac­tor authen­ti­ca­ti­on, encryp­ti­on and soft­ware updates thanks to the devices and social media plat­forms they use. When it comes to the innards — that is, secu­re design — many ques­ti­ons remain. What goes on in modern pro­ces­sors the­se days is dif­fi­cult to express in a few words. Ever­yo­ne is tal­king about the Melt­down and Spect­re bugs, but you need a lot of pri­or know­ledge to under­stand what exact­ly is hap­pe­ning. In addi­ti­on, the­re is the code that does the work for devices such as gra­phics cards or net­work cards in the firm­ware, vir­tual­ly under the ope­ra­ting sys­tem. If you now want to deve­lop an appli­ca­ti­on, the fol­lo­wing ques­ti­on ari­ses: How can you keep track of the lar­ge num­ber of com­pon­ents and pro­gram secu­re­ly? Secu­re coding, i.e. secu­re pro­gramming tech­ni­ques, alo­ne only helps with one’s own code. The ans­wer lies in the archi­tec­tu­re of the whole.

The struc­tu­re is decisi­ve in secu­re design

An appli­ca­ti­on never starts with code. It always starts with a design and a descrip­ti­on of the tasks that an appli­ca­ti­on should per­form. This pha­se is the most cri­ti­cal part in soft­ware deve­lo­p­ment, becau­se decis­i­ons made here usual­ly deter­mi­ne the future of the pro­ject. In par­ti­cu­lar, this means that the basis for the later infor­ma­ti­on secu­ri­ty of the code is made at this point. For exam­p­le, the sel­ec­tion of com­pon­ents, the pro­to­cols used, neces­sa­ry con­di­ti­ons (such as cryp­to­gra­phic keys, net­work and sto­rage requi­re­ments, etc.), and com­mu­ni­ca­ti­on with third-par­ty ven­dors are estab­lished in the design pha­se. So what does Secu­re Design mean in this context?

Secu­re Design con­sists of a set of fun­da­men­tals that are obser­ved at every point in the soft­ware pro­ject. You try to mini­mi­ze the attack sur­face of the code, use secu­re defaults ever­y­whe­re, dis­tri­bu­te as few per­mis­si­ons as pos­si­ble to accounts/components, build secu­ri­ty checks into all lay­ers, catch bugs secu­re­ly, don’t trust third-par­ty ser­vices, and sepa­ra­te tasks in the code. The appli­ca­ti­on must be able to work relia­bly in any envi­ron­ment wit­hout expo­sing vul­nerabi­li­ties. Pro­ces­sed data must be con­stant­ly che­cked for inte­gri­ty. This also appli­es to inter­nal pro­ces­ses such as com­mu­ni­ca­ti­on with a data­ba­se or other parts. Deve­lo­pers and code must at no time make assump­ti­ons that an attack could nega­te. This includes soft­ware libra­ri­es and capa­bi­li­ties of hard­ware or ope­ra­ting sys­tems. This includes the cha­rac­te­ristics of pro­ces­sors that cau­sed the class of Melt­down and Spect­re bugs.

Of cour­se, one should not be grip­ped by para­noia now and give up all the fea­tures of the plat­form. After all, one is sup­po­sed to reu­se code and not always reinvent the boat (the boat is older than the wheel). It’s always about assump­ti­ons you make when you pro­gram. The XML input may not be XML. The cloud ser­vice respon­se may not be from the assu­med source or may just be wrong. The data you pre­vious­ly wro­te to the data­ba­se may now be wrong (becau­se the­re was an attack). Modern code is full of assump­ti­ons. It gets exci­ting when the­se are not true.

Mathe­ma­ti­cal pro­ofs for secu­re coding

One way to avo­id ambi­gui­ty in spe­ci­fi­ca­ti­ons is to use mathe­ma­tics. Sin­ce code comes from com­pu­ter sci­ence and com­pu­ter sci­ence is a branch of mathe­ma­tics, pro­ces­ses can be repre­sen­ted mathe­ma­ti­cal­ly. If one trans­la­tes now tasks from the design docu­ments into a mathe­ma­ti­cal lan­guage, then one can repre­sent and pro­ve with the help of tools pro­ces­ses in the code mathe­ma­ti­zed. If this is achie­ved, one is lite­ral­ly on the safe side. In addi­ti­on, one eli­mi­na­tes unclear for­mu­la­ti­ons, which in turn helps the developers.

For­ma­lisms are also a part of Secu­re Design.

Data-based deve­lo­p­ment ≠ Data­ba­se development

So how do you imple­ment secu­re design? Sin­ce you are always deal­ing with data, you can start with them. After all, the appli­ca­ti­on should be able to hand­le errors secu­re­ly. This means that not­hing cri­ti­cal should hap­pen when non­sen­si­cal or mani­pu­la­ted data is ente­red. One tac­tic is the­r­e­fo­re to feed the soft­ware with ran­dom­ly gene­ra­ted or mani­pu­la­ted data and see what hap­pens. Ulti­m­ate­ly, this is the test case stra­tegy one often has in deve­lo­p­ment to avo­id fin­ding fixed bugs back in the code. The tech­ni­que for trip­ping up sys­tems with ran­dom data is cal­led fuz­zing. The­re are many tools for this, some of which are alre­a­dy available for deve­lo­p­ment tools. The com­bi­na­ti­on of ran­dom data and real data works best, so you can get over the first check. After all, you want to test all the code.

Ope­ra­ting sys­tem ven­dors or teams deve­lo­ping cri­ti­cal soft­ware alre­a­dy use this approach.

Chan­ge the habits!

Infor­ma­ti­on secu­ri­ty rises and falls with ever­y­day habits. Any­thing that needs to be actively con­side­red will go wrong soo­ner or later. Of cour­se, the same is true for soft­ware deve­lo­p­ment. For this reason, secu­re design and secu­re coding must be incor­po­ra­ted into one’s own pro­ces­ses in appro­pria­te steps. Unfort­u­na­te­ly, this can­not be done by rea­ding docu­men­ta­ti­on or ins­truc­tions alo­ne. It is recom­men­ded to imple­ment it in par­ti­al steps, accom­pa­nied by a work­shop for all deve­lo­pers. The­re is ple­nty of mate­ri­al to illus­tra­te this, becau­se stu­dy­ing known errors crea­tes prac­ti­cal rele­van­ce and helps to ques­ti­on one’s own code.

About René Pfeiffer

René Pfeif­fer has been working as a seni­or secu­ri­ty con­sul­tant for SEC4YOU sin­ce 2009. In addi­ti­on to his self-employ­ed work, he is the mana­ging direc­tor of Deep­Sec GmbH and has been orga­ni­zing DEEPSEC for over 10 years. Through the use of reco­gni­zed methods and his affi­ni­ty for IT secu­ri­ty and Linux, he has had the pri­vi­le­ge of advi­sing count­less cus­to­mers in the sec­tors of indus­try, avia­ti­on, tele­com­mu­ni­ca­ti­ons, uti­li­ties, phar­maceu­ti­cals, health­ca­re, adver­ti­sing, law firms, NGOs, media, logi­stics and soft­ware deve­lo­p­ment on secu­ri­ty issues.

Plea­se ask René Pfeif­fer about Secu­re Design — Secu­re Coding using our cont­act form.