12. Security Aspects
Opening
Big idea: Protecting a system means reducing opportunities for harm and preparing to recover.
Use a separate practice folder for the programs. Each example is self-contained unless its section says otherwise.
- Recognise common threats and choose layered protections.
- Distinguish malware, spam, phishing, encryption and access controls.
- Explain cookies, authorised testing and major network-threat concepts.
Read the rule, trace the worked example, and try the quick check before reading its answers. When a result surprises you, change one input and explain the difference.
This is an original lesson following the listed syllabus topics. Examples, datasets, questions and diagrams were created for this edition.
A message arrives during lunch. It claims a delivery failed and asks you to sign in through its button.
The logo looks right and the tone sounds urgent. Nothing has broken yet, but one tap could hand your account to a stranger.
This chapter teaches the pause before that tap.
A second picture helps too. A student uses one short password everywhere: mail, school drive, games.
One leaked list then opens every door at once. A classmate with a password manager and a second login step shrugs off the same leak.
Small habits decide large outcomes.
The chapter builds in nine stages. First it names threats and three protection goals.
Then it classifies malware and safe download habits. Then it explains what protective software can and cannot prove.
Next it studies spam and phishing in detail. Then it separates protected connections from honest destinations.
Next it places firewalls at their boundary. Then it explains cookies and session design.
Then it draws the permission line for security testing. Last it reviews network threats and careful diagnosis.
Three running situations return throughout. A suspicious message asks for a password.
A shared computer holds private school records. A backup copy must rescue a damaged project.
Each situation needs prevention before the event and recovery after it.
Study by predicting. Cover each result line and each expected output before reading it.
Say the answer aloud first. When a prediction fails, find the first line where your trace diverged.
That line holds the lesson. Short sentences carry one idea each.
Expect the same vocabulary in every section. Threat, vulnerability, risk, control, malware, phishing, encryption, firewall, cookie and permission keep one meaning throughout.
When a sentence confuses you, check which term it uses. Technical words are defined in plain words at first use.
A common early mistake is trusting one good sign. A padlock icon, a clean scan or a familiar logo each answers one question only.
Each section teaches you to ask which question a sign answers and which questions remain open.
Diagrams in this chapter are checklists, not decoration. Cover the caption and explain the arrows first.
Then read the walkthrough and check your explanation. Steps that you can repeat from memory are steps you can use under pressure.
Worked examples follow one pattern: goal, approach, trace, result. Read the goal before the steps. Trace each step against the table or the diagram. State the result in your own words before reading it.
Numbers in this chapter come from stated classroom models, not from measurements of real attackers. Password counts assume every combination is equally likely, which overstates weak human choices.
Real safety also depends on behaviour, so ask your teacher before quoting these figures as real-world guarantees.
Prevention lowers the chance of harm. Recovery limits the damage. A complete plan needs both, because no single control removes every risk.
12.1 THREATS AND PREVENTION
Security becomes easier to reason about when you name the protected goal. Is the concern that somebody reads private data, changes it or prevents permitted users from using it? These are different kinds of harm.
A control helps with a particular threat under particular conditions. Backups aid recovery. Access checks limit use. Updates remove some known weaknesses. They work together because none solves every problem.
- Identify the data or service that matters.
- Describe a plausible failure and its effect.
- Choose controls that address that failure and plan how to recover.
A shared account can fail even when no software has crashed: its password may have been disclosed.
A threat is a possible cause of harm. A vulnerability is a weakness that can be exploited.
A risk combines the possibility of a harmful event with its likely impact in a particular context. A control reduces the likelihood or impact.
No single control removes every risk.
Think of the shared account. The threat is someone guessing or reusing the disclosed password.
The vulnerability is one weak secret protecting everything. The risk grows because the account holds private records.
The controls are a fresh strong password, a second login step and limited sharing.
Three goals organise every defence. Read them slowly, because later sections return to them by name.
| Goal | Meaning | Example |
|---|---|---|
| Confidentiality | Only permitted parties access information. | Restrict access to private records. |
| Integrity | Information is protected from unauthorised or unintended alteration. | Validate changes and preserve an audit trail. |
| Availability | Permitted users can obtain a service when needed. | Plan recovery from failures and overload. |
Read the table row by row. Confidentiality hides information from the wrong eyes.
Integrity keeps it correct against alteration. Availability keeps it reachable for the right users.
A leaked file breaks the first. A silently edited mark breaks the second.
A crashed server at deadline breaks the third.
An attacker cannot read the records but makes the service unavailable. Which goal is affected?
Goal. Name the failed goal without guessing from the attacker’s motive.
Approach. Test each goal against what still works.
Trace. Secrecy still holds, so confidentiality survives. Nothing was altered, so integrity survives. Permitted users cannot reach the service, so availability fails.
Result. Availability.
Result: Availability.
Passwords deserve careful arithmetic, because length beats cleverness. A password space is the count of all possible combinations.
Assume each position is filled independently. Then multiply the choices per position.
Start with a 4-digit PIN. Each digit offers 10 choices.
Multiply step by step: 10 × 10 = 100, then 100 × 10 = 1000, then 1000 × 10 = 10000. The space holds 10000 combinations.
Every step is shown, so check each multiplication.
Now try lowercase letters. Two letters give 26 × 26 = 676.
Three letters give 676 × 26 = 17576. Six letters are two triples side by side, so 17576 × 17576 = 308915776.
Notice the jump: doubling the length squares the space.
Eight lowercase letters multiply once more by 676: 308915776 × 676 = 208827064576. Two extra letters multiplied the space by almost seven hundred. Length is the cheapest defence a user controls.
Compare variety against length. With 62 symbols per position (26 small plus 26 capital plus 10 digits), four characters give 14776336.
That is far below the 308915776 of six plain lowercase letters. A longer simple password can beat a short fancy one.
Prefer length first, then add variety.
Counts assume random choices, so treat them as upper bounds. Human words and dates shrink the real space sharply.
Never assume an attacker must try combinations in order or by hand. Automated guessing is fast, which is exactly why length and uniqueness matter.
| Habit | Do | Avoid |
|---|---|---|
| Choice | Use a long unique password per service. | Reusing one short password everywhere. |
| Storage | Keep secrets in a reputable password manager. | Plain lists, photos or shared notes. |
| Second step | Turn on multifactor authentication where offered. | Relying on a password alone for mail. |
| Sharing | Grant least privilege and remove old access. | Sharing one login across a whole group. |
Read the table as four habits. Each row pairs one action with its opposite.
Managers remember long secrets so people do not reuse them. A second step means a stolen password alone is not enough.
Least privilege means each person holds only the access their task needs.
Cover the output box and say what the program should print before reading on.
def check_password(pw):
issues = []
if len(pw) < 8:
issues.append("too short")
if pw == pw.lower():
issues.append("no capital letter")
if pw == pw.upper():
issues.append("no small letter")
if not any(c.isdigit() for c in pw):
issues.append("no digit")
if " " in pw:
issues.append("has a space")
if not issues:
return "strong: passes all checks"
return "weak: " + ", ".join(issues)
print(check_password("sunrise"))
print(check_password("Sunrise42"))Opens in a new tab with the code ready. Click Visualize Execution, then step through the program.
- The function collects problems in a list called issues.
- Each check appends one plain complaint when its rule fails.
- The generator expression tests every character for a digit.
- An empty list means strong; a full list is joined into one report.
- The two calls test a short lowercase word and a longer mixed secret.
weak: too short, no capital letter, no digit
strong: passes all checksTest a password with a space inside it and predict the new complaint before running.
Read the program again. “sunrise” fails three rules at once: short, no capital, no digit. “Sunrise42” passes all five checks.
A checker like this teaches the rules, but it never proves a password is unpredictable. Real strength also needs randomness, not just rule-passing.
Backups turn disasters into inconveniences. A backup is a separate copy that survives when the original is lost, damaged or locked.
The known 3-2-1 routine keeps 3 copies on 2 different media with 1 copy off site. Each number answers a different failure: one copy breaks, one device dies, one room floods.
Count a small school routine. Keep 7 daily copies, 4 weekly copies and 6 monthly copies. Add them: 7 + 4 = 11, then 11 + 6 = 17. Seventeen dated copies let recovery reach back past an unnoticed corruption.
Read the diagram from top to bottom. Copying runs on a timetable, not on hope.
One copy leaves the building or the account, so one fire cannot take everything. Restores are rehearsed before they are needed.
A failed copy is replaced, because a backup you never test is only a rumour of safety.
Predict each printed line first. The trace below explains every one.
days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
copies = []
for d in days:
copies.append("backup-" + d)
if len(copies) > 3:
copies.pop(0)
print(copies)
print(len(copies))Opens in a new tab with the code ready. Click Visualize Execution, then step through the program.
- The list names seven day labels in weekly order.
- Each day appends one labelled copy to the store.
- The length test keeps at most three copies at any time.
- Removing index zero discards the oldest copy first.
- The prints show the surviving three labels and their count.
['backup-Fri', 'backup-Sat', 'backup-Sun']
3Change the limit from 3 to 2 and predict which labels survive before running.
Read the program again. After Sunday only Friday, Saturday and Sunday remain.
Monday through Thursday aged out one by one. That is rotation: bounded storage with a sliding window of recent history.
Real tools add weekly and monthly tiers, but the oldest-first idea is identical.
A group keeps its only project copy on one laptop. Design a backup that survives a stolen laptop.
Goal. Protect both availability and confidentiality after theft.
Approach. Apply the diagram steps to this exact failure.
Trace. A scheduled copy must already exist before the theft. One copy must live off the laptop, such as encrypted cloud storage the group controls. The copy needs a tested restore, or recovery is a guess. Encryption plus limited sharing keeps the stolen copy unreadable to strangers.
Result. Scheduled encrypted copies, one off the device, with a rehearsed restore.
Result: Recovery works only if the copy, the separation and the rehearsal all predate the loss.
When suspicious activity appears, follow the organisation’s reporting and containment process. Do not investigate by running unknown attachments or experimenting against someone else’s systems. Never enter a password or one-time code on a page reached from a message.
Long unique secrets, a second login step, least privilege and tested separate copies: four habits that stop most everyday account disasters.
12.2 MALWARE
A harmful program can disguise itself, collect information and deny access to files in the same incident. The category names describe behaviours; they do not require each program to fit only one box.
Start with the behaviour you observed or are explaining. Does it attach to other files, spread independently, misrepresent its purpose or record private activity? That reasoning is more useful than memorising a scary name.
- Describe the unwanted action without assuming its cause.
- Match the behaviour to the relevant category or categories.
- Choose containment and recovery steps through the approved process.
Malware is software used to perform unwanted harmful actions, and its categories can overlap.
A malware item is software used to perform unwanted harmful actions. Categories describe behaviour, so one sample can belong to several at once.
A program can mislead like a Trojan and then lock files like ransomware. Classify by what it does, not by one label.
Picture a worksheet attachment that looks useful. Its icon promises a study sheet.
Its hidden behaviour installs an unwanted program. The visible purpose never establishes the true behaviour.
That gap is exactly what the table names.
| Term | Main characteristic | Everyday example |
|---|---|---|
| Virus | Attaches to a host file or program and spreads through the host’s execution or sharing. | An infected document template passed between computers. |
| Worm | Can propagate between systems without relying on the same host-file pattern as a virus. | A self-spreading program moving across a local network. |
| Ransomware | Denies access or threatens data exposure to pressure a victim. | Locked project files with a payment demand. |
| Trojan | Presents a misleading legitimate-looking purpose while carrying unwanted behaviour. | A fake useful tool that installs something unwanted. |
| Spyware | Collects information without appropriate permission. | A hidden program recording browsing habits. |
| Adware | Displays or injects unwanted advertising; behaviour and consent determine the risk. | Pop-ups injected into pages the user visits. |
| Keylogger | Records keystrokes; malicious use can expose private input. | Captured passwords typed on a compromised device. |
Read the table row by row. The first column names the behaviour.
The second states the mechanism in one sentence. The third gives a plain situation, not a real specimen.
Two rows can fit one sample: disguise plus locking, or spreading plus spying. Overlapping labels are normal.
Distribution routes matter as much as names. Deceptive downloads, malicious attachments, compromised sites, vulnerable services and removable media all carry infections.
The presence of a familiar icon or filename does not establish safety. Attackers copy familiar appearances deliberately.
Read the diagram as a habit, not a single event. Need comes first: avoid fetching files you never asked for.
Source comes second: prefer the maker’s own verified site or store. Scanning comes third: let updated protection inspect the saved file.
Updated software comes last: open with patched readers that close known holes.
- Obtain software from trusted, verified sources.
- Keep systems and applications updated.
- Avoid unnecessary administrative access.
- Use maintained protective tools and follow alerts.
- Keep recovery copies isolated from the same failure path.
- Report suspicious content instead of testing it casually.
Read the list as layers. Trusted sources shrink exposure.
Updates close exploited holes. Limited rights contain damage.
Protective tools watch continuously. Isolated copies survive encryption attacks.
Reporting protects the whole group. No single line carries the plan alone.
An on-screen or website-provided keyboard changes how input is entered. It is not a universal defence: malicious software may capture the screen, browser content or other input events.
A trusted device and sound account protection matter more than assuming a different keyboard makes a compromised system safe. Never open an unexpected attachment just to check what it does.
Why can a document attachment be risky even if it appears to contain a useful worksheet?
Goal. Decide whether a benign appearance settles the safety question.
Approach. Separate the visible promise from the executable behaviour.
Trace. The preview shows worksheet content, which is the Trojan-style promise. Macros, embedded objects or a double extension can carry the real behaviour. The application opening it may run that behaviour automatically.
Result. Appearance never settles the question.
Result: Treat the origin, file type, permissions and warnings as part of the decision.
A free download promises a premium game with no payment. The site is unknown and urges speed. Apply the diagram.
Goal. Reach a decision using the four checks in order.
Approach. Walk the download diagram step by step.
Trace. Need is weak: the offer creates urgency the user never had. Source fails: an unknown site is not the maker’s verified outlet. A scan cannot repair a deliberately harmful file. Updated software still runs what the user chooses to run.
Result. Do not download.
Result: Fetch games only from verified stores, and treat urgency as a warning sign.
Behaviour defines malware, appearance does not. Judge the origin, the file type and the warnings — never the icon or the promise.
12.3 ANTIVIRUS
Protective tools can match known patterns or recognise suspicious behaviour. They can help, but their result is not a perfect proof. A threat can be missed, and legitimate software can sometimes be flagged.
The right response to an alert is a controlled investigation, not automatically trusting it or disabling all protection. A useful process checks the source, the evidence and the impact before restoring or allowing content.
- Keep the tool and its detection information maintained.
- Read an alert in its context.
- Follow the response process and preserve recovery options.
Protective software is useful, but its observations are not perfect proof.
An antivirus or endpoint-protection tool looks for malicious or suspicious content and behaviour. Its effectiveness depends on current detection data, enabled protections and the surrounding system.
A clean scan is evidence, not a guarantee that every threat is absent.
Think of a hall monitor with a photo book of known troublemakers. New faces, disguises and wrong places all limit the book.
Updates add photos. Patrolling adds watching.
Rules decide the response. The monitor helps greatly and still misses things.
| Method | Idea | Limitation |
|---|---|---|
| Signature-based detection | Match known patterns. | New or altered samples may not match known signatures. |
| Heuristics | Look for suspicious structural features. | Can miss threats or flag legitimate software. |
| Behaviour monitoring | Observe actions during execution. | Context and detection timing matter. |
| Sandbox analysis | Run content in an isolated analysis environment. | The observed behaviour may differ from another environment. |
| Data-driven classification | Use learned features or statistical models. | Training data and false positives affect the result. |
| Real-time protection | Check activity as it occurs. | It still needs updates and an appropriate response policy. |
Read the table as six tools with six blind spots. Signatures know the past.
Heuristics guess from structure. Behaviour watches actions.
Sandboxes test in isolation. Statistical models learn from examples.
Real-time checks guard the present moment. Every row needs updates and human judgement beside it.
Quarantine isolates a suspected item; it is not a reason to copy the item elsewhere to see whether it works. A false positive is legitimate content flagged as malicious.
Follow the approved restoration and incident process when a file may be a false positive. Never disable protection casually to silence an alert.
A scanner reports a risk in a needed application. Should the user disable all protection to continue?
Goal. Choose a response that keeps both work and safety.
Approach. Weigh the alert against the cost of removing every guard.
Trace. The alert may be a true detection or a false positive, and neither is known yet. Disabling everything removes unrelated safeguards for every other file. The approved route checks this one file and its source instead.
Result. Do not disable everything.
Result: Investigate the specific alert and source rather than bypassing the whole protection layer.
A scan returns clean, yet the computer behaves oddly after a strange download. What does the clean result prove?
Goal. Interpret negative evidence correctly.
Approach. Recall the table’s limitations row by row.
Trace. Signatures miss new samples. Heuristics miss careful disguises. Behaviour monitoring depends on timing and context. A clean result lowers suspicion but cannot certify absence, especially with a matching symptom.
Result. Little by itself.
Result: Treat the odd behaviour as fresh evidence: update, rescan, and follow the reporting process.
Updates deserve one plain paragraph. Threat knowledge changes daily, so detection data must change with it.
Stale protection knows only yesterday’s patterns. Enable automatic updates where offered and confirm they actually run.
An updater that silently failed is the same as no updater.
A detection is a reason to follow the process. A clean scan is a reason for cautious relief, never for certainty. Evidence guides the next step; it rarely ends the story.
12.4 SPAM
A deceptive message may claim to come from a trusted organisation. Its aim can be to make you act before checking. A polished design or a familiar sender label does not establish the real destination.
Use an independently trusted route to inspect the account or contact the organisation. This breaks the attacker’s attempt to choose both the urgent story and the place where you enter private information.
- Pause when a request is unexpected or pressuring you.
- Check the claim through a known service address or contact route.
- Report suspicious content instead of supplying credentials through the message.
Unwanted messages become more dangerous when they persuade a person to reveal information or execute content.
A student checks messages after class. One promises a prize, one warns of account closure, one shares a class note.
Two demand immediate taps. One simply informs.
Sorting them correctly protects both money and accounts. This section teaches the sorting habit.
Spam is unsolicited bulk messaging. Phishing uses deception to obtain sensitive information or induce harmful action. A message can be both, but a targeted phishing message need not be bulk spam.
Bulk describes volume; deception describes intent.
Warning signs cluster into a short list. Unexpected requests arrive without context.
Pressure demands immediate action. Payment or credential demands appear where none belong.
The claimed sender mismatches the actual address. Correct spelling and polished layout prove nothing; attackers copy design cheaply.
| Warning sign | Safer check |
|---|---|
| Unexpected prize or refund | Ask whether you ever entered or paid anything. |
| Urgent threat of closure | Open the service through your own saved address. |
| Request for a password or code | No legitimate service asks for these by message. |
| Link label versus address | Inspect the real destination before tapping. |
| Odd sender address | Compare it with a known genuine message. |
Read the table as pairs. The left column shows what the message displays.
The right column states the independent check. Prizes are tested against your own history.
Threats are tested through your own route. Credential requests fail immediately.
Labels are tested against destinations. Senders are tested against known samples.
Read the diagram slowly. Stopping breaks the urgency spell the message casts.
Checking the destination exposes disguised addresses. Verifying through a trusted route means typing the known address yourself or calling a published number.
Reporting protects others before deleting removes the bait.
- Pause before following an unexpected request.
- Check through a trusted contact route or known service address.
- Do not supply passwords or one-time authentication codes to a message sender.
- Use the service’s reporting feature or the organisation’s approved route.
Read the numbered list as the same four moves in pocket form. Pause, verify independently, withhold secrets, report officially. Each numbered item matches one diagram box. Memorise the order so it survives real urgency.
A message says an account will be closed unless you sign in through its button. What is a safer next step?
Goal. Reach the account safely without obeying the message.
Approach. Replace the message’s route with your own trusted route.
Trace. The button leads wherever the sender chose, which is the one fact you cannot trust. Your saved address or application leads where you chose. Comparing the two reveals the trick without any risk.
Result. Use your own route.
Result: Do not let the message itself choose the place where you enter credentials.
A class group shares 30 suspicious messages. Members report 80 percent of them. How many reports is that, and why does reporting matter?
Goal. Convert a reporting rate into a count and a reason.
Approach. Multiply the total by the rate, then state the group benefit.
Trace. 80 percent of 30 is (80 ÷ 100) × 30 = 24. Each report trains filters and warns the group. Silence helps only the sender.
Result. 24 reports.
Result: Six unreported messages can still trap someone, so reporting is protection for others.
Filtering reduces unwanted traffic but can miss messages or misclassify legitimate ones. Users still need a clear reporting process and a way to verify genuine requests.
A filter is a sieve, not a wall: useful daily, insufficient alone.
Urgency plus a supplied link is the classic shape of phishing. Slow down, choose your own route, and report the attempt.
12.5 HTTP vs HTTPS
HTTPS helps protect communication between your browser and the connected site. It does not establish that the connected site is the one you intended to visit or that its operator is honest.
Imagine sending information through a protected channel to an impostor. The channel can work correctly while the overall action is still harmful. Destination choice and connection protection both matter.
- Check that the destination is the intended service.
- Respect certificate and connection warnings.
- Use the application’s permission and account controls as well as protected transport.
A protected connection helps secure data in transit, but it does not make every destination trustworthy.
A student sees a padlock on a look-alike bank page and relaxes. The padlock answers one question: is this connection protected.
It never answers the harder question: is this the real bank. This section separates the two questions permanently.
HTTP defines web request and response semantics. HTTPS protects HTTP communication using TLS-based mechanisms that provide confidentiality, integrity and server authentication under the connection’s certificate and trust checks. Each property guards the journey, not the honesty of the endpoint.
Encryption in transit makes passive reading and undetected alteration harder on the protected connection. It does not stop a dishonest destination from receiving data that a user deliberately submits to it.
A phishing site can use HTTPS too. The tunnel is safe; the far end is not.
Read the diagram as three separate jobs. Opening the intended address is your responsibility: check the spelling yourself.
Building the channel is the browser’s job with certificates. Sending only permitted details is again yours.
Checking rights is the server’s job. Four boxes, three owners, zero excuses.
Integrity deserves a concrete picture. A hash turns any input into a fixed-length fingerprint.
The same input always gives the same fingerprint. A tiny change gives a different one.
Comparing fingerprints reveals alteration without re-reading the whole file.
Say the result in your own words before checking it against the output box.
import hashlib
first = hashlib.sha256("Sunrise42".encode()).hexdigest()
second = hashlib.sha256("Sunrise42".encode()).hexdigest()
third = hashlib.sha256("Sunrise43".encode()).hexdigest()
print(first == second)
print(first == third)
print(len(first))
print(first[:16])Copy the code, open the playground, and paste it into the console. Files are temporary browser files.
- The import loads the standard hashing library.
- Each line hashes one short secret into a fingerprint string.
- The first two prints compare equal and unequal fingerprints.
- The last prints show the fixed length and the first sixteen characters.
True
False
64
47881f98487cabf5Change one character of the third secret and predict which printed lines change before running.
Read the program again. Identical inputs give identical fingerprints, so the first comparison prints True.
One changed character gives a different fingerprint, so the second prints False. Every fingerprint is 64 characters long, and the sample begins 47881f98487cabf5.
Real password systems add further protections, but same-input-same-output is the core idea.
Do not bypass unexpected certificate warnings to continue a sensitive task. Use a trusted route and the approved support process.
A page may also include third-party resources or scripts, so the whole application design matters. Never bypass a certificate warning to reach mail, banking or school records.
A browser shows HTTPS for a look-alike sign-in page. Does that prove the page belongs to the intended service?
Goal. Decide what the padlock certifies and what it leaves open.
Approach. List the three HTTPS properties and test the page against each.
Trace. Confidentiality holds for this connection. Integrity holds for this connection. Server authentication holds for the wrong server: the certificate belongs to the look-alike. The intended identity was never checked.
Result. No.
Result: HTTPS is necessary protection for sensitive exchanges, not a universal honesty badge.
A download’s published fingerprint matches the file you received. What does the match establish?
Goal. State exactly what a matching hash proves.
Approach. Apply the same-input-same-output rule in both directions.
Trace. The fingerprint depends on every byte, so an altered file would almost certainly differ. A match therefore means the bytes equal the published ones. It says nothing about whether the published file itself is safe to run.
Result. Intact delivery, not safety approval.
Result: Match the fingerprint, then still judge the source before running anything.
A protected route to an attacker is still the wrong route. Check the destination first, the protection second, and your permissions third.
12.6 FIREWALL
A firewall applies rules to the traffic it can observe. It can block an unnecessary service or restrict a permitted connection. It usually does not know every business rule inside an allowed application request.
A web connection may be permitted while a particular private report is not. The application therefore still needs to check the account and the action. Different security layers solve different parts of the problem.
- State which communication the firewall policy should permit.
- Test the intended allowed and blocked paths.
- Keep application-level checks for permissions and valid operations.
A firewall applies communication rules at a boundary or endpoint.
A school computer joins the canteen Wi-Fi for the first time. Games, printers and the library server all sit on nearby networks.
Something must decide which conversations may start. That decider is the firewall, and its rules are written before trouble arrives.
A firewall allows, blocks or inspects traffic according to a policy. A network firewall can protect a segment boundary; a host firewall applies rules on an individual system.
Its position and the traffic it can observe affect what it can enforce. A boundary guard cannot judge conversations it never sees.
| Approach | Teaching idea |
|---|---|
| Packet filtering | Apply rules using fields such as addresses, ports and protocols. |
| Stateful inspection | Track relevant connection state while evaluating traffic. |
| Application-aware inspection or proxying | Use application-level information where available and supported. |
Read the table from simplest to smartest. Filtering reads envelope labels.
Stateful inspection remembers the conversation. Application-aware checks peek at meaning where possible.
Each step costs more effort and sees more context. None of them replaces the application’s own permission checks.
Read the diagram as a routine. Naming allowed services forces deliberate choices.
Blocking the rest by default closes forgotten doors. Logging records what the rules caught for later review.
A review date stops rules from fossilising after needs change. Default-deny means silence is safer than surprise.
A permitted connection can still carry harmful application input. Encrypted traffic can also limit what an intermediary can inspect unless the system is specifically designed to provide inspection.
A firewall does not replace secure application code, updates or identity checks. The gate checks tickets; it does not direct the play.
A web service must accept browser requests. Can its firewall alone decide whether a user may read a private report?
Goal. Place the permission decision at its correct layer.
Approach. Ask what the firewall observes versus what the rule needs.
Trace. The firewall sees an allowed web connection from an address. The report rule needs the authenticated account and its rights. Addresses are not accounts, and connections are not permissions.
Result. No.
Result: The application must enforce that access rule.
A new game server is installed and friends cannot connect. The owner considers deleting every firewall rule. What is the safer sequence?
Goal. Restore the game without opening everything.
Approach. Follow the diagram backwards from the symptom.
Trace. Name the game’s exact port and protocol first. Add one narrow rule for that service. Test the game connection and one unrelated blocked probe. Deleting all rules would also admit every other unwanted visitor.
Result. One narrow rule, then both tests.
Result: Test both allowed and disallowed paths after any rule change.
A useful rule has a purpose, an owner and a review process. Blocking broadly can break legitimate work; allowing broadly can expose unnecessary services.
Test both allowed and disallowed paths. A rule nobody owns becomes either a outage or a hole.
A firewall controls which conversations may start. It never decides what guests may do once inside — that is the application’s job.
12.7 Cookies
Web requests arrive separately. A cookie can help a browser present the same session identifier again, so the server can connect later requests with stored session state.
The identifier can be sensitive even if it looks like random text. Its power comes from what the server accepts it as evidence of. Cookie controls reduce particular exposure risks but do not repair every application flaw.
- Identify what the cookie stores and why it is needed.
- Limit its scope, transport and access appropriately.
- Protect the server actions that use it as well as the cookie itself.
Cookies let a website retain a small piece of state across otherwise separate requests.
A student signs in to a library site, opens three book pages, and stays signed in throughout. The web forgets each request by design, yet the site remembers.
The memory aid is a small cookie travelling with every matching request.
A cookie is data associated with a website that the browser can send with later matching requests. A session cookie can contain an opaque identifier used by the server to find session state.
It should not be described as automatically storing the user’s password. Random-looking text can still be precious.
Cookies support sign-in continuity, preferences and other functions. They can also support cross-request or cross-site tracking depending on how they are used.
Cookie contents and scope need careful design; deleting one cookie does not erase every kind of browser or server-side tracking data.
| Attribute or policy | Purpose |
|---|---|
| Secure | Restrict sending to secure transport under browser rules. |
| HttpOnly | Prevent ordinary page scripts from directly reading the cookie. |
| SameSite | Limit some cross-site sending behaviours. |
| Domain, path and expiry | Control relevant scope and lifetime. |
Read the table as four locks on one small box. Secure keeps it off open channels.
HttpOnly hides it from ordinary scripts. SameSite trims cross-site journeys.
Scope and expiry bound where it travels and how long it lives. Four locks, four different thieves deterred, none sufficient alone.
These controls reduce particular risks but do not repair all application vulnerabilities. HttpOnly does not mean a malicious page script can never cause authenticated actions.
The server must protect state-changing requests and apply permissions. A locked box still needs a guarded room.
Why should a session cookie be treated as sensitive even if it contains only random-looking text?
Goal. Explain why unreadable text still needs protection.
Approach. Ask where the meaning of the text lives.
Trace. The meaning lives in the server’s session table, not in the characters. Presenting the token retrieves the session, like a cloakroom ticket retrieves a coat. Whoever holds the ticket collects the coat, readable or not.
Result. Possession equals authority.
Result: Its authority comes from the server’s mapping, not whether its text is readable.
A signed-in user visits a malicious page that triggers a request to the library site. Which cookie control helps, and what remains unprotected?
Goal. Separate the control that helps from the gaps that remain.
Approach. Test each table row against a forged cross-site request.
Trace. SameSite limits some cross-site sending, so it directly resists this shape of attack. Secure and HttpOnly do not stop the browser from attaching cookies to a request it does send. Server-side permission and request checks remain essential.
Result. SameSite helps; server checks finish the job.
Result: Layer the defences instead of trusting any single attribute.
Cookies remember so users do not have to retype. Design them as carefully as passwords: small scope, short life, and server checks behind every one.
12.8 HACKERS AND CRACKERS
Wanting to help does not automatically permit access to another person’s system. A legitimate test begins with an agreement about what may be tested and what actions are allowed.
That agreement should also cover sensitive data, reporting and limits on disruption. Finding a weakness does not grant permission to collect private records or keep experimenting beyond the scope.
- Obtain permission and define the test scope.
- Use an appropriate lab for unapproved experiments.
- Report findings through the agreed route with minimal sensitive evidence.
Security testing is legitimate when it has permission, defined scope and responsible handling of results.
A student finds a strange page that shows other users’ data. Curiosity says click further.
The law and basic care say stop. The difference between helping and harming here is not skill but permission.
This section draws that line clearly.
Classroom terms such as white hat, black hat and grey hat describe different claimed intentions or authorisation. The decisive practical rule is permission: a helpful intention does not grant access to someone else’s system.
Labels describe stories; permission decides legitimacy.
| Classroom label | Usual meaning | Necessary caution |
|---|---|---|
| White hat or ethical tester | Tests within agreed authorisation. | Scope, data handling and reporting still matter. |
| Black hat or malicious intruder | Acts for harmful or unauthorised purposes. | Intent and actions can harm people and services. |
| Grey hat | Acts without clear permission while claiming a beneficial purpose. | Lack of permission remains a serious problem. |
Read the table with one question: who agreed to this. The first row has an agreement covering targets, actions and reporting.
The second row harms by design. The third row claims good intent without agreement, which still exposes data and breaks trust.
Agreement is the whole difference.
“Hacker” has several meanings, including creative technical work; it is not a precise substitute for criminal or attacker. Use specific language such as authorised tester, intruder or researcher when the distinction matters.
Vague words hide the permission question instead of answering it.
A student finds a flaw in a public site. Should they access private records to prove it?
Goal. Decide the next action after an accidental discovery.
Approach. Test every candidate action against permission.
Trace. Discovery granted nothing; it only revealed a weakness. Opening private records exceeds any legitimate scope and exposes real people. Minimal non-sensitive evidence plus a responsible report helps without harming.
Result. Stop and report.
Result: Stop, preserve minimal non-sensitive evidence and follow the responsible reporting route.
A club wants to practise security skills safely. Design a legitimate practice setup.
Goal. Build skill without touching anyone else’s system.
Approach. List what permission requires, then satisfy each item locally.
Trace. Use a deliberately provided lab or the student’s own isolated machine. Agree in writing what is permitted: targets, accounts, request volume and acceptable disruption. Keep practice traffic inside that boundary and handle any findings responsibly.
Result. A local lab with written scope.
Result: Practise in a deliberately provided lab or your own isolated system, within agreed limits.
Practice in a deliberately provided lab or your own isolated system. Agree on what is permitted before testing, including request volume, accounts, stored data and acceptable disruption.
Skill grows fastest where mistakes harm nobody.
Curiosity is welcome; unauthorised access is not. Permission in writing, scope in advance, care with data, and a report at the end.
12.9 NETWORK SECURITY THREATS
An unavailable service can have several causes. An unusual traffic pattern can also be ordinary routing or an incomplete view. Security investigation starts by recording what was actually observed.
Then compare possible explanations with the evidence. A flood may reduce availability; a memory-safety failure may permit corruption; an asymmetric path may simply hide half the conversation from one monitor.
- Record the symptom, time and observation point.
- Identify the security property or service behaviour affected.
- Investigate competing explanations before claiming a particular attack.
Threat descriptions should explain the failed security property and the control that addresses it.
A monitor shows odd traffic on a school network. Someone says attack at once.
A careful analyst says observation first, diagnosis second. Rushing the label causes wrong fixes and false blame.
This section teaches the careful order.
| Threat or concept | Meaning | Defensive focus |
|---|---|---|
| Denial of service | Exhaust or disrupt resources so legitimate use fails. | Capacity planning, rate controls, resilient design and response. |
| Intrusion | Unauthorised entry or action in a system. | Updates, strong access controls, monitoring and least privilege. |
| Buffer overflow | A memory-safety failure can overwrite data outside an intended buffer. | Memory-safe design, bounds checking and platform protections. |
| Traffic flooding | Excess traffic consumes link or processing resources. | Filtering, upstream coordination and service-specific controls. |
| Snooping or eavesdropping | Unpermitted observation of communication or activity. | Protected channels and restricted access to relevant data. |
Read the table as five diagnoses with prescriptions. Denial of service attacks availability through exhaustion.
Intrusion breaks entry rules. Buffer overflow breaks memory boundaries.
Flooding drowns capacity. Snooping steals secrecy.
Each row pairs the failure with the control family that answers it.
Requests and responses can take different network paths. This is not automatically an intrusion or an attack.
It can complicate stateful inspection and troubleshooting because one monitoring point may not observe both directions. A one-sided monitor sees half a conversation and must say so.
A URL can appear in browser history, logs or other application records. Do not put reusable secrets into URL query parameters and assume HTTPS prevents every later disclosure.
Protect data throughout its storage and use, not only while crossing one link. Encryption guards the journey; copies keep the secret.
A network monitor sees requests but no replies. Must the server have been attacked?
Goal. Decide whether a partial observation proves an attack.
Approach. List innocent explanations before malicious ones.
Trace. Replies may travel another path under asymmetric routing. The observation point may miss half the flow. A genuine failure or overload explains silence without any attacker. One-sided evidence cannot carry a two-sided conclusion.
Result. No.
Result: Investigate the evidence; do not turn a partial observation into a definite diagnosis.
A developer places a session token in a page URL for convenience. Name two places it can leak and the safer design.
Goal. Trace where URL text travels after the address bar.
Approach. Follow copies of the URL through history, logs and sharing.
Trace. Browser history keeps it on the device. Server and proxy logs keep it on machines. Shared links and referrals carry it further. HTTPS never promised to erase these copies. A cookie or header with proper attributes plus server checks keeps tokens out of URLs.
Result. History and logs, at minimum.
Result: Keep reusable secrets out of URLs; protect them through their whole lifetime.
Useful incident records identify what was observed, when, where and with what confidence limits. Avoid distributing sensitive captures widely.
Follow the responsible response process. A calm record beats a loud accusation every time.
Observe first, diagnose second. Name the failed property, name the control, and state your confidence before acting.
Summary
Use these points to test what you can explain without looking back.
- Security protects confidentiality, integrity and availability through several layers.
- Threat, vulnerability, risk and control describe different parts of the problem.
- Password length multiplies the guessing space; unique long secrets plus a second step stop most account takeovers.
- Malware categories can overlap; updated protection tools are helpful but imperfect.
- Verify unexpected requests through a trusted independent route.
- HTTPS protects a connection, not the honesty of every destination.
- Hash fingerprints reveal alteration; matching bytes prove delivery, not safety.
- Firewalls, cookie controls and authentication each solve specific problems.
- Keep tested separate copies and rehearse restores before disaster strikes.
- Only test systems within permission and agreed scope.
- Investigate evidence before labelling an unusual network condition an attack.
Exercise
Work independently. For a program, predict the result before running it. Explain your reasoning as well as giving an answer.
12.1 A 4-digit PIN allows how many combinations? Show every multiplication step.
12.2 Six lowercase letters allow 308915776 combinations. Show how two triples build this count.
12.3 Eight lowercase letters allow 208827064576 combinations. Explain the jump from six letters in one sentence with the multiplication.
12.4 Four characters from 62 symbols allow 14776336 combinations. A friend claims this beats six lowercase letters. Judge the claim with numbers.
12.5 Spot the phish. A message claims your photo storage is full and offers a cleanup button. List three checks you perform before tapping anything.
12.6 Spot the phish. A sender address reads support@ schoo1-drive.example with a digit one inside the name. The layout is perfect. Decide and justify.
12.7 Fix the habit. A student reuses Sunrise42 for mail, games and the school drive. Name the failure and prescribe three concrete changes.
12.8 Predict the two printed lines when this program runs, and name the rule each failing check enforces.
print(check_password("sunrise"))
print(check_password("Sunrise42"))12.9 Design the backup. A project lives on one laptop plus a weekly copy on the same desk drive. Name two single events that still destroy everything, then design a routine that survives them.
12.10 A rotation keeps 7 daily, 4 weekly and 6 monthly copies. Show the total and explain why tiers beat one daily copy.
12.11 A fingerprint comparison prints True for the original file and False after one byte changes. State exactly what the match proved about the first file.
12.12 Find the flaw: “This page shows HTTPS, so the free premium download it offers must be safe.”
12.13 A firewall permits web traffic to a library server. A visitor requests another reader’s loan record. State which component must refuse and why the firewall cannot decide.
12.14 A session token travels in page URLs. Name two places it leaks and give the safer design in one sentence.
12.15 A student discovers a flaw showing other users’ data. Write the next three actions in order, and name the one action that is forbidden.
12.16 A monitor sees outbound requests with no replies. Give two innocent explanations and the correct next step.
Answers
12.1 10 × 10 = 100, 100 × 10 = 1000, 1000 × 10 = 10000. The space holds 10000 combinations.
12.2 676 × 26 = 17576 for three letters. 17576 × 17576 = 308915776 for six letters.
12.3 308915776 × 676 = 208827064576. Two extra positions multiply the space by 676.
12.4 14776336 is far below 308915776. Length wins here: prefer the longer password, then add variety.
12.5 Check the real destination without tapping. Verify through your own saved address. Ask whether you ever received genuine warnings there. Urgency plus a supplied button is the classic shape.
12.6 Reject it. Compare with a known genuine message: the spelling differs. Perfect layout never proves sender identity.
12.7 One leak opens every door. Give each service a long unique secret, store them in a password manager, and turn on a second login step for mail.
12.8 Weak with three complaints, then strong. Length, capital letter and digit rules each add guessing space and resist common patterns.
12.9 Theft and fire take laptop plus desk drive together. Keep scheduled encrypted copies with one off site, and rehearse a restore every term.
12.10 7 + 4 = 11, then 11 + 6 = 17. Tiers reach back past corruption noticed late; one tier alone ages out too fast.
12.11 Its bytes equalled the published ones at comparison time. Matching proves intact delivery, not that the published file is safe to run.
12.12 HTTPS protects the connection, not the honesty of the destination or the file. Judge the source, match the fingerprint, then decide.
12.13 The application must refuse. The firewall sees an allowed connection, not the authenticated account and its rights.
12.14 Browser history and server or proxy logs. Keep tokens in cookies or headers with proper attributes, backed by server permission checks.
12.15 Stop further access, preserve minimal non-sensitive evidence, and report through the responsible route. Opening private records to prove the flaw is forbidden.
12.16 Asymmetric routing may hide replies, or the observation point may be incomplete. Record what was observed with confidence limits and investigate before diagnosing attack.