Office hours are on a shared Google Calendar.Scan the code, or use the link on the course page.
Competition emails go to all four TAs,with me in CC. They run the setup session and check every proof of concept.
The handle under each name is their GitHub account.You will see them in the competition repositories.
TA office hours
[+] Where and when
Hamilton Hall. We are in room 702. Photo: Beyond My Ken, CC BY-SA 4.0, Wikimedia Commons.
Monday and Wednesday, 4:10 to 5:25 PM.26 classes. The first one is today, the last one is Dec 14.
702 Hamilton Hall,this room.
My office is CSB 457.The TAs' office hours are on a shared Google Calendar, QR code on the TA slide. Mine are TBA.
No classon Mon Nov 2 (academic holiday) and Wed Nov 25 (Thanksgiving).
[+] Where we are going
01How this course works: goals, grading, the competition, the rules
02Adversarial thinking: the mindset, and its three questions
03Three announcements: the final exam, a new competition rule, the round weights
04Recap: security goals and threat models, in plain words
05A worked example: an election, from goals to attacks. Then money, and who the adversary is
First we go through how the course works. Then the lecture proper:
a way of thinking, and one everyday example with no computers in it. The way of thinking is exactly the same
when there are.
[+] Course goals
Understand the fundamental principles of security.
What are the common security mechanisms?Why do they often go wrong?
What are the underlying principlesbehind building secure systems?
Why is building secure systems hard?
[ 01 ]
How this course works
Grading, deadlines, the competition, and the rules. All of it is also on the course page.
[+] The course, top-down
Three parts add up to 100%. Extra credit goes on top,
before the curve. The next slides take each part in turn.
[+] Homework and midterms: 30%
Do the homework yourself, and the midterm will look familiar.
Homework 2 and Midterm 2 work the same way: due Tue Nov 10, 11:59 PM, exam Wed Nov 11. If you miss a
midterm you take an oral exam instead, and the homework does not count for that unit.
[+] The final exam: 30%
30%of the course grade
Mon Dec 213:30–6:30 PM
requiredno exceptions
There is no make-up written exam.If you cannot attend a midterm or the final, you take an oral exam instead.
For a midterm taken orally,the homework is not taken into consideration. The oral exam alone decides that unit.
The room goes on the course pageas soon as the registrar confirms it. Block the afternoon now.
[+] The hacking competition: 40%
Everyone plants a bug. Then everyone hunts for everyone else's bugs.
Two rounds of this. It is the most fun part of the course, and I think the part that teaches the most.
[+] You hunt everyone, and everyone hunts you
Two bugs found: attack points twice, first blood twice, since alone on a bug means first. Your own bug survived: the full defense score.
Bob and Eve come back on the scoring examples. We will put up a leaderboard soon: refreshed every week or two, and right away when a bug gets found.
[x] What counts as a bug
on facebook/zstd, say
$./compile.sh && ./test.sh[ok] 1975/1975 tests passed # healthy$./poc.shbuild, then run the crafted input ...Segmentation fault (core dumped)$echo $?139
CountsA segmentation fault, an abort, or a similar fatal signal, reached from normal program input.
Does not countWrong output, a hang, running out of memory, or anything that needs a change to the build or test scripts.
And the tests still passA bug that breaks the test suite is not a hidden bug, it is a broken program.
[+] Pick a program from the project list
About 130 real programs so far,each a fork pinned to the commit ProgramBench was built from, with compile.sh and test.sh at the root.
Tests kept must be a number.N/A means the project is not ready yet.
The TA checkboxes mean validated.Only validated projects are eligible.
Used in roundshows what earlier rounds touched. The fresh-project bonus looks at that column.
Make the diff bigger than the bug.Refactor around it.
Add semantically equivalent changes.Same behaviour, more to read.
Touch several files.One file with one hunk is a signpost.
Mind the cap: at most 15% of the original lines of code.Counted after clang-format, rustfmt, or gofmt, so one giant line does not help.
Keep it honest: obfuscate the diff, never the build or test scripts.Touch those and you are disqualified for the round: 0 points, attack included.
[+] Competition timeline
Round 1: prepare Sep 16 to Oct 2, attack Oct 3 to Oct 30. Round 2: prepare Oct 31 to Nov 13,
attack Nov 14 to Dec 11. The project list is public from day one, so you can look early.
Competition deadlines are 11:59 PM by the system clock, GitHub for pull requests and CourseWorks for attack PoCs. Homework is different: due at 11:59 PM the day
before its midterm, with no late days.
[+] Competition scoring, per round
Five scores. A, B, C, and D are weights, and I announce the numbers at the start of each round. Round 1 counts 20% of the competition, Round 2 the other 80%.
Score
You get it when
Points
Submission
your pull request is in on time
A. Each late day costs A/3, at most two.
Defense
nobody finds your bug by the end of the attack phase
B, all or nothing
Attack
you find someone else's bug
B / n, shared with the n people who found it
First blood
you are among the first three to find a bug
C, 0.8 C, 0.6 C, in order
Fresh project
yours is the first valid pull request on a project no round has used
Alone on a bug means first blood on it too. Two days late, the most you can be, would have made line [1]
50 × (1 − 2/3), about 16.7; a third day and the pull request is out. Round 1 counts 20%, Round 2 counts 80%, and the weighted total is curved.
[+] Scoring, a worked example (2/2)
One day late keeps two thirds of A. Defense is all or nothing: two finders or twenty, the 50 is gone.
Third on Bob's bug still pays, a third of B plus 0.6 C. The dashed boxes are what example 1 had and this round does not.
[+] From competition points to a grade
Add up your two rounds.Every score on the previous slide, both rounds.
I curve that totalso that the class median sits at 85% of the competition points.
The curved number is 40% of your course grade,next to 30% for homework and midterms and 30% for the final.
The course grade is curved once more,with the median at B+. Extra credit is added before this curve.
[!] Competition rules (1/2)
One program, one bug, per round.You pick from the project list. Two students may pick the same program, but the fresh-project bonus goes to the earlier valid pull request.
The system clock is the time.Submission: when your pull request was opened on GitHub. Attack: when your PoC landed on CourseWorks. Emails do not count.
Crash means crash.A segmentation fault, an abort, or a similar fatal signal. Wrong output, hangs, and running out of memory do not count.
The tests still pass.Your program must build and pass the project's test suite. Touch the build or test scripts, or the test data, and you are disqualified for the round: 0 points.
[!] Competition rules (2/2)
PoCs are private, pull requests are public.Your defense PoC goes on the pull request as a zip locked with your password. Attack PoCs go through CourseWorks, named victim-attacker-poc.sh.
Late days, on submission only.Each late day costs a third of the submission score. After two late days the pull request no longer counts, but you can still attack in that round.
Your own work.Talking about techniques is fine. Sharing diffs, PoCs, crashing inputs, or passwords is an integrity violation.
Stay in bounds.Attack the pull requests in our forks and nothing else. GitHub itself, the TAs' machines, and other students' accounts are off limits.
[+] Extra credit
+1
Attendance, in reverse
Attendance is not required. But if fewer than one third of the class shows up to a lecture,
everyone who is there gets one extra-credit point.
A room like this is worth a point to everyone in it. Photo: Yinan Chen, public domain.
+1
Bug bounty
Find a real bug in any GitHub project with more than 1,000 stars and get it confirmed by the
maintainers. Follow the project's security policy, and do not go public before the fix.
The bug bounty leaderboard on my site, with your name on it.
Extra credit is added before the curve. There may or may not be a cap on bug bounty
points. If someone hits it, I will say so right away, so nobody keeps hunting for nothing.
[+] What to do this week
Bookmark the course page. Schedule, policies, grading, and every lecture deck live there.
Wed Sep 16: bring a laptop. No lecture that day. The TAs help you set up the competition environment.
By Sun Sep 20, 11:59 PM: register. One email to the TAs, CC me, with your UNI, your GitHub handle, and a competition password you use for nothing else.
Read the competition page. The submission steps and the full scoring are there. We do not go through the mechanics today.
zzhang.xyz/teaching/security1-fall26
The competition page is linked from it.
[ 02 ]
The art of adversarial thinking
The most useful habit you will take from this course.
[+] What is adversarial thinking?
“Security requires a particular mindset. Security professionals - at least the good
ones - see the world differently. They can't walk into a store without
noticing how they might shoplift. They can't use a computer without wondering about the
security vulnerabilities. They can't vote without trying to figure out how to vote twice.
They just can't help it.”
— Bruce Schneier
[!] Adversarial thinking: a disclaimer
Hopefully you will learn to think like a criminal mastermind
but behave like a gentleperson.
We teach these attacks so you can defend against them. Running them against systems you do not
own, or have no permission to test, is a crime. And Columbia's academic integrity policy applies
to everything you do in this course.
[+] Adversarial thinking: three key questions
No mechanism is “secure” by itself.
It is secure for a given goal, against a given adversary.
[+] Key security goals
[C]
Confidentiality
Data not leaked. Nobody unauthorized learns it.
[I]
Integrity
Data not modified. Nobody unauthorized changes it.
[A]
Availability
Data is accessible when needed. Nobody can deny it to you.
[T]
Authenticity
Data origin cannot be spoofed. It is really from who it claims.
Almost every goal we will see this semester is one of these four, or a mix of them.
[+] You can apply adversarial thinking anywhere
Columbia ID cardsCan you fake an ID card? What does the reader check, and what does the person at the door check?
ATM machineHow does the service person get access to refill it with cash? Can you look like the service person?
MTA MetroCardCan you increase the card balance without paying? Where does the balance live, on the card or on a server?
Try this on anything you used today.
[ 03 ]
Before we continue: three announcements
The date of the final exam, one new competition rule, and how the two competition
rounds are weighted. All three are on the course page as well.
[!] Announcement 1: the final exam
Mon Dec 21one week after the last class, which is Mon Dec 14
3:30–6:30 PMthree hours, in the afternoon
30%of your course grade
Block that afternoon now.Put it in your calendar today, and do not book travel that leaves before the evening of December 21.
The room is not confirmed yet.The registrar assigns it. As soon as I have it, it goes on the course page, and I will say it in class too.
There is no make-up written exam.If you really cannot attend, you take an oral exam with me instead. Email me as early as you can.
The exam is required for everyone.It is one of the three parts of the grade: 30% homework and midterms, 30% final, 40% competition.
[!] Announcement 2: a new competition rule (1/2)
The rule, exactly as it is written on the competition pageYour change may touch at most 15% of the program's original lines of code,
counted after formatting.
That is one sentence with three pieces. Here is what each piece means.
“Touch” means lines added plus lines removed,the two numbers that git diff --stat prints. A line you edit counts twice: once as removed, once as added.
“Original lines of code” is the size of the program before your change:the line count of the tree in our fork, the one you started from.
“Counted after formatting” means we format both trees first,the original and yours, with the same formatter at default settings, and only then diff them. So squeezing ten statements onto one line does not shrink your diff.
The formatters:clang-format for C and C++, rustfmt for Rust, gofmt for Go. Run the one for your language yourself before you count.
[!] Announcement 2: the cap, with numbers (2/2)say your program is 20,000 lines long
$clang-format -i original/**/*.c mine/**/*.c # C: same formatter, both trees$wc -l original/ # the size before your change20000 total
$git diff --stat original mine # after formatting
14 files changed, 2000 insertions(+), 800 deletions(-)
touched = 2000 + 800 = 2800 cap = 15% of 20000 = 3000
2800 <= 3000 [ok] a valid submission 3300 > 3000 [x] not valid
Why have a cap at all?In the attack phase everyone reads every pull request. Without a cap, someone could rewrite half the program and nobody could read anything. The cap keeps the game about hiding a bug well.
Over the cap means not a valid submission.It is as if you had not submitted for that round. So check the size before you open the pull request, and leave yourself some margin.
[!] Announcement 3: Round 1 is 20%, Round 2 is 80%
$competition_points = 0.2 × round_1 + 0.8 × round_2 # then curved, then 40% of the course
Why not 50 / 50?Because Round 1 is a warm-up. Most of you have never planted a bug or hunted for one. Round 1 is where you learn how the game is played: how people hide bugs, how people find them, what a good diff and a good proof of concept look like.
So a rough Round 1 does not sink you.A mistake in Round 1 costs a quarter of what the same mistake costs in Round 2.
Round 2 is where the points are.Take every attack and every defense you learned in Round 1, and use it there.
[!] Announcement 3: the same rule, with numbers
Student
Round 1
Round 2
0.2 × R1 + 0.8 × R2
Points
Alice
100
200
20 + 160
180
Bob
200
100
40 + 80
120
Carol
60
200
12 + 160
172
Alice and Bob both scored 300 raw points.Alice ends 60 points ahead, because her good round was the one that counts four times as much.
Carol had a weak Round 1 and a strong Round 2.She lands within 8 points of Alice. That is the whole point of the weighting: learn in Round 1, deliver in Round 2.
These points are then curved,so that the class median sits at 85%, and the curved number is 40% of your course grade.
[ 04 ]
Recap: security goals and threat models
Last time we ended with three questions and four goals. Before we use them on a real
example, here they are again, in plain words.
[+] Recap: adversarial thinking asks three questions
[1]
Security goal
What do we want to stay true, no matter who tries to break it? One sentence about the
system, not about the attacker.
Example: nobody but me reads my diary.
[2]
Threat model
Who might try to break it, and what can they do? A list of the adversary's abilities,
and of what we assume they cannot do.
Example: my little brother. He can open
drawers, but he cannot pick a lock.
[3]
Mechanism
What we build, or what we do, so that the goal holds against that adversary.
Example: a locked drawer. Enough against my brother. Not enough against my father,
who can simply order me to open it, suspecting I hide wine in there.
“Is it secure?” is not a full question. The full question is:
does this mechanism keep this goal, against this adversary?
[+] Recap: the four security goals, in plain words
[C]
Confidentiality
Nobody who should not see the data gets to see it.
Diary: nobody else reads it.
[I]
Integrity
Nobody who should not change the data gets to change it.
Diary: nobody adds a page or erases one.
[A]
Availability
The data, or the service, is there when you need it.
Diary: I can open it whenever I want. Nobody takes it away.
[T]
Authenticity
The data really comes from where it says it comes from.
Diary: a page signed “me” was really written by me.
Every goal you will write this semester is one of these four, or a mix of them.When you write a goal down, say which letter it is.
Goals can pull against each other.We will see it today: a vote that is easy to check is hard to keep secret.
[+] The method we will follow today, top-down
Describe the system in plain words, as if everyone were honest. What goes in, what comes out, who does what.
Write down the security goals. One sentence each, and say which of the four goals it is.
Write down the threat model. Who might attack, what they want, what they can do, and what we assume they cannot do.
Choose a mechanism for each goal. Something you build, or a procedure that people follow.
Attack it. For each goal and each adversary, ask: does the mechanism still hold? Where it does not, you have found a gap. Fix it, or write down that you accept it.
That is the whole lecture, and most of the course. Today we run it on an election.
[ 05 ]
Worked example: an election
No computers anywhere. We describe the system, write down the goals, name the adversaries,
choose the mechanisms, and then try to break them.
[+] Step 1: the system, with everyone honest
A town of 1,000 people elects a mayor. Two candidates, A and B. Here is election day.
The rules, when everyone is honest:every resident over 18 may vote, each person votes once, and the candidate with more votes wins.
This is the correctness story: what the system does with honest people.Security starts at the next question: what happens when someone is not honest?
[+] Step 2: what do we want to stay true? Four goals
G1 · one person, one voteAuthenticity [T]. Only residents over 18 vote, each of them once. Every counted ballot came from a real voter.
G2 · the count is honestIntegrity [I]. Every ballot in the box is counted as it was marked. Nothing is added, lost, or changed.
G3 · the vote is secretConfidentiality [C]. Nobody can learn how you voted. Not the workers, not the candidates, not even if you want to prove it.
G4 · the election happensAvailability [A]. Everyone who wants to vote can, and the result is out on election night. Nobody can shut it down.
G3 has a strange tail: you cannot prove your own vote, even if you want to. In a few slides you
will see why. It is what makes buying votes pointless.
[+] Step 3: who might attack? Four adversaries
A threat model is a list of abilities, not a name.“T2” really means “someone who can hold the ballots and be alone with them”, whoever that turns out to be.
It also says what we assume the adversary cannot do.For example: we assume T1 cannot get near the ballot box. Assumptions like this are where systems get broken later, so write them down.
[+] Step 3: what each adversary can and cannot do
Adversary
What they can do
What we assume they cannot do
T1 · a voter
Show up twice. Claim a name that is not theirs. Mail in a second ballot.
Touch the ballot box, see other people's ballots, or change the count.
T2 · a poll worker
Everything T1 can, plus: hold the ballots, read them, lose a stack, add a stack, misreport the tally.
Send away the people who come to watch the count.
T3 · a campaign
Pay voters, if it can check how they voted. Pay a worker. Print convincing fake ballots. Spread lies.
Be at every station at once, or force anyone to do anything.
T4 · a government
Cut the power. Close the roads. Threaten or arrest workers. Change the law on the day.
Not much. Nothing a town's poll workers do can stop it.
T4 is out of scope. A town election cannot stop a government, so we say so out loud, cross T4 out,
and design against T1 to T3 only. Every later slide ignores T4.
[+] Step 4: choose a mechanism for each goal
Notice: one poll worker runs the station. A mechanism can be a thing, like a lock or a sealed box,
or a procedure, like “the worker stays with the box.” Things break; procedures get skipped.
[x] Step 5: attack G1, one person, one vote
G1 · one person, one vote · authenticityThe goal: only residents over 18 vote, each of them once. The mechanism, the voter roll: a printed list of residents over 18. At the door the worker checks your ID, crosses you out, and hands you one ballot.
T1 comes back at 5 PM in a different coat.Holds. Their name was crossed out at 9 AM. No second ballot.
T1 uses the name of a neighbor who moved away.Depends. With a stale list and no ID check, they get a ballot. The roll is only as good as both.
T2, the worker, quietly skips crossing out their friends.Breaks. One worker checks the list, and nobody checks the worker.
New mechanism: a second worker, from the rival candidate's sideBoth workers check the list and the ID. Rival sides do not cover for each other.
[x] Step 5: attack G2, the count is honest
G2 · the count is honest · integrityThe goal: every ballot in the box is counted as it was marked. The mechanism, the sealed box and a public count: shown empty at 6 AM, sealed, the worker stays with it all day, counted at 8 PM in front of everyone.
T1 tries to stuff ten extra ballots into the box.Holds. They were handed one ballot, and the worker is watching the box.
T2, alone with the box at lunch, swaps fifty ballots.Breaks. The worker is the only person watching the box, and the worker is the attacker.
T3 prints 500 fake ballots and pays the worker to add them.Breaks. The public count at 8 PM counts the fakes too. Nobody knows they are fake.
New mechanisms: the second worker again, plus one free checkThe rival worker stays with the box too. And at 8 PM, ballots in the box must equal names crossed out.
[x] Step 5: attack G3, the vote is secret
G3 · the vote is secret · confidentialityThe goal: nobody can learn how you voted, not even if you want to prove it. The mechanism, the booth and the identical ballot: every ballot is the same blank paper. You mark it alone, fold it, drop it in yourself. No phones.
T3 pays $50 to anyone who votes for A.Holds. The buyer cannot check, so voters take the money and vote as they like.
T3 asks voters to photograph their ballot.Depends on the no-phones rule. Better: let voters swap a spoiled ballot for a new one, so a photo proves nothing.
T2 puts a tiny dot on each ballot, in a different spot per voter, and notes who got which.Breaks. After the count, the dots reveal every person's vote.
New mechanism: the second worker, once moreThe rival worker checks that every ballot handed out is blank and identical.
[x] Step 5: attack G4, the election happens
G4 · the election happens · availabilityThe goal: everyone who wants to vote can, and the result is out on election night. The mechanism, many stations, paper, and the law: several stations open 6 AM to 8 PM, paper and pencils, and a law that every station must open.
T1 blocks the door of one station.Holds. The police move them along, and there are other stations.
T2 “oversleeps” and opens the station at noon.Breaks with one worker. With the second worker, who also has a key, it holds.
T3 spreads a rumor that voting is on Wednesday.Partly breaks. No lock stops a lie. The fix is information: every household gets a card with the date.
Not every mechanism is a lock. Some are procedures, some are information, and some are the law.
[+] The scoreboard: secure against whom?
Goal
T1 voter
T2, one worker
T2, two workers
T3 campaign
G1 one person, one vote
holds
breaks
holds
holds
G2 the count is honest
holds
breaks
holds if ballots are counted against names
holds if ballots are counted against names
G3 the vote is secret
holds
breaks
holds
holds if no phones in the booth
G4 the election happens
holds
breaks
holds
partly, lies get through
T4 has no column. We crossed it out on the threat-model slide: this election does not try to stop a government.
Secure against a voter. Against a worker, only once there are two of them. Partly against a campaign.
“Is it secure?” has no answer. “Secure against whom?” does.
[+] Money: the same three questions, 5,000 years ago
The system.Before coins, people in Mesopotamia kept accounts with small clay tokens. One token meant one sheep, or one jar of grain. The tokens stayed in a temple, or traveled sealed inside a clay envelope.
The goals.Only the temple may create tokens, so a token is real proof of a debt: authenticity. And anyone handed a token can check that it is genuine, without walking to the temple.
The threat model.Anyone with a lump of clay can make a token that looks the same. Clay is free and the shapes are simple. Inside the temple, the walls did the security work. Outside, nothing does.
The question.How do you make a token that can travel from hand to hand and still meet both goals?
Clay counting tokens: the accounting record before writing.
[+] Money: the mechanism, then and now
Coins, from around the 6th century BCE, answered the question with three ideas. The paper money in your wallet uses the same three.
Anyone can check a bill: hold it to the light, tilt it, feel the paper. Only the central bank can make one.
Keep that shape in mind. The crypto lecture builds it out of math.
[+] Who is the adversary? It depends on who you are
For a town election, T1 to T3 is the right target.For a national election, the government is the whole point. Same system, different adversary, different budget.
The same is true for you.A criminal wants money and goes after whoever is easiest. A government can control the network itself. Most of the cryptography in this course exists for the second one.
[+] Takeaways
Write the goal down first, in one sentence.Say which of the four it is: confidentiality, integrity, availability, authenticity.
Name the adversary and list what they can do.“Secure” only ever means secure against them. The same election holds against a voter and falls to a government.
A mechanism answers one goal against one adversary,and it rests on assumptions. The ballot box stops a voter; it stops a worker only once a second worker is watching.
Goals pull against each other.A ballot with your name on it is easy to check and impossible to keep secret. You pick mechanisms for all the goals at once.
$./think --like-an-adversary --next crypto# next: how to make data that cannot be forged
[+] Acknowledgements
These lecture materials were provided by Suman Jana (Columbia University),
and this deck is a re-typeset and extended version of his Security I slides. The money example
follows his; the election example is new.
Some slides in the original material are borrowed from Vitaly Shmatikov
and Ari Juels.