Introduction
Security people are often asked "is this system secure?" The honest answer is always another question: secure against what? Before you can protect anything, you need words for what can go wrong. The oldest and most useful set of words is the CIA triad: confidentiality, integrity and availability. (The CIA here has nothing to do with the spy agency.)
Think about your bKash or Nagad account. You want three things from it. Nobody else should see your balance or your PIN. Nobody should be able to change the amount you send. And the app should work at 11 pm when you need to pay your hostel rent. Those three wishes are the whole triad.
How it works
Every security problem breaks at least one of the three properties.
| Property | It means | Broken when |
|---|---|---|
| Confidentiality | Only the right people can read the data | A password leaks, a laptop is stolen, a message is read on the way |
| Integrity | Data is changed only by the right people, in the right way | Marks are edited, a payment amount is altered, a file is corrupted |
| Availability | The system works when the right people need it | A server crashes, a site is flooded with traffic, a disk fails with no backup |
Each property has its own tools:
- Confidentiality is protected by access control (who may read what) and by encryption, which makes data unreadable without a key.
- Integrity is protected by permissions (who may change what), by checksums and hashes that show when data changed, and by logs that record who changed it.
- Availability is protected by backups, spare servers, monitoring and limits on how much any one user can ask for.
The three properties pull against each other. Locking a file so that nobody can read it is perfect confidentiality and zero availability. A good design finds the balance the situation needs: a hospital's patient records need high availability in an emergency, while an exam paper the night before needs confidentiality above all.
Two more words often sit next to the triad. Authenticity means you can trust who sent something, and non-repudiation means the sender cannot later deny sending it. Both are really about integrity of identity, and they come back when we meet digital signatures.
// Each incident breaks one part of the CIA triad.
const incidents = [
{ what: "Hostel Wi-Fi password posted in a public group", breaks: "confidentiality" },
{ what: "A student edits their own marks in the portal", breaks: "integrity" },
{ what: "Course registration site down on the last day", breaks: "availability" },
{ what: "Lost phone with an unlocked banking app", breaks: "confidentiality" },
];
let c = 0;
let i = 0;
let a = 0;
for (const incident of incidents) {
if (incident.breaks === "confidentiality") c += 1;
else if (incident.breaks === "integrity") i += 1;
else a += 1;
console.log(incident.breaks.padEnd(16) + incident.what);
}
console.log(`C: ${c}, I: ${i}, A: ${a}`);The program above sorts real-life incidents into the property each one breaks. Step through it and watch the three counters change.
Example
Integrity is the hardest property to see: a changed number looks just like a correct one. One simple way to notice a change is a checksum, a short number worked out from every character of a message. The sender computes it and sends it along; the receiver computes it again and compares.
// A checksum: a short number worked out from every character of a message.
// If one character changes, the number almost always changes too.
function checksum(text) {
let sum = 0;
for (let k = 0; k < text.length; k++) {
sum = (sum * 31 + text.charCodeAt(k)) % 65536;
}
return sum;
}
const sent = "Pay 500 taka to Rahim";
const tag = checksum(sent);
console.log("sent: " + sent + " checksum " + tag);
const received = "Pay 900 taka to Rahim";
const check = checksum(received);
console.log("received: " + received + " checksum " + check);
console.log(check === tag ? "intact" : "changed on the way");Line by line
checksumstartssumat 0 and walks through the text one character at a time.- For each character it multiplies the running sum by 31 and adds the character's code (
charCodeAt). The% 65536keeps the number between 0 and 65535. - The sender's message
Pay 500 taka to Rahimgives the checksum 30322. - On the way, one digit changes:
5becomes9. The receiver's checksum is now 61046. - The two numbers differ, so the program reports that the message changed.
Expected result
sent: Pay 500 taka to Rahim checksum 30322
received: Pay 900 taka to Rahim checksum 61046
changed on the way
There is a catch, and it matters. A checksum catches accidents, such as a noisy line flipping a bit. It does not stop an attacker: someone who can change 500 to 900 can also work out the new checksum and send that instead. Protecting integrity against people needs a secret key or a signature, which the cryptography module builds up to.
In the real world
- Banks and mobile wallets protect confidentiality with PINs and encryption, integrity with transaction logs that cannot be edited, and availability with several data centres.
- Download pages for operating systems publish a hash next to each file, so you can check that the file you got is the one they released.
- A university results portal that crashes on result day has an availability problem, even if no data leaked.
- Ransomware encrypts files so their owner cannot use them (availability). Many ransomware groups also copy the files out first and threaten to publish them, which breaks confidentiality as well.
Common mistakes
- Thinking security means only secrecy. A system that keeps every secret but is down for a week has still failed.
- Treating a checksum as protection against attackers. It only detects accidental changes, because anyone can recompute it.
- Forgetting availability when adding protection. Locking accounts after three wrong passwords stops guessing, but it also lets an attacker lock out every user on purpose.
- Saying "secure" without saying against what. Always name the property and the threat.
Best practices
- For every system you build, write down what confidentiality, integrity and availability mean for it, in one line each.
- Decide which of the three matters most for each kind of data before choosing tools.
- Keep backups somewhere an attacker on the main system cannot reach, so availability survives a breach.
- Log who changed important data and when, so integrity problems can be traced.
Summary
The CIA triad names the three things security protects. Confidentiality keeps data away from the wrong readers, integrity keeps it from being changed wrongly, and availability keeps it working for the right users. Every attack breaks at least one of them, and every protection costs a little of another, so good design is about balance. A checksum can show that data changed by accident, but defending integrity against a person needs secret keys, which come later in this course.
Quick check
Key takeaways
- Every attack breaks confidentiality, integrity, availability, or more than one of them.
- Protecting one property usually costs a little of another, so design for the balance the data needs.
- A checksum detects accidental changes only; stopping deliberate changes needs a secret key or a signature.
- Ask "secure against what?" before choosing any protection.
Practice problems for this lesson
Was this lesson clear?
My notes
Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.