Data security: integrity

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Data security: integrity

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A hacker changes a student's bank balance from $50 to $5000 without permission. Which security principle is broken?
A Availability
B Integrity
2. Which statement best describes data integrity?
A Data can be read by anyone who asks for it
B Data stays accurate and is only changed by authorised people
3. A bank teller with the right permissions corrects a mistyped balance and the change is logged. Is integrity still intact?
A Yes, because an authorised person made the change
B No, because the balance was changed
4. Which situation is a breach of integrity?
A A user edits their own account balance without permission
B The bank website is offline for maintenance
5. Which control helps protect the integrity of a bank balance?
A Giving only authorised staff write permission
B Giving every customer write permission to all accounts

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Integrity AGRANT UPDATE ON accounts TO bank_manager;
2UPDATE accounts SET balance = 999999 WHERE accountId = 7; BThe change was made by an unauthorised person and was accepted without any check, so the balance is no longer accurate and integrity is broken.
3Only authorised users may change a balance, which protects integrity CA tampered balance: an unauthorised change that breaks data integrity
4A balance must stay accurate, so a rule blocks impossible changes DALTER TABLE accounts ADD CHECK (balance >= 0);
5GRANT UPDATE ON accounts TO PUBLIC; EData stays accurate and unaltered unless an authorised person changes it
6A customer edits their own balance from 500 to 5000, and the bank accepts it as correct. FEvery user can change balances, so anyone could tamper with them and integrity is not protected. Only authorised users should get UPDATE.

Definitions

Integrity

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
______ accounts SET balance = 9999 WHERE id = 4;
2.
if storedBalance _ expectedBalance then print "Tampering detected" end if
3.
if ____ = "admin" then balance ← newBalance end if
4.
GRANT ______ ON accounts TO customer;
5.
balance DECIMAL(10,2) _____ (balance >= 0)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A balance ← 500
B input userRole
C input amount
D if userRole ≠ "teller" then
E balance ← balance - amount
F end if
Question 2
A oldTotal ← sum(transactions)
B if oldTotal = balance then
C print "Balance tampered"
D else
E print "Balance tampered"
Question 3
A define checkBalance(stored, now
B if stored ≠ now then
C return "Tampered"
D end if
E return "Intact"
Question 4
A input amount
B newBalance ← balance amount
C write userId, newBalance to log
Question 5
A if role = "teller" then
B balance = balance + deposit
C else
D print "Access denied"
E end if

Answer Key

Data security: integrity
Section A: Quick Questions
Q1
B — Integrity
Q2
B — Data stays accurate and is only changed by authorised people
Q3
A — Yes, because an authorised person made the change
Q4
A — A user edits their own account balance without permission
Q5
A — Giving only authorised staff write permission
Section B: Match the Pairs
Q1
Integrity → Data stays accurate and unaltered unless an authorised person changes it
Q2
UPDATE accounts SET balance = 999999 WHERE accountId = 7; → A tampered balance: an unauthorised change that breaks data integrity
Q3
Only authorised users may change a balance, which protects integrity → GRANT UPDATE ON accounts TO bank_manager;
Q4
A balance must stay accurate, so a rule blocks impossible changes → ALTER TABLE accounts ADD CHECK (balance >= 0);
Q5
GRANT UPDATE ON accounts TO PUBLIC; → Every user can change balances, so anyone could tamper with them and integrity is not protected. Only authorised users should get UPDATE.
Q6
A customer edits their own balance from 500 to 5000, and the bank accepts it as correct. → The change was made by an unauthorised person and was accepted without any check, so the balance is no longer accurate and integrity is broken.
Section C: Definitions
Q1
Integrity — Data stays accurate and unaltered unless an authorised person changes it, so a tampered bank balance breaks integrity.
Section D: Fill in the Blanks
Q1
UPDATE accounts SET balance = 9999 WHERE id = 4;
Q2
if storedBalance ≠ expectedBalance then print "Tampering detected" end if
Q3
if role = "admin" then balance ← newBalance end if
Q4
GRANT SELECT ON accounts TO customer;
Q5
balance DECIMAL(10,2) CHECK (balance >= 0)
Section E: Spot the Error
Q1
D — The condition is reversed, so everyone except a teller could change the balance. Only an authorised user may alter it: if userRole = "teller" then.
Q2
C — When the stored balance matches the transaction total, the data is intact. This branch should print "Integrity OK", not report tampering.
Q3
A — The closing bracket of the parameter list is missing. It should be define checkBalance(stored, now).
Q4
B — The arithmetic operator is missing, so the new balance cannot be calculated. It should be newBalance ← balance - amount.
Q5
B — = compares two values and does not store anything. Assignment needs the arrow: balance ← balance + deposit.