Year 10TechnologySupport
This sheet is about defending systems. Read each question and code example carefully. Never test these ideas on a website or system you do not own or have written permission to test.
Read the text
When data turns into instructions
- [1]
Most apps and websites store their information in a database: tables of rows and columns, like a set of linked spreadsheets. A school library app might have a table called books, with columns for title, author and shelf. Programs talk to the database using SQL (Structured Query Language). A query such as SELECT title FROM books WHERE author = 'Joy Cowley' asks the database for the titles of every book by that author.
- [2]
Many queries include something a user typed, such as a search word or a username. The danger comes when a program builds the query by gluing the user's text straight into the SQL. The database receives one long piece of text and cannot tell which part the programmer wrote and which part came from the user. If someone types text that contains SQL, the database may treat it as part of the instructions instead of as a value to look up. This is called SQL injection.
- [3]
Think of a library request slip that says "Please fetch the book called ____". A trusting librarian reads the whole slip as instructions. If someone writes a book title followed by "and also hand over the staff room keys" in the blank, the librarian might do both. The slip should have kept the blank as just a book title, whatever was written in it.
- [4]
SQL injection has been behind some of the largest data breaches in the world, exposing millions of people's passwords, addresses and card details. It is also one of the easiest problems to prevent. The main defence is a parameterised query: the program sends the SQL with a placeholder, and sends the user's text separately as a value. The database always treats that value as data, never as instructions. Other layers help too: checking that input looks the way it should, giving the app's database account only the permissions it needs, and showing users simple error messages instead of technical details.
- [5]
In New Zealand, accessing a computer system without authorisation is a criminal offence under the Crimes Act 1961. Trying out an attack on a school, business or government website "just to see" is not a harmless experiment. Security professionals only test systems with written permission, and someone who finds a weakness by accident should report it to the owner or to the National Cyber Security Centre rather than exploring further.
ADatabases and queries
Use paragraph 1.
- 1.
Match each word to its meaning.
(2 marks)- Database
- Table
- Query
- SQL
- Aa set of rows and columns about one kind of thing
- Bthe language programs use to talk to a database
- Corganised storage of information in tables
- Da request to find or change data
- 2.
What does this query ask for? SELECT title FROM books WHERE shelf = 'B3'
(1 mark)- The titles of all books on shelf B3
- Every column for every book
- The shelf number of a book called B3
- It deletes the books on shelf B3
- 3.
SQL injection happens when a program glues the user's straight into a query, so the database treats some of it as instead of data.
(2 marks)
BStaying safe
Use paragraphs 3 to 5.
- 4.
Read paragraph 3. In the library slip example, what should the librarian do with whatever is written in the blank? Sentence starter: "The librarian should treat…"
(1 mark) - 5.
What is the main defence against SQL injection?
(1 mark)- A parameterised query
- A longer password
- A faster database
- Turning the website off at night
- 6.
In New Zealand it is legal to try to break into a website as long as you don't change anything.
(1 mark)- True
- False
- 7.
Read paragraph 5. You notice an error on a business website that might be a security weakness. What should you do? Sentence starter: "I should…"
(1 mark)