Sample questions
Question 1Easy
Why should passwords be stored hashed with a salt?
- So users can read their passwords back
- To make logins faster for everyone
- So leaked databases do not expose the passwords
- To compress the database storage
Answer: C. So leaked databases do not expose the passwords
Explanation
A salted hash cannot be reversed easily and defeats precomputed tables.
Step-by-step solution
- Hash hides password.
- Salt makes each unique.
- Safe storage.
Why the other options are wrong
- A. Hashes are one way.
- B. Hashing is intentionally slower.
- D. Compression is unrelated.
Question 2Easy
Which attack inserts malicious SQL through an input field?
- Phishing
- SQL injection
- Denial of service
- Port scan
Answer: B. SQL injection
Explanation
SQL injection places SQL fragments in input so the database executes unintended commands.
Step-by-step solution
- Input reaches SQL.
- Attacker adds SQL.
- Injection.
Why the other options are wrong
- A. Phishing tricks users.
- C. DoS floods resources.
- D. Port scan finds open ports.
Question 3Medium
Cross-site scripting (XSS) lets an attacker:
- Read the disk of the server directly
- Crash the database engine remotely
- Guess stored passwords offline
- Run a malicious script in a victim's browser
Answer: D. Run a malicious script in a victim's browser
Explanation
XSS injects script that the victim's browser executes in the site's context.
Step-by-step solution
- Script injected.
- Runs in victim browser.
- XSS.
Why the other options are wrong
- A. That needs server compromise.
- B. That's a different attack.
- C. That is cracking.
Question 4Medium
What is the purpose of penetration testing?
- Simulate an attack to find exploitable weaknesses
- Test the speed of the company network
- Check the spelling of the user interface
- Count the lines of code written
Answer: A. Simulate an attack to find exploitable weaknesses
Explanation
Authorised testers try to exploit the system to reveal real security gaps.
Step-by-step solution
- Authorised attack.
- Find weaknesses.
- Penetration test.
Why the other options are wrong
- B. That's performance work.
- C. Not related.
- D. Not related.
Question 5Medium
Which measure best prevents SQL injection?
- Client-side validation of the input fields only
- Hiding the detailed error page
- Parameterised queries (prepared statements)
- Requiring longer passwords for users
Answer: C. Parameterised queries (prepared statements)
Explanation
Parameterised queries keep data separate from SQL commands.
Step-by-step solution
- Separate code and data.
- Use placeholders.
- Prepared statements.
Why the other options are wrong
- A. Client checks can be bypassed.
- B. Hiding errors does not fix injection.
- D. Passwords are unrelated.
Question 6Medium
What does the principle of least privilege require?
- Give each user or process only the access it needs
- Give administrators access to everything by default
- Share one account among the whole team
- Disable logging for faster performance
Answer: A. Give each user or process only the access it needs
Explanation
Limiting rights reduces the damage if an account or process is compromised.
Step-by-step solution
- Minimum needed.
- Smaller blast radius.
- Least privilege.
Why the other options are wrong
- B. Broad admin access violates the principle.
- C. Shared accounts hide who did what.
- D. Logging supports security.
Practise all 6 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →