welcome to Frank's Diana explains today's topic is the first lecture in my new course on cyber security at the University of Cambridge I'm opening my class to the entire world by putting these recordings on YouTube and you are most welcome to join us even if you're not one of my Cambridge students if you are willing to engage with the course as intensely as my students who are going to be examining this material in June if you are willing to put in the work of studying textbook and do the exercises you will have exactly the same
opportunities as a Cambridge student to become competent and computer security this course is for all computer scientists Not Just for future security Specialists it consists of foundational material that should be an essential part of the training of every computer professional many spectacular security incidents were made possible by vulnerabilities introduced in the software by developers without this basic training if all computer professionals learn to view the system they develop through the lens of adversarial thinking they would have a better understanding of how malicious actors can subvert and exploit their systems developers who have this awareness would
be more cautious when designing and implementing their systems and the Digital Society would be a safer place while redesigning the course I surveyed available textbooks and the one that best aligned with my vision and goals was this one self-published by Professor Kevin dear indeed very much Hands-On as the subtitle says just like I wanted and supported by a wealth of well-designed and pedagogically valid online resources the so-called seed Labs s-e-e-d security education I recommend this book and the seed Labs very highly besides the hands-on experience that's provided by the book and the seed Labs I
also want to give you some awareness of the bigger picture of security I thought that this book did not give you enough of that so I supplemented it with my own notes but my handout is not a substitute for the official course textbook and it does not attempt to duplicate what's already in the book so get the textbook it's a very good textbook it's very detailed and it's especially useful for people without prior security experience the seed labs are great each lab which in its context means exercise lets you practice a specific attack the lab
gives you a pre-configured virtual machine that exposes vulnerable services for you to attack in a controlled fashion as well as all the tools required to implement the attack you will use virtualbox to run these virtual machines and this requires a computer with an x86 processor which excludes the newer Max with apple silicon and also the Raspberry Pi's so either get yourself a cheap or free x86 box that someone is discarding for example a 10 year old one is still fine and that's what I use myself at home or use an in-cloud virtual machine as explained
on the seedlabs website either way ensure you can run the seedlabs virtual machine by the time the course starts please don't leave this until later when I do lecture live then at the end of the lecture there's always the keenest students who come and ask me clarifications and things that I just said now when I lecture on YouTube like no you can come and ask me questions in the comments and I will answer all the pertinent questions publicly so that future viewers may also benefit from my replies please leave feedback on the course in the
comments and with your like button that's also feedback signal and also if you are one of my Cambridge students leave feedback with the departmental feedback form I've been lecturing at Cambridge for a couple of decades now and the positive comments from the students who appreciate what I do are a very powerful motivator to keep on doing better I may not be able to please everyone all of the time but I do listen to all comments and I have implemented a number of suggestions and Improvement that were put forward by your predecessors on other courses the
core syllabus is on the official course web page the link is in the description and the biggest chapters are on software security including stuff like buffer overflow and SQL injection and also web and Internet Security including stuff like cross-site request forgery and cross-site scripting this course has by design a very strong practical orientation and my main objective is that people who graduate from this course are able to spot and exploit those vulnerabilities as opposed to just being able to talk and hand wave about them okay now with this parameters out of the way let's get
into it we live today in the 21st century in the Digital Society and everything we do is mediated by computers so it makes sense that cyber security has grown to a very significant role anything we rely on e-commerce banking the power grid other critical infrastructure the internet itself your digital medical records your private correspondence all the stuff and more needs to be protected against malicious attackers and the worldwide Global demand for cyber security Specialists largely outstrips the available supply of competent people industry as a whole needs to be more involved because we need to address
the skills gap which everybody's been recently talking about you know by 2022 is potentially 1.8 million shortfall in the industry that's a lot of people so we need to attract people to this type of career but as I said this Cambridge security course is not aimed merely at people who will make security their career every developer every computer person needs to write software with an awareness that as soon as their system is deployed there will be malicious actors who will try to book holes in it for nefarious purposes so I believe that some basic security
education should be part of the curriculum of every computer scientist whatever their specialism and this is what I'm doing here this course will be quite challenging but he will also be fascinating Security in essence is about outsmarting intelligent adversaries and this intelligent adversaries could strike anywhere any part of the system you design and build could become a Target your devious adversaries will prove your system for weaknesses and they will look for the part that they find easiest to attack maybe because it's the one that you've done the most mistakes in maybe because it's the one
that they know best about and so on and so on in any case that part of the day will decide to attack might not be the part that you know or understand the best so one reason why this course may be more challenging than others in the computer science drivers is because this course requires you to acquire some background knowledge in many seemingly unrelated topics Computing is a very complex field and noticing that human being not even during a world winner is able to understand a computer completely absolutely from top to bottom nobody can understand
everything about how a computer works at all the levels from the protocol messages that are exchanged between the web browser and the web server to the structure of the application program the operating system calls the inside of the device drivers the machine code that's executed by the processor the circuitry that makes up the fiscal Hardware the device physics of how the transistors work and so on and so on level understands all these levels there are people who specialize in one level there are people who understand a few of Jason lives nobody understands the whole thing
as computer scientists we dominate this complexity by using abstraction and we've been teaching that to you from your uh very first term of your first year you know is abstraction to dominate complexity when we focus on one layer of this technology stack then we take a simplified view of everything that happens underneath it and in general that's a very good approach however in security we can't always afford this luxury and convenience of simplifying the stuff below us so here's an example from stuff we're going to do later on in the course in Greater detail imagine
there is a program that in its infinite kindness sends your presence of either 5 or 10 pounds depending on the flip of a cone here's the electronic version of flipping the coin you just draw a random number and you check if it's even or odd and if it's um odd then the reward is five pounds if it's even the reward is 10 pounds okay and here's where you get the reward congratulations blah I'll send you blah blah uh pounds to blah blah blah where this first block is your name and the second black is your
sort code and bank account which you have supplied as an input to this program you notice here that this program defines three variables name which is a string of characters which holds your name and then reward which is an integer which holds the number of bounds that are going to be paid out to you and then pay Yi which is another string of character which will hold your sort code and account number which are the UK banking coordinates and so if you run the program it will ask you for some input and the interaction might
look something like this so uh the program ask print what's your name your name and your reply honest Joe and it sticks that into the variable name then it asks your source code and bank account and then it puts your input into the payee variable and then it outputs congratulations honest Joe I'll send 10 because 10 is what came out of the flip of the coin uh 10 pounds to this bank account that you supplied okay very nice so you will notice that the program only lets you write to two variables the name with this
function calling here and the payee with this other function Point here the program does not ask you how much you want to be paid it decides that for itself in this other part of the code so despite the fact that the program doesn't ask for your input on how much you should be paid a devious attacker might find ways to increase the reward just by crafting suitable inputs for the name and the payee that it is being asked about over here and over here can you see how they might do that if you think you
can then why don't you test your assumptions by stopping the video now try compiling this program and checking whether your hunt actually works whether you can make the program uh put something other than five or ten by doing whatever it is that you think it could be stop the video and come back when you have tried you'll have to return this program for it okay all right you're back I assume very few of you will have actually tried I still urge you to try but I won't insist anyway we'll review this problem in Greater detail
in a future lecture but what we'll say for now is that at the level of abstraction of the C source code there are really no further assignments to the reward variable after this line over here no nothing rights to reward and so there should be absolutely no way that the content of this variable gets modified after here it should remain at the whatever he got out of this if statement is either 5 or 10. so uh how can an attacker overwrite this reward variable after this line here if no assignment to reward exists in the
program well to even acknowledge that this is possible we cannot look at the level on the C language we must we must look below that extraction layer that is provided by C and look at what happens at the level of the compiled program so only at that point we can understand that okay actually it is possible for the attacker to write a long string into one variable and have it over spill into another adjacent variable somewhat some in somebody breaks the rules of the abstraction layer of the sea language and yeah and I'm saying for
example another adjacent variable but they look adjacent in these variables look adjacent in the source code here and so you could imagine okay well I write something to them and it splits over into here if the name is longer than these 20 characters that have been allocated but there's nothing in the program that tells the compiler that you should first allocate this variable and then this variable and then this variable the compile is free to put them wherever it feeds like so this is all stuff that is beyond what that's extraction level of the C
language says okay so even just to understand what the attacker is doing we must now become somewhat proficient not only in the C programming language that we were using to to write the program but also in lower level data is about how the compiler allocates the data structures of our program into memory how the high level uh high-level language statements translate into machine language and so on and so forth and that is just to explain an attack that some adversary already came up with after they noticed that there was a vulnerability after they noticed that
okay I might spill over from one variable into another even greater Ingenuity than that and greater background knowledge about other things is required for us to discover unknown vulnerabilities and anticipate possible new attacks so this is why Securities at the same time challenging and fascinating you're repeating your wits against the width of an intelligent opponent and to beat that opponent you must be at least it's not just a cleverness you must be at least as knowledgeable as them in the areas where the opponent is going to strike and you're not told in advance where those
target areas are so you must be willing to learn a lot a short notice about topics that might have nothing to do with your own special you might have to learn about Asim language how the operating system works how tcpip Works firewalls cryptography Digital Electronics even analog electronics for the matter and so on and so forth and if you have the happy mindset of an eternal learner then great it's going to be fun otherwise it's going to be a chore and it's going to be very difficult so to outsmart the attackers you have to learn
to think like them and you have to anticipate their moves and this requires a lot of creativity and lateral thinking and that's the fun part of security so when I talk about the systems being attacked uh with systems I don't mean simply computer systems rather I mean complex socio-technical systems which include computers and organizations and people who work in those organizations and some computer security attacks can be devastatingly effective even without really touching the technical part at all if these attacks actually Target a vulnerability in the social part of the social technical system so for
example one day I received a very worried phone call from someone that I hadn't heard from in a long while it's a Tradesman who had done work on my house a few years ago now he remembered that I was in the business of computer security and he needed some competent and trustworthy assistance about some serious problem that just happened to him so he told me in a rather embarrassed voice that his wife was an invalid and no longer sexually active and that was a problem for him and for that reason he kind of confessed to
me that he had been watching sexy videos on the internet okay well that's right but then all of a sudden he received a message from an unknown who said he had infected his computer with a Trojan and he had recorded uh his porn watching and masturbation sessions through the webcam and he would send the video of these exploits to everyone in the pool chat's address book unless he paid a ransom in Bitcoin so basically extortion we did some techno Pawn twist so this uh this person was in a panic about this and he asked me
what to do especially about uh you know how do I go about removing this All-Seeing and uncontrolling Trojan from my computer I mean what can I do about that because he rightly feared that he might get further blackmail requests even if he paid up now when I heard the story fortunately I was able to reassure him that this was on a bluff on the part of the crook the crook had not installed any Trojan I told him he had simply crafted a plausible threatening letter and he had sent it to as many email addresses as
he could find and then the group just sat back and and simply pocketed The Ransom from those few who actually believed that they had been caught masturbating and were sufficiently scared to believe the threats now my treatment friend was initially a bit skeptical about my reassurance that the Trojan didn't exist and was a bluff but he was then convinced by my explanation once I started going through my own emails and then reading out to him one essentially identical letter that I had also received myself so they said um greetings I have to share bad news
with you approximately a few months ago I have gained access to your devices which is used for internet browsing and after that I've started tracking your internet activities and I have already installed the Trojan virus to operating systems of all the devices that you use to access your email all right and this often provides me with access to all the controls of your devices blah blah live download the audio information data for tomorrow I have access to all your Messengers my virus continuously refreshes the signature and blah blah blah and what else happens uh I've
discovered you're a big fan of adult websites you really love this and that and I watched I managed to record the number of your dirty scenes and Montage the few videos and so on uh which show the way you masturbate and reach orgasms yeah if you have doubts I can make a few clicks of the mouse and all your videos will be shared to your friends colleagues and relatives and so on and let's settle it this way you transfer sixteen hundred dollars to win Bitcoin equivalent and once the transfer is received I will delete all
this dirty stuff right away trust me I keep my word so there you go a crafty low-tech attack that targeted a vulnerability not in the computer software but in the user psychology there was no Trojan like I told him just a well thought out story that would sound believable and persuasive to some victims some recipients would know for sure that those events never happened and that the mess the message had to be a fake but others oppressed by guilt and shame after believing that they had been caught out might find the story Auto plausible and
might be scared into paying the ransom now given the almost nil cost of sending out the emails to as many addresses as possible the crook is obviously not worried if the response rate is very low because it still makes an enormous return on his very modest investment so the reason I I told you this anecdote is I see at least two takeaways from it and number one is that today's computers and also today's smartphones for that matter are sufficiently powerful and complex and actually full of vulnerabilities that this scenario that was depicted in that email
even though uh it was fake it's not too unrealistic it is fairly believable that some very skilled and determined attacker might be able to deploy the kind of Trojan that was described in that demand uh but it would have to be a rather competent and resourceful attacker to do that and nowadays this type of high-tech payload tends to be used rather sparingly and only licensed at high prices to oppressive regimes for the purpose of spear fishing individual political opponents or dissidents or journalists and stuff like that and there's a there was a software called Pegasus
that was in the news recently developed by the NSO a secretive Israeli organization and this is one of these targeted programs that's used to facilitate human rights violations around the world on a massive scale they just sell it too oppressive regimes who pay a lot of money for it and then they can Target whatever they like the second takeaway however is that serious and exploitable vulnerabilities can be found not only in computers but also in human beings and that therefore the competent security expert to be competent must also have a good grasp of human factors
otherwise they won't be able to protect complex socio-technical systems in a holistic fashion and basically every system that's of interest is a complex socio-technical system systems that are limited to just the machines are not that interesting and when you look at the whole thing they're always embedding something bigger which is such technical so we'll have more to say about human factors insecurity in a future lecture now to outsmart the attacker wherever the attacker might decide to uh to strike you must learn to think like the attacker and to think like the attacker you must learn
to spot and exploit the vulnerabilities and therefore you must gain some practical experience in attacking systems this interplay between attack and defense is really at the core of security attack and defense are inextricable you cannot separate them you cannot just say well I'm a good guys I'm going to do defense no no there are some misguided people who worry that how help help this irresponsible University Professor is teaching terrorists how to attack our homeland ah this is really bad well people who think that we fail to understand that nobody can ever become a good Defender
without being skilled at attack the reason why serious University level security courses are needed that teach how to attack systems is because otherwise only criminals would learn that craft and they would learn it from their underground forms as opposed to from a university course and they already do anyway what we are doing here with a course like this one is putting the good guys on the same footing as the bad guys who are already getting that expertise nobody can build a lock capable of withstanding the unwelcome attentions of crooks and burglars without first being a
skilled and resourceful lock picker so you have to have experience of breaking stuff before you can make a defenses that will resist being broken by other people who are good at it in the cyber security World many adversaries are not actually particularly clever we call them the script kiddies okay they are usually very much below the skill level where they could for example identify a new vulnerability and conceive of an attack that would exploit it let alone the level of being able to write a sophisticated Trojan like these Pegasus we were talking about but the
script kit is have become proficient at running these pre-packaged attack tools the scripts that some smarter and more dangerous attackers have created so the script kit is may not be that smart but they can be quite Adept at using those scripts and they can still run circles around the Defenders unless these Defenders get up to speed so Defenders have to be as proficient as attackers otherwise they have no hope so this course is not about turning you into script kiddies it's not about you know teaching you to run automated attack tools it's about making understand
the fundamentals of security things insecurity evolved in a kind of an arms race so today's vulnerability I get patched tomorrow but tomorrow there will be a new attack on the batch system and then a new patch will come in due course and so on so you need to learn the principles not the low level tricks that quickly become obsolete because you know they get patched and so on but in abstract just stating the principles will not make a lot of sense and it will not be of much use so you need a Hands-On understanding of
the principles and you can only gain that by seeing what it is that the bad guys actually do and where is it that the bad guys have difficulties in doing their review stuff where is it that they have to be ingenious what challenges they have to overcome and if you don't go through that then you don't have any hope of developing the mindset and the skill set that will allow you to defeat them now statistically a majority of the bad guys are just script kiddies and they are not particularly ingenious they just you know they
just recycle and reuse the stuff that was invented by a small number of smarter bad guys but I want you to ultimately become the kind of good guy who can defeat those smart bad guys that are at the top of the pyramid so uh to do that you first need to follow in in their intellectual footsteps so in a sense studying the classics okay the classics here would be the attacks that have broken your ground and have made history and of course because these attacks were so devastating and were applied to so many systems then
they had to be stopped and once some countermeasure was developed then they slowly the countermeasures became the adopted default by new systems fortunately so as we do study the classics in this sense we will have to go in and disable those countermeasures that are nowadays standard if we want to be able to replicate what the original bad guys did so if you took me up when I said stop the video and try compiling that program and see if you can change the reward if you just compile the program with the standard default settings of the
modern C compiler then probably uh the compiler silently inserted protections that didn't allow you to do what you thought you could do and overspeed from one variable to the other so when we do explore this in a future lecture about buffer overflow we will have to first pretend that we are going backwards in time and disable the protections that are commonplace now but we're not at the time that this attack was first introduced so we will repeat this pattern again and again in this course and specifically as we uh as we engage with the seed
Labs okay rewind back the clock to a simpler age when the attack was still near and we disable all the countermeasures that have been invented later and that are now deployed by default and then we basically recreate the thought process of that smart first pioneering attacker back then and what they did to basically Implement their attack intuition and then once we have managed to replicate this kind of historical uh historical attack then we enable the modern countermeasure and we see how it stops the old attack and then we see what else the attackers have done
in the meantime to defeat the new countermeasure and so on and so on as we said it's usually a never-ending arms race where there can be several zigzags between attack and defense in this course I want to expose you to Common failure patterns uh common um repeated mistakes in security so that you may recognize them when they occur in new situations in new computer systems that have not been invented yet but that you will encounter in your professional life okay I do not hold in very high esteem people who talk the talk but cannot walk
the walk so I wouldn't want you to be one of them if you are my student if you are able to see a vulnerability you should also have the technical skills to exploit it otherwise you will be pathetically ineffective at stopping those bad guys who would exploit it in anger so you have to be at least the equal of the bad guys if you're if you want to have any hope of defeating them so my aim is that by the end of this course every one of you will have acquired alongside an understanding of the
principles also the skills to exploit a few basic vulnerabilities these Classics we're talking about to set the right incentive for you to gain those skills I'll do my best to set exam questions that can only be solved by people who have acquired those skills by practice if you want to pass my exam do the Practical exercise if you just watch the lectures and read the handout without doing the exercises and without referring to the course textbook you will put yourself at a severe disadvantage now of course with only 12 hour lecture course it's unrealistic to
expect that you would become an expert the kind of person who can invent new security Primitives invent new defenses invent your attacks and so on so if you want to become too proficient at that as with any other topic you will need to put in your proverbial 10 000 hours of practice this course only 12 hours is meant to offer you how to say whistle software a mental roadmap of security give you a taste for the field he would not show you everything it will show you give a glimpse of the breadth of themes and
topics that you need to consider at Cambridge we have a pretty strong research group in security with a tradition that goes pretty far back in time further back than most other groups security groups at competing institutions and if you find security attractive then we hope that you will join us as a graduate student but for now you're basically just going to study this classic the literature as it were and learn the most basic things that crackers and criminals have been doing for decades now and still keep doing it because not every system gets patched unfortunately
now not everything that you will encounter in your professional life would be as basic as the stuff I will be showing you in this course and indeed many modern systems will have been patched against the well-known attacks but nonetheless the same patterns of failure at some higher level tend to reoccur in new flavors and besides you would be surprised at how many deployed systems are still unpatched against decades-old vulnerabilities so even if studying those Classics is only a first baby step it is still a highly educational first step and it will take you maybe quite
a bit further than you might think now since I'm teaching you attack stuff when I'm speaking to intelligent and responsible adults then I should not have to say the following but I'll say it anyway and in the handout that I'll I'll even put a big box around it stay legal okay I'll be teaching you potentially dangerous stuff and it's your responsibility to use it for good and to make sure that you don't accidentally hurt anyone including yourself so stately don't break anything okay in this course I'm going to teach you some attacks and I will
encourage you to become proficient at deploying those attacks these attacks can cause serious damage the Cyber weapons that are aimed at critical infrastructure use many of the same techniques do not launch these attacks on any system other than your own experimental setup understand how to confine your experiments and do confine them ensure that no other system is damaged or affected by your experiments stay legal at all times you will be liable to be sued or prosecuted otherwise and claiming that you did it because of the coursework will never be accepted as a mitigating excuse it
could be responsible be wise be legal with that warning out of the way the court of security is adversarial thinking it is a mindset it's difficult perhaps impossible to teach this mindset so all I can do is inspire you to want to pick up this mindset and to develop it and refine it you will need experience how can you get any experience in security well there are many Avenues the main one and the one I recommend all of you on this course follow is this famous seed labs the seed Labs do require a lot of
work but they are an integral part of this course do not skip them merely because they do not attract marks okay you can consider them optional because they are not rewarded with um with grades but you will never own this material intellectually without actually doing the exercise please practice as much as you can especially if they are difficult for you another Avenue is engaging in Capture the Flag competition CTS that's always good and I continue to help in the organization of these events I've been doing that for many years now because I consider them highly
beneficial if you have the chance to take part in a CTF then please do so and learn from your peers if you're placed in a team to collaborate from time to time I invite the most talented among you including medalists from past ctfs that I organized to do small self-contained and actually well-paid jobs for my Boutique security company called Cambridge cyber a typical task that one of these student contractors might do for me could be to perform penetration testing on a device or some system belonging to my client so to succeed at that you will
need a good mix of creativity lateral thinking and experience and deviousness to some extent and of course intelligence which I'm sure you do have and and I've been very pleased at the results that previous collaborators have produced now the answer you seek will not be in any textbook but it will typically be accessible to you if you know the textbook inside and out so please make the most of all these opportunities to get as much hands-on experience in security as you can and a few who choose not to engage in Practical work and who refuse
to do the work of the seed labs are really cheating themselves out of a valuable education and they will have a hard time passing the exam that I'm going to set for this course at the end of the year you must learn adversarial thinking in order to anticipate what the bad guys might do you have to look at everything with suspicion you must question all assumption and that is in part why security is interesting and appealing and and fun to those of us who are at heart contrarians and reluctant to accept any Dogma but as
I told you you have to be prepared to learn a lot more than in a regular course because all the assumptions that you might end up questioning are there for a reason because the world is too complex without making some simplifying assumptions and so the simplification most of the time is correct but some of the time it is slightly wrong and the clever attacker exploits that subtle discrepancy between the Assumption when the assumption is slightly wrong and the reality okay so when there is this slight Divergence you know they stick their prying tool in and
separate them and so in order to follow the attacker or even better in order to anticipate what the attacker might do you must be well versed not just in the easy world of the simplifying assumption but also in the rather more complicated underlying reality so that you can spot the the subtle places where they diverge as we said abstraction is one of the most powerful tools in the computer scientists Arsenal to dominate the inherent complexity of our field but in the security game you must be prepared to abandon the convenience of abstraction and instead go
back to First principles going down that route can be difficult can be time consuming especially when you are the first one to look for some new discrepancy new vulnerability and nobody has yet pointed out to you which abstraction needs to be questioned and unraveled and compared against reality but that's why good security people are so rare and valuable and in great demand it's useful as a starting point to be able to recognize a pattern a pattern that you spot in your clients security problem that is similar to something that I've shown in this course or
something that you've seen elsewhere in your various extracurricular security experiences it will rarely be exactly the same but on the other hand many core ideas resurface in different guys if you'd be surprised how many times you know the same thing for example not being able to quote user Supply data properly how many times does this um this core abstract idea resurface in many guyses and translates into various families of vulnerabilities so uh when you do find a match between this common failure pattern that you study with me and this match then inspires you to develop
and apply a relevant solution account to measure then that's really satisfying and it's also really valuable because security problems cost real money to your client and you will be saving them this money and a secure and satisfied client will be very happy to pay you a nice fraction of that money that you saved them in the next lecture we'll start digging into more technical material in the meantime please get yourself an x86 box if you don't already have one a real one or include one whatever you prefer an install virtualbox and get the seed virtual
machine going you really need to be doing the seed labs in Pace with the lectures if you want to get the most out of this course so thank you very much for staying until the end and to let me know that you are part of this Elite leave a comment mentioning sunflower seeds and I'll see you in the next lecture